## SPL_INTERP

Given the arrays X and Y , which tabulate a function (with the X i in ascending order), and given the array Y 2 , which is the output from SPL_INIT, and given an input value of X 2 , the SPL_INTERP function returns a cubic-spline interpolated value for the given value of X I . The result has the same structure as X 2 , and is either single- or double-precision floating, based on the input type.

SPL_INTERP is based on the routine splint described in section 3.3 of Numerical Recipes in C: The Art of Scientific Computing (Second Edition), published by Cambridge University Press, and is used by permission.

### Calling Sequence

Result = SPL_INTERP( X, Y, Y2, X2 )

### Arguments

#### X

An input array that specifies the tabulated points in ascending order.

#### Y

An input array that specifies the values of the tabulate function corresponding to X i .

#### Y2

The output from SPL_INIT for the specified X and Y .

#### X2

The input value for which an interpolated value is desired. X can be scalar or an array of values. The result of SPL_INIT will have the same structure.

### Keywords

#### DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

### Example

To create a spline interpolation over a tabulated set of data, [ X i , Y i ], first create the tabulated data. In this example, X i will be in the range [0.0, 2p] and Y i in the range [sin(0.0), sin(2p)].

X = (FINDGEN(21)/20.0) * 2.0 * !PI

Y = SIN(X)

Y 2 = SPL_INIT(X, Y) ; Calculate interpolating cubic spline.

X 2 = FINDGEN(11)/11.0 * !PI ; Define the X values P at which we desire interpolated Y values.

result = SPL_INTERP(X, Y, Y 2 , X 2 ) ; Calculate the interpolated Y values corresponding to X 2 ; [i].

PRINT, result

IDL prints:

0.00000  0.281733  0.540638  0.755739  0.909613  0.989796

0.989796  0.909613  0.755739  0.540638  0.281733

The exact solution vector is sin(X 2 ).

To interpolate a line in the XY plane, see SPLINE_P.