Spline Toolbox    

General Spline Interpolation

If you want to interpolate at sites other than the breaks and/or by splines other than cubic splines with simple knots, then you use the spapi command. In its simplest form, you would say

in which the first argument, k, specifies the order of the interpolating spline; this is the number of coefficients in each polynomial piece, i.e., 1 more than the nominal degree of its polynomial pieces. For example, the next figure shows a linear, a quadratic, and a quartic spline interpolant to our data, as obtained by the statements

Figure 2-2: Spline Interpolants of Various Orders to Smooth Data

Even the cubic spline interpolant obtained from spapi is different from the one provided by csapi and spline. To emphasize their difference, we compute and plot their second derivatives, as follows:

This gives the following graph:

Figure 2-3: Second Derivative of Two Cubic Spline Interpolants to the Same Smooth Data

Since the second derivative of a cubic spline is a broken line, with vertices at the breaks of the spline, we can see clearly that csapi places breaks at the data sites, while spapi does not, and thereby produces a less jerky second derivative in this example.


  Other End Conditions Knot Choices