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

## Examples

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, 2π] and *Y*_{i} in the range [sin(0.0), sin(2π)].

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

Y = SIN(X)

; Calculate interpolating cubic spline:

Y2 = SPL_INIT(X, Y)

; Define the X values P at which we desire interpolated Y values:

X2= FINDGEN(11)/11.0 * !PI

; Calculate the interpolated Y values corresponding to X2[i]:

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

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.

## Syntax

*Result* = SPL_INTERP( *X*, *Y*, *Y2*, *X2* [, /DOUBLE] )

## Return Value

Returns either single- or double-precision floating result of the same structure as *X*_{2}.

## 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_INTERP will have the same structure.

## Keywords

### DOUBLE

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

## Version History

4.0 |
Introduced |

## Resources and References

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.

## See Also

## Notes

This page has no user notes yet. Be the first one!