JSci.maths.polynomials
Class PolynomialMath

java.lang.Object
  extended by JSci.maths.AbstractMath
      extended by JSci.maths.polynomials.PolynomialMath

public final class PolynomialMath
extends AbstractMath


Method Summary
static Complex evalPolynomial(ComplexPolynomial p, Complex t)
          Evaluates a polynomial by Horner's scheme.
static double evalPolynomial(RealPolynomial p, double t)
          Evaluates a polynomial by Horner's scheme.
static Complex[] findRoots(RealPolynomial p)
          Calculates the roots of a given polynomial by solving the eigenvalue problem for the companion matrix.
static ComplexPolynomial interpolateLagrange(Complex[][] samplingPoints)
          Interpolates a polynomial.
static RealPolynomial interpolateLagrange(double[][] samplingPoints)
          Interpolates a polynomial.
static int maxDegree(Polynomial p1, Polynomial p2)
          Get the maximum degree of two polynomials
static int minDegree(Polynomial p1, Polynomial p2)
          Get the minimal degree of two polynomials
static ComplexPolynomial normalize(ComplexPolynomial p)
          Normalizes a given complex polynomial, i.e.
static RealPolynomial normalize(RealPolynomial p)
          Normalizes a given real polynomial, i.e.
static AbstractComplexSquareMatrix toCompanionMatrix(ComplexPolynomial p)
           
static AbstractDoubleSquareMatrix toCompanionMatrix(RealPolynomial p)
          Returns the companion matrix of a given polynomial.
static ComplexPolynomial toComplex(Polynomial p)
          Try to cast a Polynomial to a complex polynomial
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

toCompanionMatrix

public static AbstractDoubleSquareMatrix toCompanionMatrix(RealPolynomial p)
Returns the companion matrix of a given polynomial. The eigenvalues of the companion matrix are the roots of the polynomial.

Parameters:
p - the polynomial
Returns:
the companion matrix
PlanetMath references:
CompanionMatrix

toCompanionMatrix

public static AbstractComplexSquareMatrix toCompanionMatrix(ComplexPolynomial p)

findRoots

public static Complex[] findRoots(RealPolynomial p)
Calculates the roots of a given polynomial by solving the eigenvalue problem for the companion matrix. This is not yet implemented (depends on a QR- decomposition)

Parameters:
p - the polynomial
Returns:
(unordered) list of roots.

maxDegree

public static int maxDegree(Polynomial p1,
                            Polynomial p2)
Get the maximum degree of two polynomials

Parameters:
p1 -
p2 -

minDegree

public static int minDegree(Polynomial p1,
                            Polynomial p2)
Get the minimal degree of two polynomials

Parameters:
p1 -
p2 -

evalPolynomial

public static double evalPolynomial(RealPolynomial p,
                                    double t)
Evaluates a polynomial by Horner's scheme.

Parameters:
p -
t -

evalPolynomial

public static Complex evalPolynomial(ComplexPolynomial p,
                                     Complex t)
Evaluates a polynomial by Horner's scheme.

Parameters:
p -
t -

interpolateLagrange

public static RealPolynomial interpolateLagrange(double[][] samplingPoints)
Interpolates a polynomial. Caveat: this method is brute-force, slow and not very stable. It shouldn't be used for more than approx. 10 points. Remember the strong variations of higher degree polynomials.

Parameters:
samplingPoints - an array[2][n] where array[0] denotes x-values, array[1] y-values

interpolateLagrange

public static ComplexPolynomial interpolateLagrange(Complex[][] samplingPoints)
Interpolates a polynomial. Caveat: this method is brute-force, slow and not very stable. It shouldn't be used for more than approx. 10 points. Remember the strong variations of higher degree polynomials.

Parameters:
samplingPoints - an array[2][n] where array[0] denotes x-values, array[1] y-values

normalize

public static RealPolynomial normalize(RealPolynomial p)
Normalizes a given real polynomial, i.e. divide by the leading coefficient.

Parameters:
p -

normalize

public static ComplexPolynomial normalize(ComplexPolynomial p)
Normalizes a given complex polynomial, i.e. divide by the leading coefficient.

Parameters:
p -

toComplex

public static ComplexPolynomial toComplex(Polynomial p)
Try to cast a Polynomial to a complex polynomial