# RatInterp

Advanced Analysis Library Only

AnalysisLibErrType RatInterp (double arrayX[], double arrayY[], int numberOfElements, double x_value, 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

/* 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-precision array | The known x-values for the planar function.
arrayY | double-precision array | The known y-values for the planar function.
numberOfElements | integer | Number of points in arrayX and in arrayY.
x_value | double-precision | Value at which the rational function is interpolated or extrapolated.
interpolatedYValue | double-precision | A calculated estimate of the y-value corresponding to the given x_value for the rational function.
errorEstimate | double-precision | 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.