Lecture 2.3:
Linear and cubic splines

Higher-order polynomial interpolation is rarely used for practical purposes because of a polynomial wiggle, i.e. high swings of the interpolating polynomials between the data points. Instead, most of computational algorithms use the idea of splines, i.e. piecewise interpolation. The MATLAB functions interp1(x,y,xi,'linear') and interp1(x,y,xi,'spline') are also based on piecewise linear and cubic interpolation.

Linear splines

The linear spline represents a set of line segments between the two adjacent data points (Vk,Ik) and (Vk+1,Ik+1). The equations for each line segment can be immediately found in a simple form:

Ik(V) = Ik + ( Ik+1 - Ik) ( V - Vk ) / (Vk+1 - Vk),

where V = [Vk,Vk+1] and k = 0,1,...,(n-1). When the linear spline is applied to the voltage-current data for a zener diode, the interpolating algorithm produces the following picture:

The resulting curve is clearly not smooth, with sharp corners at the data points. However, the piecewise interpolation represents the "exact" curve I = I(V) better that the Lagrange or Newton polynomial interpolation. The linear spline is constructed for each interval V = [Vk,Vk+1] independently and it matches the data values (Vk,Ik) for k=0,1,...,n.

Cubic splines

We can improve the appearance of the piecewise interpolation by matching not only the data values but also the slopes and the concavities of each individual interpolating segment at the interior data points. For (n+1) data values (Vk,Ik) we would have n conditions to match the values I(Vk), (n-1) conditions to match the slopes I'(Vk) and (n-1) conditions to match the concavities I''(Vk), i.e. 3n - 2 conditions (equations). Cubic splines would be good candidates for such interpolation:

Ik(V) = Ik + ak ( V - Vk ) + bk ( V - Vk )2 + ck ( V - Vk )3,

where V = [Vk,Vk+1] and k = 0,1,...,(n-1). Indeed, the cubic splines have 3n unknown coefficients (more than required). Two more conditions should be added separately at the ends of the interpolating interval, i.e. at the points V = V0 and V = Vn. These end-point or boundary conditions are set due to additional assumptions on appearance of the interpolating curve. The simplest conditions follow from the assumption that the concavity is zero at the ends. This is a definition of a natural cubic spline.

A suitable computational algorithm to define the coefficients of cubic splines solves a WELL-posed linear system for concavities I''(Vk) = mk subject to the boundary conditions: m0 = m n = 0 (for natural splines). Provided the solution for mk is found for k = 1,2,...,(n-1), the coefficients of the cubic splines are

ak = ( Ik+1 - Ik ) / (Vk+1 - Vk ) - (2 mk + mk+1) ( Vk+1 - Vk ) / 6
bk = 0.5 mk, ck = 1/6 ( mk+1 - mk ) / (Vk+1-Vk)

Note that the cubic spline reduces to the linear spline if concavities are neglected, i.e. all mk are zeros. When the cubic spline is applied to the voltage-current data for a zener diode, the interpolating algorithm produces the following picture acceptable both for further work and visualization:

The error of the cubic spline interpolation is O(h4), where h is the maximum spacing between the data points.