Top Description Fields Constructors Methods
org.apache.commons.math3.analysis.interpolation

public Class DividedDifferenceInterpolator

extends Object
implements UnivariateInterpolator, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator
Imports
java.io.Serializable, org.apache.commons.math3.analysis.polynomials.PolynomialFunctionLagrangeForm, .PolynomialFunctionNewtonForm, org.apache.commons.math3.exception.DimensionMismatchException, .NumberIsTooSmallException, .NonMonotonicSequenceException

Implements the Divided Difference Algorithm for interpolation of real univariate functions. For reference, see Introduction to Numerical Analysis, ISBN 038795452X, chapter 2.

The actual code of Neville's evaluation is in PolynomialFunctionLagrangeForm, this class provides an easy-to-use interface to it.

Since
1.2

Field Summary

Modifier and TypeField and Description
private static final long
serialVersionUID

serializable version identifier

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected static double[]

Returns:

a fresh copy of the divided difference array.
computeDividedDifference
(final double[]
Interpolating points array.
x
,
final double[]
Interpolating values array.
y
)

Return a copy of the divided difference array.

public PolynomialFunctionNewtonForm

Returns:

a function which interpolates the dataset.
interpolate
(double[]
Interpolating points array.
x
,
double[]
Interpolating values array.
y
)

Implements org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator.interpolate.

Compute an interpolating function for the dataset.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

serializable version identifier

Constructor Detail

DividedDifferenceInterpolatorback to summary
public DividedDifferenceInterpolator()

Method Detail

computeDividedDifferenceback to summary
protected static double[] computeDividedDifference(final double[] x, final double[] y) throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException

Return a copy of the divided difference array.

The divided difference array is defined recursively by

f[x0] = f(x0)
f[x0,x1,...,xk] = (f[x1,...,xk] - f[x0,...,x[k-1]]) / (xk - x0)

The computational complexity is \(O(n^2)\) where \(n\) is the common length of x and y.

Parameters
x:double[]

Interpolating points array.

y:double[]

Interpolating values array.

Returns:double[]

a fresh copy of the divided difference array.

Exceptions
DimensionMismatchException:
if the array lengths are different.
NumberIsTooSmallException:
if the number of points is less than 2.
NonMonotonicSequenceException:
if x is not sorted in strictly increasing order.
interpolateback to summary
public PolynomialFunctionNewtonForm interpolate(double[] x, double[] y) throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException

Implements org.apache.commons.math3.analysis.interpolation.UnivariateInterpolator.interpolate.

Compute an interpolating function for the dataset.

Parameters
x:double[]

Interpolating points array.

y:double[]

Interpolating values array.

Returns:PolynomialFunctionNewtonForm

a function which interpolates the dataset.

Exceptions
DimensionMismatchException:
if the array lengths are different.
NumberIsTooSmallException:
if the number of points is less than 2.
NonMonotonicSequenceException:
if x is not sorted in strictly increasing order.