Class LagrangeInterpolator

java.lang.Object
noaa.coastwatch.util.Function
noaa.coastwatch.util.LagrangeInterpolator
All Implemented Interfaces:
Encodable

public class LagrangeInterpolator extends Function
A Lagrange interpolator uses a set of known function data to interpolate function values between data points. The interpolator makes use of the Lagrange polynomial method as describe in:
Burden, R.L., and J.D Faires. "Numercial Analysis", Sixth Ed., Brooks/Cole Publishing, 1997, pp 107-111.
Briefly, the interpolator derives an (n-1)th order polynomial using the n known data points (xi, yi) where i=1..n with the formula:
P(x) = SUM(i=1..n) { yiLi(x) }
where:
Li(x) = PRODUCT(j=1..n,j!=i) { (x-xj) / (xi - xj) }
Since:
3.1.3
Author:
Peter Hollemans
  • Constructor Details

    • LagrangeInterpolator

      public LagrangeInterpolator(double[] x, double[] y)
      Creates a new Lagrangian interpolator based on the specified data.
      Parameters:
      x - the x data values.
      y - the y function values corresponding to x1..xn.
  • Method Details

    • evaluate

      public double evaluate(double[] variables)
      Description copied from class: Function
      Evalutes a function value with the specified inputs.
      Specified by:
      evaluate in class Function
      Parameters:
      variables - the array of input variable values.
      Returns:
      the evaluated function value. If an error occurred during evaluation, the return value is Double.NaN.