Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/damianc/math-qfzeros
Returns zeros of a quadratic function.
https://github.com/damianc/math-qfzeros
Last synced: about 1 month ago
JSON representation
Returns zeros of a quadratic function.
- Host: GitHub
- URL: https://github.com/damianc/math-qfzeros
- Owner: damianc
- Created: 2023-09-28T09:26:51.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-05T17:55:19.000Z (about 1 year ago)
- Last Synced: 2023-10-05T18:43:29.740Z (about 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# math-qfzeros
Method returns the roots (or zeros) of the univariate quadratic function $f(x)=ax^2+bx+c$: `null`, $[x_0]$ or $[x_1,x_2]$.
```
Math.qfZeros(a,b,c)
```
We can get the intersection points of a parabola and horizontal line $y=0x+n$, what may be interpreted as if x-axis were translated by $n$ units towards the top (or towards the bottom for $-n$). To do so, pass 4th parametr:
```
Math.qfZeros(a,b,c,y)
``````
const a = -2;
const b = 3;
const c = 4;Math.qfZeros(a,b,c)
// [-0.851, 2.351]Math.qfZeros(a,b,c,4)
// [0, 1.5]Math.qfZeros(a,b,c,-4)
// [-1.386, 2.886]
```