Interpolation and splines · Definition

Cubic splines

numerical methodsinterpolation and splines

Interpolating with one high-degree polynomial can oscillate strongly between the data. Cubic splines solve this by using cubic pieces joined smoothly.

Definition

A cubic spline \(S\) is a piecewise function, each piece a polynomial of degree three, that interpolates the data \((x_i,y_i)\) and is of class \(C^2\) at the nodes.

\[S_i(x)=a_i+b_i(x-x_i)+c_i(x-x_i)^2+d_i(x-x_i)^3\]

Each piece \(S_i\) is defined on \([x_i,x_{i+1}]\), and the interpolation conditions plus continuity of \(S\), \(S'\) and \(S''\) at interior nodes give \(4n-2\) equations for \(4n\) unknowns. That is why two boundary conditions are added, such as the natural ones \(S''(x_0)=S''(x_n)=0\) or the clamped ones, which fix \(S'\) at the endpoints.

For the data \((0,1),(1,2),(2,0)\) with natural boundary, the system for \(c_1\) is tridiagonal, with \(c_0=c_2=0\) and \(4c_1=3\,(f[x_1,x_2]-f[x_0,x_1])=-9\), so \(c_1=-\tfrac{9}{4}\). This gives a \(C^2\) spline that passes exactly through the three points.

A typical mistake is imposing only continuity of \(S\) and \(S'\) and forgetting \(S''\), which produces an interpolant that is not a true cubic spline. Another common error is using boundary conditions without justifying which one fits the problem.

Think about it

What would happen to the oscillation if the same data were interpolated with one high-degree polynomial instead of cubic pieces?

It would tend to oscillate strongly between the nodes, especially near the ends (Runge phenomenon), whereas a cubic spline confines that effect to each piece.

Exercises 10

References

  • Richard L. Burden, J. Douglas Faires, Annette M. Burden, Numerical Analysis, 10th edition, Cengage Learning, 2016.
  • Lloyd N. Trefethen, David Bau III, Numerical Linear Algebra, 1st edition, SIAM, 1997.