RatInterp
Advanced Analysis Library Only
AnalysisLibErrType RatInterp (double arrayX[], double arrayY[], ssize_t numberOfElements, double xValue, double *interpolatedYValue, double *errorEstimate);
Purpose
Returns the value of a particular rational function P(x)/Q(x) passing through the numberOfElements points (xi, f(xi)) at x_value, given a set of numberOfElements points (xi, f(xi)) in the plane where f is some function, and a value x_value at which f is to be interpolated. P and Q are polynomials, and numberOfElements is the number of elements in arrayX.
The function P(x)/Q(x) is the unique rational function that passes through the given points and satisfies the following conditions:


where deg( ) is the order of the polynomial function.
All input arrays should be the same size. If the value of x_value is in the range of arrayX, RatInterp performs interpolation; otherwise, it performs extrapolation. If x_value is too far from the range of arrayX, errorEstimate might be large, and RatInterp would not produce a satisfactory extrapolation.
This function also returns an estimate of the error in the interpolation.
Example Code
/* Pick points randomly, pick an x in the range of x-values, run a rational
function through the points and interpolate at x_val. */
double x[10], y[10], Interp_Val, Error, x_val, high, low;
int 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;
RatInterp (x, y, n, x_val, &Interp_Val, &Error);
Parameters
Input | ||
Name | Type | Description |
arrayX | double [] | The 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 rational function is interpolated or extrapolated. |
interpolatedYValue | double * | A calculated estimate of the y-value corresponding to the given x_value for the rational 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 RatInterp function.