Class PolynomialRoot


  • public final class PolynomialRoot
    extends java.lang.Object
    Find roots of polynomials.

    Stand-alone utility functions.

    TODO: Need a unit test for this class.

    Since:
    Ptolemy II 11.0
    Version:
    $id$
    Author:
    David M. Lorenzetti, Contributor: Thierry S. Nouidui
    Pt.AcceptedRating:
    red (reviewmoderator) // FIXME: Fill in.
    Pt.ProposedRating:
    red (dmlorenzetti)
    • Constructor Summary

      Constructors 
      Constructor Description
      PolynomialRoot()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double findMinimumPositiveRoot2​(double qea, double qeb, double qec)
      Find the smallest positive real root of a second-order (quadratic) equation.
      static double findMinimumPositiveRoot3​(double cea, double ceb, double cec, double ced, double absTol, double relTol)
      Find the smallest positive real root of a third-order (cubic) equation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PolynomialRoot

        public PolynomialRoot()
    • Method Detail

      • findMinimumPositiveRoot2

        public static final double findMinimumPositiveRoot2​(double qea,
                                                            double qeb,
                                                            double qec)
        Find the smallest positive real root of a second-order (quadratic) equation.

        Equation is a*x^2 + b*x + c = 0.

        Parameters:
        qea - Coefficient `a`.
        qeb - Coefficient `b`.
        qec - Coefficient `c`.
        Returns:
        The smallest positive real root. Return `Double.POSITIVE_INFINITY` if no root. Return 0 if only nonpositive roots.
      • findMinimumPositiveRoot3

        public static final double findMinimumPositiveRoot3​(double cea,
                                                            double ceb,
                                                            double cec,
                                                            double ced,
                                                            double absTol,
                                                            double relTol)
        Find the smallest positive real root of a third-order (cubic) equation.

        Equation is a*x^3 + b*x^2 + c*x + d = 0.

        TODO: Switch from bracketing solution, to one based on algebraic solution to cubic equation. Expect to have to tune up the roots it gives, using NR, just to account for numerical issues. But still may be more direct, maybe faster.

        Parameters:
        cea - Coefficient `a`.
        ceb - Coefficient `b`.
        cec - Coefficient `c`.
        ced - Coefficient `d`.
        absTol - The size of residual at which end search.
        relTol - The fractional difference in bracket on x, at which end search.
        Returns:
        The smallest positive real root. Return `Double.POSITIVE_INFINITY` if no root. Return 0 if only nonpositive roots.