PolyInterp
Advanced Analysis Library Only
AnalysisLibErrType PolyInterp (double arrayX[], double arrayY[], ssize_t numberOfElements, double xValue, double *interpolatedYValue, double *errorEstimate);
Purpose
Calculates the value of the unique polynomial P of degree (numberOfElements – 1) passing through the numberOfElements points (xi, f(xi)) at x_value and returns an estimate of the error in the interpolation, given a set of numberOfElements points (xi, f(xi)) in the plane where f is some function and given a value x_value at which f is interpolated or extrapolated. All input arrays should be the same size. If the value of x_value is in the range of arrayX, PolyInterp performs interpolation; otherwise, it performs extrapolation. If x_value is too far from the range of arrayX, errorEstimate might be large, and PolyInterp would not produce a satisfactory extrapolation.
Example Code
/* Pick points randomly, pick an x in the range of X-values, run a polynomial through the points, and interpolate at x_val. */
double X[10], Y[10], Interp_Val, Error, x_val, high, low;
n, i;
n = 10;
WhiteNoise (n, 5.0, 17, X);
WhiteNoise (n, 5.0, 17, Y);
high = X[0];
low = X[0];
for(i=0; i<n; i++) {
if (X[i] > high) high = X[i];
if (X[i] < low) low = X[i];
}
x_val = (high + low)/2.0;
PolyInterp (x, y, n, x_val, &Interp_Val, &Error);
Parameters
Input | ||
Name | Type | Description |
arrayX | double [] | Known x-values for the planar function. |
arrayY | double [] | The known y-values for the planar function. |
numberOfElements | ssize_t | Number of points in arrayX and in arrayY. |
xValue | double | Value at which the function is interpolated or extrapolated. |
Output | ||
Name | Type | Description |
interpolatedYValue | double | A calculated estimate of the y-value corresponding to the given x_value for the tabulated function. |
errorEstimate | double | Estimate of the error in the interpolation. |
Return Value
Name | Type | Description |
status | AnalysisLibErrType | A value that specifies the type of error that occurred. Refer to analysis.h for definitions of these constants. |
Additional Information
Library: Advanced Analysis Library
Include file: analysis.h
LabWindows/CVI compatibility: LabWindows/CVI 3.1 and later
Example
Refer to analysis\interp.cws for an example of using the PolyInterp function.