Functions > Data Analysis > Interpolation and Prediction > Polynomial Interpolation
Polynomial Interpolation
polyint(vx, vy, x)—Returns the interpolated value at x using a polynomial function, and the expected error.
The polyint function performs polynomial interpolation of a data set of length N at a requested point, x, using Neville's algorithm. The function finds a unique polynomial of degree N – 1 which passes through each point.
polycoeff(vx, vy)—Returns the coefficients of the interpolating polynomial function.
The polycoeff function calculates the coefficients of the interpolating polynomial for use in subsequent calculations.
polyiter(vx, vy, x, N, e)—Returns the interpolated value at x using a polynomial function with maximum order N and maximum error, e.
The output of polyiter is a vector where the first element is a "converged" flag (1 = converged, 0 = did not converge), the second element is the number of iterations needed to meet the specified tolerance, and the third element is the iterated estimate of y obtained for the input value of x.
Arguments
vx, vy are real vectors of data values of the same length.
x is the value of the independent variable at which you want to evaluate the interpolation curve. For best results, x should be in the range encompassed by the values of vx.
If the input vectors use units, then x must have the same units as vx.
N is the maximum number of iterations. N is also the maximum order of the polynomial function because after each iteration, the degree of the polynomial is increased by one.
e is the input tolerance.
If the input vectors use units, then e must have the same units as vy.
Additional Information
Aitken-Neville interpolation used for the polyiter function is similar to the polynomial interpolation implemented in polyint and polycoeff. But since the interpolation is iterated, polyiter permits you to specify an input tolerance, e, and a maximum number of iterations, N. The algorithm stops if the last two iterated estimates of the data point agree to within the tolerance e, or if the number of iterations reaches the input argument N. Iterated interpolation is used to advantage, for example, in the Romberg quadrature of definite integrals. Numerical integration is a very computationally-intensive process. Being able to exit early can save processing time in trade for a less accurate answer. Aitken-Neville interpolation is typically used to find only a few interpolated points with some specified tolerance.
The polyint and polycoeff routines are based on polyint (p.109) and polycoeff (p.121) from the book "Numerical Recipes in C, The Art of Scientific Computing" (Cambridge University Press), Copyright (C) 1987, 1988 Numerical Recipes Software, and is used under license. The polyiter routine is described in McCalla, Thomas Richard (1967). Introduction to Numerical Methods and FORTRAN Programming, John Wiley.
Was this helpful?