public class PolynomialFunctionNewtonForm extends Object implements UnivariateDifferentiableFunction, FieldUnivariateFunction
The formula of polynomial in Newton form is p(x) = a[0] + a[1](x-c[0]) + a[2](x-c[0])(x-c[1]) + ... + a[n](x-c[0])(x-c[1])...(x-c[n-1]) Note that the length of a[] is one more than the length of c[]
Constructor and Description |
---|
PolynomialFunctionNewtonForm(double[] a,
double[] c)
Construct a Newton polynomial with the given a[] and c[].
|
Modifier and Type | Method and Description |
---|---|
protected void |
computeCoefficients()
Calculate the normal polynomial coefficients given the Newton form.
|
int |
degree()
Returns the degree of the polynomial.
|
static double |
evaluate(double[] a,
double[] c,
double z)
Evaluate the Newton polynomial using nested multiplication.
|
double[] |
getCenters()
Returns a copy of the centers array.
|
double[] |
getCoefficients()
Returns a copy of the coefficients array.
|
double[] |
getNewtonCoefficients()
Returns a copy of coefficients in Newton form formula.
|
double |
value(double z)
Calculate the function value at the given point.
|
<T extends Derivative<T>> |
value(T t)
Compute the value for the function.
|
<T extends CalculusFieldElement<T>> |
value(T t)
Compute the value of the function.
|
protected static void |
verifyInputArray(double[] a,
double[] c)
Verifies that the input arrays are valid.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toCalculusFieldUnivariateFunction
public PolynomialFunctionNewtonForm(double[] a, double[] c) throws MathIllegalArgumentException, NullArgumentException
The constructor makes copy of the input arrays and assigns them.
a
- Coefficients in Newton form formula.c
- Centers.NullArgumentException
- if any argument is null
.MathIllegalArgumentException
- if any array has zero length.MathIllegalArgumentException
- if the size difference between
a
and c
is not equal to 1.public double value(double z)
value
in interface UnivariateFunction
z
- Point at which the function value is to be computed.public <T extends Derivative<T>> T value(T t)
value
in interface UnivariateDifferentiableFunction
T
- the type of the field elementst
- the point for which the function value should be computedpublic <T extends CalculusFieldElement<T>> T value(T t)
value
in interface FieldUnivariateFunction
T
- the type of the field elementst
- Point at which the function value should be computed.public int degree()
public double[] getNewtonCoefficients()
Changes made to the returned copy will not affect the polynomial.
public double[] getCenters()
Changes made to the returned copy will not affect the polynomial.
public double[] getCoefficients()
Changes made to the returned copy will not affect the polynomial.
public static double evaluate(double[] a, double[] c, double z) throws MathIllegalArgumentException, NullArgumentException
a
- Coefficients in Newton form formula.c
- Centers.z
- Point at which the function value is to be computed.NullArgumentException
- if any argument is null
.MathIllegalArgumentException
- if any array has zero length.MathIllegalArgumentException
- if the size difference between
a
and c
is not equal to 1.protected void computeCoefficients()
protected static void verifyInputArray(double[] a, double[] c) throws MathIllegalArgumentException, NullArgumentException
The centers must be distinct for interpolation purposes, but not for general use. Thus it is not verified here.
a
- the coefficients in Newton form formulac
- the centersNullArgumentException
- if any argument is null
.MathIllegalArgumentException
- if any array has zero length.MathIllegalArgumentException
- if the size difference between
a
and c
is not equal to 1.DividedDifferenceInterpolator.computeDividedDifference(double[],
double[])
Copyright © 2016-2021 CS GROUP. All rights reserved.