JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 759
  • Score
    100M100P100Q110480F
  • License MIT

Implementation of Kahan's polynomial root finders for polynomials up to degree 4.

Package Exports

  • minimatrix-polyroots

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (minimatrix-polyroots) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

minimatrix-polyroots

Implementation of Kahan's polynomial root finders for polynomials up to degree 4.

Motivation

According to Kahan, standard cubic root finders based on classical methods are prone to numerical inaccuracies. This is an implementation of a numerically stable method illustrated in Kahan's notes titled "To Solve a Real Cubic Equation".

The 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.

Usage

The linear equation solved is Ax + B = 0.

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: <number>,
    imag: <number>
  }
  ...
]

Author

Algorithm and pseudocode by William Kahan. Implementation in Javascript by Tim Bright.

License

(c) Tim Bright, 2017. MIT License.