public class PolynomialUtils extends Object
In this module, polynomial coefficients are stored in arrays ordered in descending powers.
When an awway a[] contains the coefficients, the polynomial has the following form:
a[0] * x^n + a[1] * x^(n-1) + ... a[n-1] * x + a[n]
| Modifier and Type | Class and Description |
|---|---|
static class |
PolynomialUtils.RationalFraction
Structure for the coefficients of a rational fraction (a fraction of two polynomials) with real coefficients.
|
| Modifier and Type | Method and Description |
|---|---|
static Complex[] |
deflate(Complex[] a,
Complex z,
double eps)
Forward deflation of a polynomial with a known zero.
|
static Complex |
evaluate(double[] a,
Complex x)
Computes the value of a polynomial with real coefficients.
|
static Complex |
evaluate(PolynomialUtils.RationalFraction f,
Complex x)
Computes the value of a rational fraction.
|
static Complex[] |
expand(Complex[] zeros)
Computes the coefficients of a polynomial from it's complex zeros.
|
static Complex[] |
multiply(Complex[] a1,
Complex[] a2)
Multiplies two polynomials with complex coefficients.
|
static double[] |
multiply(double[] a1,
double[] a2)
Multiplies two polynomials with real coefficients.
|
public static Complex evaluate(double[] a, Complex x)
a - The coefficients of the polynomial, ordered in descending powers.x - The x value for which the polynomial is to be evaluated.public static Complex evaluate(PolynomialUtils.RationalFraction f, Complex x)
evaluate(f.top, x) / evaluate(f.bottom, x).public static double[] multiply(double[] a1,
double[] a2)
public static Complex[] multiply(Complex[] a1, Complex[] a2)
public static Complex[] deflate(Complex[] a, Complex z, double eps)
a[] by (x - z),
where z is a zero of the polynomial.a - Coefficients of the polynomial.z - A known zero of the polynomialeps - The maximum value allowed for the absolute real and imaginary parts of the remainder, or 0 to ignore the reminder.public static Complex[] expand(Complex[] zeros)
zeros - The zeros of the polynomial.
The polynomial formula is:
(x - zero[0]) * (x - zero[1]) * ... (x - zero[n - 1])