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

X_{
2}
= FINDGEN(11)/11.0 * !PI

result = SPL_INTERP(X, Y, Y_{
2}
, X_{
2}
)
_{
2}

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.