Class PolynomialOps


public class PolynomialOps extends Object
  • Constructor Details

    • PolynomialOps

      public PolynomialOps()
  • Method Details

    • quadraticVertex

      public static double quadraticVertex(double a, double b)
      Given the coefficients compute the vertex (minimum/maximum) of the quadratic. y = a*x2 + b*x + c
      a - quadratic coefficient.
      b - quadratic coefficient.
      The quadratic's vertex.
    • derivative

      public static Polynomial derivative(Polynomial poly, @Nullable @Nullable Polynomial deriv)
    • refineRoot

      public static double refineRoot(Polynomial poly, double root, int maxIterations)
    • divide

      public static void divide(Polynomial numerator, Polynomial denominator, Polynomial quotient, Polynomial remainder)

      Polynomial division. Computes both the quotient and the remainder.

      quotient = numerator/denominator
      remainder = numerator % denominator

      numerator - Numerator in the division. Not modified.
      denominator - Denominator in the division. Not modified.
      quotient - Output quotient, Modified.
      remainder - Output remainder. Modified.
    • multiply

      public static Polynomial multiply(Polynomial a, Polynomial b, @Nullable @Nullable Polynomial result)
      Multiplies the two polynomials together.
      a - Polynomial
      b - Polynomial
      result - Optional storage parameter for the results. Must be have enough coefficients to store the results. If null a new instance is declared.
      Results of the multiplication
    • add

      public static Polynomial add(Polynomial a, Polynomial b, @Nullable @Nullable Polynomial results)
      Adds two polynomials together. The lengths of the polynomials do not need to be the zero, but the 'missing' coefficients are assumed to be zero.
      a - Polynomial
      b - Polynomial
      results - Optional storage for resulting polynomial. If null a new instance is declared. If not null its length must be the same as the largest polynomial 'a' or 'b'.
      Polynomial 'a' and 'b' added together.
    • countRealRoots

      public static int countRealRoots(Polynomial poly)
    • createRootFinder

      public static PolynomialRoots createRootFinder(int maxCoefficients, RootFinderType which)
      Creates different polynomial root finders.
      maxCoefficients - The maximum number of coefficients that will be processed. This is the order + 1
      which - 0 = Sturm and 1 = companion matrix.
    • cubicRealRoot

      public static double cubicRealRoot(double c0, double c1, double c2, double c3)
      Returns a real root to the cubic polynomial: 0 = c0 + c1*x + c2*x^2 + c3*c^3. There can be other real roots. WARNING: This technique is much less stable than using one of the RootFinder algorithms
      c0 - Polynomial coefficient for power 0
      c1 - Polynomial coefficient for power 1
      c2 - Polynomial coefficient for power 2
      c3 - Polynomial coefficient for power 3
      A real root of the polynomial