org.opensourcephysics.numerics

## Class LagrangeInterpolator

• java.lang.Object
• org.opensourcephysics.numerics.LagrangeInterpolator
• All Implemented Interfaces:
Function

```public class LagrangeInterpolator
extends java.lang.Object
implements Function```
LagrangeInterpolator uses a polynomial interpolation formula to evaluate values between data points.
Version:
1.0
Author:
W. Christian
• ### Field Summary

Fields
Modifier and Type Field and Description
`protected double[]` `hornerCoef`
Polynomial coefficients.
• ### Constructor Summary

Constructors
Constructor and Description
```LagrangeInterpolator(double[] xdata, double[] ydata)```
Constructs a Lagrange interpolating polynomial from the given data using Horner's expansion for the representation of the polynomial.
• ### Method Summary

Methods
Modifier and Type Method and Description
`double` `evaluate(double x)`
Computes the interpolated y value for a given x value.
`double[]` `getCoefficients()`
Gets the polynomial coefficients c in c[0] + c[1] * x + c[2] * x^2 + ....
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Field Detail

• #### hornerCoef

`protected double[] hornerCoef`
Polynomial coefficients.
• ### Constructor Detail

• #### LagrangeInterpolator

```public LagrangeInterpolator(double[] xdata,
double[] ydata)```
Constructs a Lagrange interpolating polynomial from the given data using Horner's expansion for the representation of the polynomial.
Parameters:
`xdata` - double[]
`ydata` - double[]
• ### Method Detail

• #### evaluate

`public double evaluate(double x)`
Computes the interpolated y value for a given x value.
Specified by:
`evaluate` in interface `Function`
Parameters:
`x` - value
Returns:
interpolated y value
• #### getCoefficients

`public double[] getCoefficients()`
Gets the polynomial coefficients c in c[0] + c[1] * x + c[2] * x^2 + .... This routine should be used with care because the Vandermonde matrix that is being solved is ill conditioned. See Press et al.
Returns:
double[]