# SpInterp

Advanced Analysis Library Only

AnalysisLibErrType SpInterp (double arrayX[], double arrayY[], double secondDerivatives[], int numberOfElements, double x_value, double *interpolatedValue);

## Purpose

Performs a cubic spline interpolation of the function f at a value x_value, where x_value is in the same range as xi, given a tabulated function of the form yi = f(xi) for i = 0, 1, . . ., n — 1, with x < xi + 1, and given the second derivatives that specify the interpolant at the numberOfElements nodes of arrayX. The Spline procedure supplies the second derivatives. You can then call SpInterp as many times as you need, assuming the same tabulated function. If x_value falls in the interval [xi, xi + 1], the interpolated value is as follows:

interpolatedValue = Ayi + Byi + 1 + Cy"i + Dy"i + 1

where |
| B = 1 - A

y" denotes the second derivative of arrayY.

### Example

/* Choose ascending X-values. Pick corresponding Y-values randomly. Set boundary conditions and specify the cubic spline interpolant to run through the points. Pick an x in the same range as X and interpolate. Pick another x and interpolate again. */
double X[100], Y[100], Y2[100], b1, b2, x_val;
int n, i;
n = 100;
for(i=0; i<n; i++)
X[i] = i * 0.1;
WhiteNoise (n, 5.0, 17, Y);
b1=0.0;
b2=0.0;
Spline (X, Y, n, b1, b2, Y2);
x_val = 0.331;
SpInterp (X, Y, Y2, n, x_val, &Interp_Val);
x_val = 0.7698;
SpInterp (X, Y, Y2, n, x_val, &Interp_Val);

## Parameters

Input
Name | Type | Description
arrayX | double-precision array | The known x-values for the planar function; these values must be in ascending order.
arrayY | double-precision array | The known y-values for the planar function.
secondDerivatives | double-precision array | Array of second derivatives that specify the interpolant.
numberOfElements | integer | Number of elements in arrayX, arrayY, and secondDerivatives.
x_value | double-precision | Value at which tabulated function is interpolated.
interpolatedValue | double-precision | Interpolated value.

## 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.