org.ddogleg.solver
Class PolynomialSolver
- java.lang.Object
-
- org.ddogleg.solver.PolynomialSolver
-
public class PolynomialSolver extends java.lang.ObjectProvides functions for finding the roots of polynomials
-
-
Constructor Summary
Constructors Constructor and Description PolynomialSolver()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static PolynomialRootscreateRootFinder(RootFinderType type, int maxDegree)Creates a generic polynomial root finding class which will return all real or all real and complex roots depending on the algorithm selected.static doublecubicDiscriminant(double a, double b, double c, double d)The cubic discriminant is used to determine the type of roots.static doublecubicRootReal(double a, double b, double c, double d)A cubic polynomial of the form "f(x) = a + b*x + c*x2 + d*x3" has three roots.static org.ejml.data.Complex64F[]polynomialRootsEVD(double... coefficients)Finds real and imaginary roots in a polynomial using the companion matrix and Eigenvalue decomposition.
-
-
-
Method Detail
-
createRootFinder
public static PolynomialRoots createRootFinder(RootFinderType type, int maxDegree)
Creates a generic polynomial root finding class which will return all real or all real and complex roots depending on the algorithm selected.- Parameters:
type- Which algorithm is to be returned.maxDegree- Maximum degree of the polynomial being considered.- Returns:
- Root finding algorithm.
-
polynomialRootsEVD
public static org.ejml.data.Complex64F[] polynomialRootsEVD(double... coefficients)
Finds real and imaginary roots in a polynomial using the companion matrix and Eigenvalue decomposition. The coefficients order is specified from smallest to largest. Example, 5 + 6*x + 7*x^2 + 8*x^3 = [5,6,7,8]- Parameters:
coefficients- Polynomial coefficients from smallest to largest.- Returns:
- The found roots.
-
cubicRootReal
public static double cubicRootReal(double a, double b, double c, double d)A cubic polynomial of the form "f(x) = a + b*x + c*x2 + d*x3" has three roots. These roots will either be all real or one real and two imaginary. This function will return a root which is always real.
WARNING: Not as numerically stable as
polynomialRootsEVD(double...), but still fairly stable.- Parameters:
a- polynomial coefficient.b- polynomial coefficient.c- polynomial coefficient.d- polynomial coefficient.- Returns:
- A real root of the cubic polynomial
-
cubicDiscriminant
public static double cubicDiscriminant(double a, double b, double c, double d)The cubic discriminant is used to determine the type of roots.
- if d
>0, then three distinct real roots - if d = 0, then it has a multiple root and all will be real
- if d
<0, then one real and two non-real complex conjugate roots
From http://en.wikipedia.org/wiki/Cubic_function November 17, 2011
- Parameters:
a- polynomial coefficient.b- polynomial coefficient.c- polynomial coefficient.d- polynomial coefficient.- Returns:
- Cubic discriminant
- if d
-
-
DataMelt 3.0 © DataMelt by jWork.ORG