public class PolynomialFunctionNewtonForm extends java.lang.Object implements UnivariateRealFunction
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 |
---|---|
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.
|
public PolynomialFunctionNewtonForm(double[] a, double[] c) throws java.lang.IllegalArgumentException
The constructor makes copy of the input arrays and assigns them.
a
- the coefficients in Newton form formulac
- the centersjava.lang.IllegalArgumentException
- if input arrays are not validpublic double value(double z) throws FunctionEvaluationException
value
in interface UnivariateRealFunction
z
- the point at which the function value is to be computedFunctionEvaluationException
- if a runtime error occursUnivariateRealFunction.value(double)
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 FunctionEvaluationException, java.lang.IllegalArgumentException
a
- the coefficients in Newton form formulac
- the centersz
- the point at which the function value is to be computedFunctionEvaluationException
- if a runtime error occursjava.lang.IllegalArgumentException
- if inputs are not valid"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"