cubSplineValue¶
Computes the value of a cubic spline or the value of one of its derivatives.
Synopsis¶
cubSplineValue (x, ppoly)
Required Arguments¶
- float
x
(Input) - Evaluation point for the cubic spline.
- Imsl_d_ppoly
ppoly
(Input) - Pointer to the piecewise polynomial structure that represents the cubic spline.
Return Value¶
The value of a cubic spline or one of its derivatives at the point x. If no value can be computed, then NaN is returned.
Optional Arguments¶
deriv
, int (Input)- Let d =
deriv
and let s be the cubic spline that is represented by the structureImsl_d_ppoly
, then this option produces the d-th derivative of s at x, \(s^{(d)}(x)\). grid
, floatxvec
, floatvalue
(Input/Output)- The array
xvec
contains the points at which the cubic spline is to be evaluated. The d-th derivative of the spline at the points inxvec
is returned invalue
. The values in arrayxvec
must appear sorted and non-decreasing. Arranging for this requirement may benefit by use of the function sort, Chapter 12.
Description¶
The function cubSplineValue
computes the value of a cubic spline or one
of its derivatives. The first and last pieces of the cubic spline are
extrapolated. As a result, the cubic spline structures returned by the cubic
spline routines are defined and can be evaluated on the entire real line.
This routine is based on the routine PPVALU by de Boor (1978, p. 89).
Examples¶
Example 1¶
In this example, a cubic spline interpolant to a function f is computed. The values of this spline are then compared with the exact function values. Since the default settings are used, the interpolant is determined by the “not-a-knot” condition (see de Boor 1978).
Output¶
x F(x) Interpolant Error
0.250 -0.572 -0.549 0.0228
0.300 -0.978 -0.978 0.0000
0.350 -0.859 -0.843 0.0162
0.400 -0.279 -0.279 0.0000
0.450 0.450 0.441 0.0093
0.500 0.938 0.938 0.0000
0.550 0.923 0.903 0.0199
0.600 0.412 0.412 0.0000
0.650 -0.320 -0.315 0.0049
0.700 -0.880 -0.880 0.0000
0.750 -0.968 -0.938 0.0295
Example 2¶
Recall that in the first example, a cubic spline interpolant to a function f is computed. The values of this spline are then compared with the exact function values. This example compares the values of the first derivatives.
Output¶
x F(x) Interpolant Deriv Error
0.250 -12.308 -12.559 0.2510
0.300 -3.162 -3.218 0.0560
0.350 7.681 7.796 0.1151
0.400 14.403 13.919 0.4833
0.450 13.395 13.530 0.1346
0.500 5.200 5.007 0.1926
0.550 -5.786 -5.840 0.0535
0.600 -13.667 -13.201 0.4660
0.650 -14.214 -14.393 0.1798
0.700 -7.133 -6.734 0.3990
0.750 3.775 3.911 0.1359