org.apache.commons.math3.analysis.polynomials

## Class PolynomialFunctionNewtonForm

• java.lang.Object
• org.apache.commons.math3.analysis.polynomials.PolynomialFunctionNewtonForm
• All Implemented Interfaces:
UnivariateDifferentiableFunction, UnivariateFunction

public class PolynomialFunctionNewtonForm
extends Object
implements UnivariateDifferentiableFunction
Implements the representation of a real polynomial function in Newton Form. For reference, see Elementary Numerical Analysis, ISBN 0070124477, chapter 2.

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[]

Since:
1.2
Version:
$Id: PolynomialFunctionNewtonForm.java 1455194 2013-03-11 15:45:54Z luc$
• ### Method Detail

• #### value

public double value(double z)
Calculate the function value at the given point.
Specified by:
value in interface UnivariateFunction
Parameters:
z - Point at which the function value is to be computed.
Returns:
the function value.
• #### degree

public int degree()
Returns the degree of the polynomial.
Returns:
the degree of the polynomial
• #### getNewtonCoefficients

public double[] getNewtonCoefficients()
Returns a copy of coefficients in Newton form formula.

Changes made to the returned copy will not affect the polynomial.

Returns:
a fresh copy of coefficients in Newton form formula
• #### getCenters

public double[] getCenters()
Returns a copy of the centers array.

Changes made to the returned copy will not affect the polynomial.

Returns:
a fresh copy of the centers array.
• #### getCoefficients

public double[] getCoefficients()
Returns a copy of the coefficients array.

Changes made to the returned copy will not affect the polynomial.

Returns:
a fresh copy of the coefficients array.
• #### computeCoefficients

protected void computeCoefficients()
Calculate the normal polynomial coefficients given the Newton form. It also uses nested multiplication but takes O(N^2) time.