Implementation of Kahan's polynomial root finders for polynomials up to degree 4.
npm install minimatrix-polyrootsThe notes can be found here: http://people.eecs.berkeley.edu/~wkahan/Math128/Cubic.pdf.
Kahan's cubic root finder is based on a quadratic root finder. In like fashion, the quartic root finder is based on Kahan's cubic root finder. The linear root finder is easy to calculate and is added for completeness.
The quadratic equation solved is Ax2 + Bx + C = 0.
The cubic equation solved is Ax3 + Bx2 + Cx + D = 0.
The quartic equation solved is Ax4 + Bx3 + Cx2 + Dx + E = 0.
- getLinearRoot(A, B)
- getQuadraticRoots(A, B, C)
- getCubicRoots(A, B, C, D)
- getQuarticRoots(A, B, C, D, E)
The roots returned are in an unsorted array. Since roots can be complex, they are given in a complex form:
````
[
{
real:
imag:
}
...
]