Class LagrangeInterpolator

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

public class LagrangeInterpolator extends 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
    Description
    protected double[]
    Polynomial coefficients.
  • Constructor Summary

    Constructors
    Constructor
    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

    Modifier and Type
    Method
    Description
    double
    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 + ....

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • hornerCoef

      protected double[] hornerCoef
      Polynomial 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.
      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[]