README
The focus is to find real roots of real coefficient polynomials from degree 1 up to about degree 20 as accurately and as fast as possible, e.g.
However, the above function, allRoots
, does not take error bounds into account and
can thus be inaccurate if the roots have high condition numbers.
For extremely accurate (no matter how high the condition number) certified results use e.g.:
or for a more flexible function that takes the input polynomial coefficients
as double-double precision and the ability to specify error bounds on the coefficients
in addition to a fallback function to specify exact coefficients
(in the form of Shewchuk expansions)
use allRootsCertified
.
Though the focus is on root finding, the library include numerous useful operators
on polynomials with double
, double-double
, Shewchuk expansion
and bigint
coefficients, e.g
Why only up to about degree 20?
This isn't a hard limit. Roughly speaking, since the roots are found
using Rolle's Theorem
it becomes asymptotically slower (compared to Descartes Methods), i.e.
roughly O(n²)
vs O(n)
the higher the polynomial degree, n
.
Another reason is that evaluation of the polynomial at x
when |x| >> 1
can result in
overflow when the result is larger than about 1.8 x 10^308
(the max value a double precision floating point value can be).
Documentation
For more in-depth documentation please read the docs!.
Installation
In TypeScript or Node simply import whatever you need, e.g.:
or if you prefer using a script and global var in the browser (not recommended):
and then use the global named FloPoly