Spline

Advanced Analysis Library Only

AnalysisLibErrType Spline (double arrayX[], double arrayY[], int numberOfElements, double firstBoundary, double secondBoundary, double secondDerivatives[]);

Purpose

Calculates the second derivatives used by the cubic spline interpolant, given a tabulated function of the form yi = f(xi) for i = 0, 1, . . ., n — 1, with xi < xi + 1, and given the boundary conditions firstBoundary and secondBoundary such that the interpolant's second derivative matches the specified values at x0 and xn — 1.

You can use this array with SpInterp to calculate an interpolation value.

Example

/* Choose ascending X-values. Pick corresponding Y-values randomly. Set boundary conditions and specify the cubic spline interpolant to run through the points. */
double X[100], Y[100], Y2[100], b1, b2;
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);

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.
numberOfElements integer Number of elements in arrayX, arrayY, and secondDerivatives.
firstBoundary double-precision The value of the first derivative of the interpolant at the first element of arrayX.
secondBoundary double-precision The value of the first derivative of the interpolant at the last element of arrayX.
secondDerivatives double-precision array Array of second derivatives that specify the interpolant.

You can use this array with SpInterp to calculate an interpolation value.

These second derivatives represent the continuously differentiable curve to run though the n points (xi, yi).

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.