Package org.opensourcephysics.numerics
Class LagrangeInterpolator
java.lang.Object
org.opensourcephysics.numerics.LagrangeInterpolator
- All Implemented Interfaces:
Function
LagrangeInterpolator uses a polynomial interpolation formula to evaluate values between data points.
- Version:
- 1.0
- Author:
- W. Christian
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionLagrangeInterpolator
(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
Modifier and TypeMethodDescriptiondouble
evaluate
(double x) Computes the interpolated y value for a given x value.double[]
Gets the polynomial coefficients c in c[0] + c[1] * x + c[2] * x^2 + ....
-
Field Details
-
hornerCoef
protected double[] hornerCoefPolynomial coefficients.
-
-
Constructor Details
-
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 Details
-
evaluate
public double evaluate(double x) Computes the interpolated y value for a given x 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[]
-