Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Namespaces | Data Structures | Functions | Variables
MathPoly Namespace Reference

Polynomial root finding algorithms. More...

Namespaces

namespace  detail
 

Data Structures

struct  GeneralPolyResult
 Result for general polynomial solver. More...
 

Functions

MathUtils::PolyResult Linear (double theA, double theB)
 Solve linear equation: a*x + b = 0 Handles degenerate cases (a = 0).
 
MathUtils::PolyResult Quadratic (double theA, double theB, double theC)
 Solve quadratic equation: a*x^2 + b*x + c = 0 Uses numerically stable formulas to avoid catastrophic cancellation.
 
MathUtils::PolyResult Cubic (double theA, double theB, double theC, double theD)
 Solve cubic equation: a*x^3 + b*x^2 + c*x + d = 0 Uses Cardano's method with Vieta substitution and trigonometric solution.
 
MathUtils::PolyResult Quartic (double theA, double theB, double theC, double theD, double theE)
 Solve quartic equation: a*x^4 + b*x^3 + c*x^2 + d*x + e = 0 Uses Ferrari's method with modern numerical enhancements.
 
GeneralPolyResult Laguerre (const double *theCoeffs, int theDegree, double theTol=1.0e-12)
 Solve polynomial equation using Laguerre's method with deflation. Works for any degree up to THE_MAX_POLY_DEGREE.
 
GeneralPolyResult LaguerreN (const double *theCoeffs, size_t theSize, double theTol=1.0e-12)
 Convenience function: solve polynomial given as array with specified size.
 
MathUtils::PolyResult Sextic (double theA, double theB, double theC, double theD, double theE, double theF, double theG)
 Solve sextic (degree 6) polynomial: a*x^6 + b*x^5 + c*x^4 + d*x^3 + e*x^2 + f*x + g = 0.
 
MathUtils::PolyResult Quintic (double theA, double theB, double theC, double theD, double theE, double theF)
 Solve quintic (degree 5) polynomial: a*x^5 + b*x^4 + c*x^3 + d*x^2 + e*x + f = 0.
 
GeneralPolyResult Octic (const double theCoeffs[9])
 Solve octic (degree 8) polynomial using Laguerre's method. Useful for Circle-Ellipse extrema after Weierstrass substitution.
 

Variables

constexpr int THE_MAX_POLY_DEGREE = 20
 Maximum polynomial degree supported by Laguerre solver.
 

Detailed Description

Polynomial root finding algorithms.

Polynomial root finding algorithms using Laguerre's method.

Function Documentation

◆ Cubic()

MathUtils::PolyResult MathPoly::Cubic ( double theA,
double theB,
double theC,
double theD )
inline

Solve cubic equation: a*x^3 + b*x^2 + c*x + d = 0 Uses Cardano's method with Vieta substitution and trigonometric solution.

Algorithm:

  1. Handle lower degree cases (a = 0 -> quadratic)
  2. Transform to depressed cubic: t^3 + pt + q = 0 via x = t - b/(3a)
  3. Compute discriminant Delta = q^2/4 + p^3/27
  4. For Delta > 0: one real root (Cardano's formula)
  5. For Delta < 0: three real roots (trigonometric method)
  6. For Delta = 0: multiple roots
  7. Apply Newton-Raphson refinement
Parameters
theAcoefficient of x^3
theBcoefficient of x^2
theCcoefficient of x
theDconstant term
Returns
result containing 1, 2, or 3 real roots (sorted in ascending order)

◆ Laguerre()

GeneralPolyResult MathPoly::Laguerre ( const double * theCoeffs,
int theDegree,
double theTol = 1.0e-12 )
inline

Solve polynomial equation using Laguerre's method with deflation. Works for any degree up to THE_MAX_POLY_DEGREE.

Algorithm:

  1. Use Laguerre iteration to find one root (complex)
  2. If root is nearly real, treat it as real and deflate
  3. If root is complex, deflate by quadratic factor (conjugate pair)
  4. Repeat until all roots found
  5. Refine real roots using Newton on original polynomial
Parameters
theCoeffscoefficients array [a0, a1, a2, ..., an] for a0 + a1*x + ... + an*x^n
theDegreepolynomial degree
theToltolerance for convergence and real/complex discrimination
Returns
GeneralPolyResult containing real and complex roots

◆ LaguerreN()

GeneralPolyResult MathPoly::LaguerreN ( const double * theCoeffs,
size_t theSize,
double theTol = 1.0e-12 )
inline

Convenience function: solve polynomial given as array with specified size.

Parameters
theCoeffscoefficients [a0, a1, ..., an]
theSizesize of coefficient array (degree + 1)
theToltolerance
Returns
GeneralPolyResult

◆ Linear()

Solve linear equation: a*x + b = 0 Handles degenerate cases (a = 0).

Parameters
theAcoefficient of x
theBconstant term
Returns
result containing 0 or 1 root, or infinite solutions flag

◆ Octic()

GeneralPolyResult MathPoly::Octic ( const double theCoeffs[9])
inline

Solve octic (degree 8) polynomial using Laguerre's method. Useful for Circle-Ellipse extrema after Weierstrass substitution.

Parameters
theCoeffscoefficients [a0, a1, ..., a8] where polynomial is a0 + a1*x + ... + a8*x^8
Returns
GeneralPolyResult containing all real roots

◆ Quadratic()

MathUtils::PolyResult MathPoly::Quadratic ( double theA,
double theB,
double theC )
inline

Solve quadratic equation: a*x^2 + b*x + c = 0 Uses numerically stable formulas to avoid catastrophic cancellation.

Algorithm:

  1. Handle linear case when a = 0
  2. Compute discriminant D = b^2 - 4ac
  3. For D < 0: no real roots
  4. For D = 0: one double root
  5. For D > 0: two roots using stable formula
Parameters
theAcoefficient of x^2
theBcoefficient of x
theCconstant term
Returns
result containing 0, 1, or 2 real roots (sorted in ascending order)

◆ Quartic()

MathUtils::PolyResult MathPoly::Quartic ( double theA,
double theB,
double theC,
double theD,
double theE )
inline

Solve quartic equation: a*x^4 + b*x^3 + c*x^2 + d*x + e = 0 Uses Ferrari's method with modern numerical enhancements.

Algorithm:

  1. Handle lower degree cases (a = 0 -> cubic)
  2. Transform to depressed quartic: t^4 + pt^2 + qt + r = 0 via x = t - b/(4a)
  3. Solve Ferrari's resolvent cubic
  4. Factor quartic into two quadratics
  5. Solve both quadratics
  6. Apply Newton-Raphson refinement
Parameters
theAcoefficient of x^4
theBcoefficient of x^3
theCcoefficient of x^2
theDcoefficient of x
theEconstant term
Returns
result containing 0, 1, 2, 3, or 4 real roots (sorted in ascending order)

◆ Quintic()

MathUtils::PolyResult MathPoly::Quintic ( double theA,
double theB,
double theC,
double theD,
double theE,
double theF )
inline

Solve quintic (degree 5) polynomial: a*x^5 + b*x^4 + c*x^3 + d*x^2 + e*x + f = 0.

Parameters
theAcoefficient of x^5
theBcoefficient of x^4
theCcoefficient of x^3
theDcoefficient of x^2
theEcoefficient of x
theFconstant term
Returns
PolyResult containing real roots only

◆ Sextic()

MathUtils::PolyResult MathPoly::Sextic ( double theA,
double theB,
double theC,
double theD,
double theE,
double theF,
double theG )
inline

Solve sextic (degree 6) polynomial: a*x^6 + b*x^5 + c*x^4 + d*x^3 + e*x^2 + f*x + g = 0.

Parameters
theAcoefficient of x^6
theBcoefficient of x^5
theCcoefficient of x^4
theDcoefficient of x^3
theEcoefficient of x^2
theFcoefficient of x
theGconstant term
Returns
PolyResult containing real roots only

Variable Documentation

◆ THE_MAX_POLY_DEGREE

constexpr int MathPoly::THE_MAX_POLY_DEGREE = 20
constexpr

Maximum polynomial degree supported by Laguerre solver.