Mathematics.

numerical analysis

Spline Interpolation

Numerical Analysis30 minDifficulty6 out of 10

You should know: interpolation methods

Overview

A single high-degree polynomial forced through many data points tends to oscillate wildly between the nodes (Runge's phenomenon), especially near the ends of the interval. Spline interpolation sidesteps this by using a different low-degree polynomial (almost always cubic) on each subinterval between consecutive data points, chosen so the pieces join up smoothly: the value, first derivative, and second derivative all match at each interior node. This piecewise construction gives a curve that looks and behaves smoothly to the eye while staying numerically well-behaved even with many data points — which is why splines are the standard tool behind font and vector-graphics curves, CAD/CAM surface design, and smooth trajectory planning in robotics and animation, as well as smooth interpolation of scientific and financial time series.

Intuition

Picture a flexible draftsman's spline — a thin strip of wood or metal historically used to draw smooth curves through fixed pins on a drafting table. The physical strip naturally bends to minimize its own strain energy, producing a smooth curve of least total curvature that passes through every pin without kinks. The mathematical cubic spline mimics this exactly: rather than one rigid polynomial fighting to pass through every point (and overshooting between them), each short piece only has to blend smoothly into its neighbors, so the curve stays gentle and well-behaved everywhere, just like the physical strip relaxing into its natural shape between the pins.

Formal Definition

Definition

For nodes x₀ < x₁ < ⋯ < xₙ with values y₀, …, yₙ, a cubic spline is a piecewise cubic Sᵢ(x) on each [xᵢ, xᵢ₊₁] that agrees with the data and joins continuously in value, slope, and curvature at every interior node. Writing cᵢ = Sᵢ''(xᵢ)/2, the natural spline (which additionally sets the curvature to zero at both endpoints) solves a tridiagonal linear system for the interior cᵢ:

Si(x)=yi+bi(xxi)+ci(xxi)2+di(xxi)3,x[xi,xi+1]S_i(x) = y_i + b_i(x-x_i) + c_i(x-x_i)^2 + d_i(x-x_i)^3, \qquad x \in [x_i, x_{i+1}]
Piecewise cubic on each subinterval
hi1ci1+2(hi1+hi)ci+hici+1=3hi(yi+1yi)3hi1(yiyi1),hi=xi+1xih_{i-1}c_{i-1} + 2(h_{i-1}+h_i)c_i + h_i c_{i+1} = \dfrac{3}{h_i}(y_{i+1}-y_i) - \dfrac{3}{h_{i-1}}(y_i - y_{i-1}), \quad h_i = x_{i+1}-x_i
Tridiagonal system for interior second-derivative coefficients (natural spline: c_0 = c_n = 0)
bi=yi+1yihihi(2ci+ci+1)3,di=ci+1ci3hib_i = \dfrac{y_{i+1}-y_i}{h_i} - \dfrac{h_i(2c_i+c_{i+1})}{3}, \qquad d_i = \dfrac{c_{i+1}-c_i}{3h_i}
Remaining coefficients once the c_i are known

Worked Examples

  1. With natural boundary conditions c₀ = c₂ = 0 and equal spacing h₀ = h₁ = 1, the single interior unknown c₁ solves the reduced tridiagonal equation.

    2(h0+h1)c1=3h1(y2y1)3h0(y1y0)    4c1=3(01)3(10)=62(h_0+h_1)c_1 = \dfrac{3}{h_1}(y_2-y_1) - \dfrac{3}{h_0}(y_1-y_0) \;\Rightarrow\; 4c_1 = 3(0-1) - 3(1-0) = -6
  2. Solve for c₁.

    c1=64=1.5c_1 = -\dfrac{6}{4} = -1.5
  3. Compute b₀ and d₀ for the first piece S₀ on [0,1], using c₀=0, c₁=−1.5, h₀=1.

    b0=y1y0h0h0(2c0+c1)3=11.53=1+0.5=1.5,d0=c1c03h0=1.53=0.5b_0 = \dfrac{y_1-y_0}{h_0} - \dfrac{h_0(2c_0+c_1)}{3} = 1 - \dfrac{-1.5}{3} = 1 + 0.5 = 1.5, \qquad d_0 = \dfrac{c_1-c_0}{3h_0} = \dfrac{-1.5}{3} = -0.5
  4. Assemble S₀(x) = y₀ + b₀(x−0) + c₀(x−0)² + d₀(x−0)³ and evaluate at x=0.5.

    S0(x)=1.5x0.5x3,S0(0.5)=1.5(0.5)0.5(0.125)=0.750.0625=0.6875S_0(x) = 1.5x - 0.5x^3, \qquad S_0(0.5) = 1.5(0.5) - 0.5(0.125) = 0.75 - 0.0625 = 0.6875

Answer: S(0.5) = 0.6875 — smoothly rising toward the peak at x=1, unlike a straight-line (linear) interpolation, which would give only 0.5 at the midpoint.

Practice Problems

Difficulty 5/10

For the natural cubic spline through (0,0), (1,1), (2,0), what value does the tridiagonal system give for c₁?

Difficulty 6/10

Using S₀(x) = 1.5x − 0.5x³ (the first piece of the spline through (0,0),(1,1),(2,0)), evaluate S₀ at x = 0.25.

Difficulty 7/10

A font's letter outlines are drawn using cubic Bézier/spline curves through anchor points rather than a single high-degree interpolating polynomial through all the anchor points on a letter. Why?

Quiz

A cubic spline joins its piecewise polynomial pieces so that at each interior node the following match between neighboring pieces:
The 'natural' boundary condition for a cubic spline sets:
A key advantage of splines over a single high-degree interpolating polynomial through many points is that splines:

Summary

  • Spline interpolation uses piecewise low-degree (usually cubic) polynomials, joined so value, slope, and curvature match at each interior node, avoiding the oscillation of a single high-degree interpolating polynomial.
  • Natural cubic splines additionally set curvature to zero at both endpoints (c₀ = cₙ = 0), reducing the construction to solving a tridiagonal linear system for the interior second-derivative coefficients cᵢ.
  • For (0,0),(1,1),(2,0), the natural spline gives c₁ = −1.5 and first piece S₀(x) = 1.5x − 0.5x³, so S(0.5) = 0.6875.
  • Splines are the standard tool behind font/vector-graphics curves, CAD surface design, and smooth robotics/animation trajectories, because editing one point only affects nearby segments (local control).

References

  1. BookBurden, R. L. & Faires, J. D. Numerical Analysis, 10th ed. Cengage, 2015.