public class PolynomialFunction extends Object implements UnivariateDifferentiableFunction, PolynomialFunctionInterface
Horner's Method is used to evaluate the function.
| Modifier and Type | Class and Description |
|---|---|
static class |
PolynomialFunction.Parametric
Dedicated parametric polynomial class.
|
| Constructor and Description |
|---|
PolynomialFunction(double[] c)
Construct a polynomial with the given coefficients.
|
| Modifier and Type | Method and Description |
|---|---|
PolynomialFunction |
add(PolynomialFunction p)
Add a polynomial to the instance.
|
PolynomialFunction |
derivative()
Returns the derivative as a
PolynomialFunction. |
protected static double[] |
differentiate(double[] coefficients)
Returns the coefficients of the derivative of the polynomial with the given coefficients.
|
boolean |
equals(Object obj) |
protected static double |
evaluate(double[] coefficients,
double argument)
Uses Horner's Method to evaluate the polynomial with the given coefficients at
the argument.
|
double[] |
getCoefficients()
Returns a copy of the coefficients array.
|
int |
getDegree()
Returns the degree of the polynomial.
|
PolynomialType |
getPolynomialType()
Return the type of this polynomial function.
|
int |
hashCode() |
PolynomialFunction |
multiply(PolynomialFunction p)
Multiply the instance by a polynomial.
|
PolynomialFunction |
negate()
Negate the instance.
|
PolynomialFunction |
primitive(double x0,
double y0)
Returns the primitive polynomial.
|
PolynomialFunction |
subtract(PolynomialFunction p)
Subtract a polynomial from the instance.
|
String |
toString()
Returns a string representation of the polynomial.
|
UnivariateFunction |
univariateDerivative()
Returns the derivative as a
UnivariateFunction. |
DerivativeStructure |
value(DerivativeStructure t)
Simple mathematical function.
|
double |
value(double x)
Compute the value of the function for the given argument.
|
public PolynomialFunction(double[] c)
The constructor makes a copy of the input array and assigns the copy to the coefficients property.
c - Polynomial coefficients.NullArgumentException - if c is null.NoDataException - if c is empty.public double value(double x)
The value returned is
coefficients[n] * x^n + ... + coefficients[1] * x + coefficients[0]
value in interface UnivariateFunctionx - Argument for which the function value should be computed.UnivariateFunction.value(double)public int getDegree()
getDegree in interface PolynomialFunctionInterfacepublic double[] getCoefficients()
Changes made to the returned copy will not affect the coefficients of the polynomial.
getCoefficients in interface PolynomialFunctionInterfaceprotected static double evaluate(double[] coefficients,
double argument)
coefficients - Coefficients of the polynomial to evaluate.argument - Input value.NoDataException - if coefficients is empty.NullArgumentException - if coefficients is null.public DerivativeStructure value(DerivativeStructure t)
UnivariateDifferentiableFunction classes compute both the value and the first derivative of the function.
value in interface UnivariateDifferentiableFunctiont - function input valueNoDataException - if coefficients is empty.NullArgumentException - if coefficients is null.public PolynomialFunction add(PolynomialFunction p)
p - Polynomial to add.p.public PolynomialFunction subtract(PolynomialFunction p)
p - Polynomial to subtract.p.public PolynomialFunction negate()
public PolynomialFunction multiply(PolynomialFunction p)
p - Polynomial to multiply by.protected static double[] differentiate(double[] coefficients)
coefficients - Coefficients of the polynomial to differentiate.null if coefficients has length 1.NoDataException - if coefficients is empty.NullArgumentException - if coefficients is null.public PolynomialFunction derivative()
PolynomialFunction.derivative in interface PolynomialFunctionInterfacepublic UnivariateFunction univariateDerivative()
UnivariateFunction.public PolynomialFunction primitive(double x0, double y0)
primitive in interface PolynomialFunctionInterfacex0 - the absicssa at which the polynomial value is knowny0 - the value of the polynomial at x0public String toString()
The representation is user oriented. Terms are displayed lowest degrees first. The
multiplications signs, coefficients equals to one and null terms are not displayed (except if
the polynomial is 0, in which case the 0 constant term is displayed). Addition of terms with
negative coefficients are replaced by subtraction of terms with positive coefficients except
for the first displayed term (i.e. we display -3 for a constant negative
polynomial, but 1 - 3 x + x^2 if the negative coefficient is not the first one
displayed).
public PolynomialType getPolynomialType()
getPolynomialType in interface PolynomialFunctionInterfaceCopyright © 2024 CNES. All rights reserved.