All Projects → ZhepeiWang → Root-Finder

ZhepeiWang / Root-Finder

Licence: MIT license
Root-Finder is a header-only univariate polynomial solver, which finds/counts all real roots of any polynomial within any interval.

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to Root-Finder

wp-config
Bedrock's failsafe wp-config
Stars: ✭ 45 (+50%)
Mutual labels:  roots
multinomials
Multinomials for the Mathematical Components library.
Stars: ✭ 12 (-60%)
Mutual labels:  polynomials
numerics
library of numerical methods using Armadillo
Stars: ✭ 17 (-43.33%)
Mutual labels:  root-finding
built-with-roots
Demo of a fan site of WordPress sites built with Roots, which is also built with Roots
Stars: ✭ 19 (-36.67%)
Mutual labels:  roots
SumOfSquares.jl
Sum of Squares Programming for Julia
Stars: ✭ 96 (+220%)
Mutual labels:  polynomials
numerical-veliz
Numerical Analysis code from the Oscar Veliz YouTube Channel
Stars: ✭ 83 (+176.67%)
Mutual labels:  root-finding
wp-smtp
Simple package for handling WordPress SMTP with .env when using the Roots stack.
Stars: ✭ 31 (+3.33%)
Mutual labels:  roots
Abacus
Advanced Combinatorics and Algebraic Number Theory Symbolic Computation library for JavaScript, Python
Stars: ✭ 16 (-46.67%)
Mutual labels:  polynomials
givaro
Givaro - C++ library for arithmetic and algebraic computations
Stars: ✭ 41 (+36.67%)
Mutual labels:  polynomials
equadratures
equadratures.org/
Stars: ✭ 92 (+206.67%)
Mutual labels:  polynomials
gardener
Lazy configuration of Roots stack (Trellis/Bedrock/Sage/Soil) based on command-line prompts.
Stars: ✭ 27 (-10%)
Mutual labels:  roots
PolyJuMP.jl
A JuMP extension for Polynomial Optimization
Stars: ✭ 36 (+20%)
Mutual labels:  polynomials
Fatou.jl
Fatou sets in Julia (Fractals, Newton basins, Mandelbrot)
Stars: ✭ 92 (+206.67%)
Mutual labels:  root-finding
wp-docker-bedrock
[UNSUPPORTED] Roots Bedrock for WordPress running on Docker.
Stars: ✭ 50 (+66.67%)
Mutual labels:  roots
SphericalHarmonicExpansions.jl
A Julia package to handle spherical harmonic functions
Stars: ✭ 22 (-26.67%)
Mutual labels:  polynomials
trellis-cli
A CLI to manage Trellis projects
Stars: ✭ 141 (+370%)
Mutual labels:  roots
cmna-pkg
Computational Methods for Numerical Analysis
Stars: ✭ 13 (-56.67%)
Mutual labels:  root-finding
tenda-reverse
Reverse engineering, getting root access to Tenda MW6 wifi mesh router
Stars: ✭ 90 (+200%)
Mutual labels:  root-finding
NAGPythonExamples
Examples and demos showing how to call functions from the NAG Library for Python
Stars: ✭ 46 (+53.33%)
Mutual labels:  root-finding
ddeabm
Modern Fortran implementation of the DDEABM Adams-Bashforth algorithm
Stars: ✭ 23 (-23.33%)
Mutual labels:  root-finding

Root-Finder

Root-Finder is a header-only univariate polynomial solver, which finds/counts all REAL roots of any polynomial inside a given interval. (Please use the up-to-date master branch.)

Feature

  1. The solver is a C++11 header-only library, which is highly optimized on the premise of instruction set independence.

  2. It only contains one header file "root_finder.hpp".

  3. The interface only contains two functions. One is for roots finding while the other one is for roots counting.

  4. As for low order polynomials (linear, quadratic, cubic, and quartic polynomials), the solver calculates their closed-form solutions. In this case, the solver only takes less than 0.25 microsecond for Intel i7-8700 CPU.

  5. As for high order polynomials (order >= 5), the solver implements 2 different methods to find all roots. The recommended one is Real Roots Isolation Method. The other one is based on Companion Matrix Method.

  6. The Real Roots Isolation Method uses geometrical properties of polynomial roots to tighten a given interval. Both Cauchy’s bound as well as Kojima’s bound are adopted. Normally, the latter can be tighter than the former for several magnitude in most cases. Technically, Fujiwara’s bound is always better than Kojima's bound, while Kojima's bound is more numerically friendly and is tight enough.

  7. The Real Roots Isolation Method is much faster and much more stable than the Companion Matrix Method. However, due to truncation error of float point number, the former is recommended for at most 32-order polynomials, while the latter is only recommended for at most 20-order polynomials.

  8. We perform benchmark example between our Real Roots Isolation Method and TOMS493: Jenkins–Traub Algorithm on two different platforms. The latter one is commonly known as the "RPOLY" algorithm. In the benchmark, all roots of a polynomial are required. For 8-order polynomials, our method is about 5% faster than RPOLY under Intel i7-8700 CPU. In general, our library outperforms the RPOLY algorithm even when all real roots are needed. Moreover, RPOLY is designed to find all roots of a polynomial while ours can handle any given interval. Therefore, when roots in an interval are required, our method performs far better.

  9. The library is also capable of efficiently counting the number of roots inside an interval, of which RPOLY is incapable. For 8-order polynomials, our roots counter only takes about 0.2 microsecond under Intel i7-8700 CPU and 0.8 microsecond under Intel i5-5200U CPU. The time consumption for high order polynomial is extremely low as those low order polynomials which have closed-form solutions.

  10. Only algorithmic acceleration is explicitly implemented in the code. Furthur instruction-dependent optimization can be done to get better performance.

Interface

Only two functions below are needed.

Roots Finding Function:

std::set<double> RootFinder::solvePolynomial(const Eigen::VectorXd &coeffs, double lbound, double ubound, double tol, bool isolation = true)

Inputs:

coeffs: 
    Eigen VectorXd for coefficients of a polynomial. For example, the polynomial a(n)*x^n+a(n-1)*x^(n-1)+...+a(1)*x+a(0) can be expressed by 
    coeffs=[a(n), a(n-1), ..., a(1), a(0)].

lbound and ubound:
    Open interval (lbound, ubound). If lbound = -INFINITY and ubound = INFINITY, then all real roots can be found by the solver. Note that polynomial cannot be zero at these two boundaries.

tol:
    tolerance for precision, only works when order is higher than 4.

isolation:
    switch for Method used. Default one is Real Roots Isolation Method.

Outputs:

std::set<double> which stores all searched real roots.

Example:

Eigen::VectorXd coeffs(6);
coeffs << 1.0, -2.0, 3.0, -4.0, 5.0, -6.0;
std::set<double> allRoots = RootFinder::solvePolynomial(coeffs, -100.0, 100.0, 0.00001);

Roots Counting Function:

int RootFinder::countRoots(const Eigen::VectorXd &coeffs, double lbound, double ubound)

Inputs:

coeffs: 
    Eigen VectorXd for coefficients of a polynomial. For example, the polynomial a(n)*x^n+a(n-1)*x^(n-1)+...+a(1)*x+a(0) can be expressed by 
    coeffs=[a(n), a(n-1), ..., a(1), a(0)].

lbound and ubound:
    Open interval (lbound, ubound). Note that polynomial cannot be zero at these two boundaries.

Outputs:

The number of distinct roots inside (lbound, ubound).

Example:

Eigen::VectorXd coeffs(6);
coeffs << 1.0, -2.0, 3.0, -4.0, 5.0, -6.0;
int numRoots = RootFinder::countRoots(coeffs, -10, 0.5);

Compile

sudo apt install libeigen3-dev
mkdir build
cd build
cmake ..
make

Note

The "RPOLY" algorithm which we benchmarks againt comes from a modified version by Helen Oleynikova, which originates in http://www.netlib.org/toms/.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].