Simbody  3.6
SimTK::PolynomialRootFinder Class Reference

This class provides static methods for finding the roots of polynomials. More...

Classes

class  ZeroLeadingCoefficient
 This is an exception which is thrown by all of the PolynomialRootFinder::findRoots() methods. More...
 

Static Public Member Functions

template<class T >
static void findRoots (const Vec< 3, T > &coefficients, Vec< 2, complex< T > > &roots)
 Find the roots of a quadratic polynomial with real coefficients. More...
 
template<class T >
static void findRoots (const Vec< 3, complex< T > > &coefficients, Vec< 2, complex< T > > &roots)
 Find the roots of a quadratic polynomial with complex coefficients. More...
 
template<class T >
static void findRoots (const Vec< 4, T > &coefficients, Vec< 3, complex< T > > &roots)
 Find the roots of a cubic polynomial with real coefficients. More...
 
template<class T >
static void findRoots (const Vec< 4, complex< T > > &coefficients, Vec< 3, complex< T > > &roots)
 Find the roots of a cubic polynomial with complex coefficients. More...
 
template<class T >
static void findRoots (const Vector_< T > &coefficients, Vector_< complex< T > > &roots)
 Find the roots of a polynomial of arbitrary degree with real coefficients. More...
 
template<class T >
static void findRoots (const Vector_< complex< T > > &coefficients, Vector_< complex< T > > &roots)
 Find the roots of a polynomial of arbitrary degree with complex coefficients. More...
 

Detailed Description

This class provides static methods for finding the roots of polynomials.

There are specialized methods for quadratic and cubic polynomials, as well as general methods for polynomials of arbitrary degree. In each case, there are methods for polynomials with both real and complex coefficients.

There are two different algorithms used by this class. The specialized methods for quadratic polynomials calculate the roots by explicit evaluation of the quadratic formula. They use the evaluation method described in section 5.6 of "Numerical Recipes in C++, Second Edition", by Press, Teukolsky, Vetterling, and Flannery. In addition, the method for quadratic polynomials with real coefficients performs an extra check to detect when the discriminant is zero to within machine precision. This helps to prevent round-off error from producing a tiny imaginary part in a multiple root.

The methods for cubic and arbitrary degree polynomials use the Jenkins-Traub method, as implemented in the classic RPOLY and CPOLY functions:

Jenkins, M. A. and Traub, J. F. (1972), Algorithm 419: Zeros of a Complex Polynomial, Comm. ACM, 15, 97-99.

Jenkins, M. A. (1975), Algorithm 493: Zeros of a Real Polynomial, ACM TOMS, 1, 178-189.

This is an iterative method that provides rapid convergence and high accuracy in most cases.

Member Function Documentation

◆ findRoots() [1/6]

template<class T >
static void SimTK::PolynomialRootFinder::findRoots ( const Vec< 3, T > &  coefficients,
Vec< 2, complex< T > > &  roots 
)
static

Find the roots of a quadratic polynomial with real coefficients.

Parameters
coefficientsThe polynomial coefficients in order of decreasing powers
rootsOn exit, the roots of the polynomial are stored in this

◆ findRoots() [2/6]

template<class T >
static void SimTK::PolynomialRootFinder::findRoots ( const Vec< 3, complex< T > > &  coefficients,
Vec< 2, complex< T > > &  roots 
)
static

Find the roots of a quadratic polynomial with complex coefficients.

Parameters
coefficientsThe polynomial coefficients in order of decreasing powers
rootsOn exit, the roots of the polynomial are stored in this

◆ findRoots() [3/6]

template<class T >
static void SimTK::PolynomialRootFinder::findRoots ( const Vec< 4, T > &  coefficients,
Vec< 3, complex< T > > &  roots 
)
static

Find the roots of a cubic polynomial with real coefficients.

Parameters
coefficientsThe polynomial coefficients in order of decreasing powers
rootsOn exit, the roots of the polynomial are stored in this

◆ findRoots() [4/6]

template<class T >
static void SimTK::PolynomialRootFinder::findRoots ( const Vec< 4, complex< T > > &  coefficients,
Vec< 3, complex< T > > &  roots 
)
static

Find the roots of a cubic polynomial with complex coefficients.

Parameters
coefficientsThe polynomial coefficients in order of decreasing powers
rootsOn exit, the roots of the polynomial are stored in this

◆ findRoots() [5/6]

template<class T >
static void SimTK::PolynomialRootFinder::findRoots ( const Vector_< T > &  coefficients,
Vector_< complex< T > > &  roots 
)
static

Find the roots of a polynomial of arbitrary degree with real coefficients.

Parameters
coefficientsThe polynomial coefficients in order of decreasing powers
rootsOn exit, the roots of the polynomial are stored in this

◆ findRoots() [6/6]

template<class T >
static void SimTK::PolynomialRootFinder::findRoots ( const Vector_< complex< T > > &  coefficients,
Vector_< complex< T > > &  roots 
)
static

Find the roots of a polynomial of arbitrary degree with complex coefficients.

Parameters
coefficientsThe polynomial coefficients in order of decreasing powers
rootsOn exit, the roots of the polynomial are stored in this

The documentation for this class was generated from the following file: