Interpolation and splines · Definition
Cubic 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.
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
- What degree is each piece of a cubic spline?
- What class of continuity does a cubic spline have at interior nodes?
- Which boundary condition defines the natural spline?
- How many cubic pieces does a spline have over \(n\) intervals?
- What type of linear system appears when computing the coefficients \(c_i\)?
- A natural spline with \(n=3\) intervals has \(4\cdot3=12\) unknowns. How many interpolation and continuity equations are there in total, not counting the boundary ones?
- For the natural spline through \((0,0),(1,1),(2,0)\), what is \(S''(1)\) using the \(c_1\) form of the system?
- A clamped spline imposes \(S'(x_0)=f'(x_0)\). Which of these statements about it is correct?
- If \(S\) is a natural cubic spline with \(S''(x_0)=0\), what happens to \(c_0\) in the piecewise representation?
- Let \(S\) be the natural spline through \((0,0),(1,1),(2,8)\). Compute \(S'(1^-)\) and \(S'(1^+)\) to check continuity of \(S'\). What is the common value \(S'(1)\)?
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.