Burden & Faires, 9th Ed. - §3.5–3.6

Chapter 7: Cubic Splines & Parametric Curves

Piecewise polynomials · Natural & clamped boundary conditions · The tridiagonal system · Parametric curves

Chapter 5 ended with a warning: one high-degree polynomial through many points can oscillate wildly (Runge's phenomenon). Cubic splines are the practical fix - instead of one degree-$n$ polynomial, use $n$ separate cubic pieces, one per interval between consecutive nodes, stitched together so the curve and its first two derivatives are continuous across every seam. The result is a curve as smooth as a draftsman's spline (the flexible strip of wood the method is named for), without ever needing a polynomial of degree higher than 3.

Section 3.5

Why Piecewise?

The Trade Splines Make
A single high-degree interpolant is a global object - one wiggle far from a data point can (via Runge's phenomenon) contaminate the fit everywhere. A cubic spline is local - each piece only depends on nearby data - so it can follow local behavior in the data without the far-field blow-up of Chapter 5's Runge example, at the cost of the resulting curve technically being $n$ separate cubics glued together rather than one clean formula.
Section 3.5 continued

Constructing the Natural Cubic Spline

Continuity Conditions

Definition - Cubic Spline Interpolant
Given nodes $x_0\lt x_1\lt\cdots\lt x_n$, a cubic spline $S(x)$ consists of $n$ cubic pieces $S_i(x)$ on $[x_i,x_{i+1}]$, satisfying:
  1. $S_i(x_i)=f(x_i)$ and $S_i(x_{i+1})=f(x_{i+1})$ for each $i$ (interpolates the data).
  2. $S_{i+1}(x_{i+1})=S_i(x_{i+1})$ (continuous - automatic from condition 1).
  3. $S_{i+1}'(x_{i+1})=S_i'(x_{i+1})$ (continuous first derivative - no visible kinks).
  4. $S_{i+1}''(x_{i+1})=S_i''(x_{i+1})$ (continuous second derivative - no visible change in curvature).
  5. Boundary condition - one of: $S''(x_0)=S''(x_n)=0$ (natural spline), or $S'(x_0)=f'(x_0),\,S'(x_n)=f'(x_n)$ (clamped spline).

The Tridiagonal System

Solving for the Second Derivatives
Let $M_i = S''(x_i)$ and $h_i = x_{i+1}-x_i$. Continuity of $S'$ across every interior node reduces to a linear system in the unknowns $M_0,\ldots,M_n$: $$h_{i-1}M_{i-1} + 2(h_{i-1}+h_i)M_i + h_iM_{i+1} = 6\left(\frac{f(x_{i+1})-f(x_i)}{h_i} - \frac{f(x_i)-f(x_{i-1})}{h_{i-1}}\right), \quad i=1,\ldots,n-1$$ together with $M_0=0,\,M_n=0$ (natural) closing the system. This matrix is tridiagonal and diagonally dominant, which - as Chapter 14 shows - guarantees a unique solution and lets it be solved in $O(n)$ operations rather than the $O(n^3)$ a general linear solve would need. Once the $M_i$ are known, each cubic piece is $$S_i(x) = f(x_i) + b_i(x-x_i) + \frac{M_i}{2}(x-x_i)^2 + \frac{M_{i+1}-M_i}{6h_i}(x-x_i)^3, \qquad b_i = \frac{f(x_{i+1})-f(x_i)}{h_i} - \frac{h_i(2M_i+M_{i+1})}{6}$$
📘 Example 7.1 - Natural Cubic Spline Through Four Points
Construct the natural cubic spline through $(0,1),\,(1,3),\,(2,2),\,(3,4)$. Solution All $h_i=1$. With $M_0=M_3=0$, the interior equations ($i=1,2$) are: $$4M_1 + M_2 = 6[(2-3)-(3-1)] = 6(-1-2) = -18$$ $$M_1 + 4M_2 = 6[(4-2)-(2-3)] = 6(2+1) = 18$$ Solving: from the first, $M_1 = (-18-M_2)/4$. Substituting into the second: $(-18-M_2)/4 + 4M_2 = 18 \Rightarrow -18-M_2+16M_2=72 \Rightarrow 15M_2=90 \Rightarrow M_2=6$, then $M_1=(-18-6)/4=-6$.
Interval$a_i$$b_i$$c_i=M_i/2$$d_i$
$[0,1]$13.00.0$-1.0$
$[1,2]$30.0$-3.0$2.0
$[2,3]$20.03.0$-1.0$
where $S_i(x) = a_i + b_i(x-x_i)+c_i(x-x_i)^2+d_i(x-x_i)^3$. At $x=1.5$ (interval $[1,2]$, so use $a_1,b_1,c_1,d_1$ with $(x-x_1)=0.5$): $$S(1.5) = 3 + 0(0.5) - 3(0.5)^2 + 2(0.5)^3 = 3 - 0.75 + 0.25 = 2.5$$ $S(1.5)=2.5$ - the spline passes smoothly through the dip at $(2,2)$ without overshooting, unlike a single cubic Lagrange polynomial forced through all four points, which has no freedom to bend independently per interval.
Drag any of the 5 control points and watch the natural cubic spline (blue) recompute live via the tridiagonal system above - notice how moving one point only reshapes the curve locally, never introducing far-away oscillation the way a single high-degree polynomial would (Chapter 5).
Section 3.5 continued

Clamped Cubic Splines

When You Know the Endpoint Slopes
If $f'(x_0)$ and $f'(x_n)$ are known (e.g. from the physical problem the data comes from), the clamped spline pins the curve's slope at both ends instead of its curvature. This changes only the two boundary rows of the tridiagonal system - $h_0(2M_0+M_1)/6\ldots$ replace $M_0=0$ - and in general produces a strictly more accurate fit than the natural spline whenever those derivatives are actually known, since it uses genuine information the natural spline simply doesn't have access to and has to compensate for by assuming zero curvature at the ends instead.
Section 3.6

Parametric Curves

Beyond Functions - Curves That Loop and Cross Themselves
Every spline so far has interpolated $y=f(x)$ - one $y$ per $x$, so the curve can never double back on itself. A parametric spline instead fits two independent splines, $x(t)$ and $y(t)$, against a parameter $t$ (often arc-length or simply node index). Tracing $(x(t),y(t))$ as $t$ increases can produce loops, corners, and closed curves - exactly the technique behind font outlines and vector graphics.
The Parameterization Itself Matters
Two different choices of $t$ at the same data points (e.g. uniform spacing vs. spacing proportional to the distance between consecutive points) generally produce visibly different curves - parametric interpolation is not unique the way $y=f(x)$ interpolation is, because the parameterization is an extra modeling choice, not something the data alone determines.
Practice

Practice Problem

Try this problem yourself before expanding the solution below.

✏️ Practice Problem 7.1 - Natural Cubic Spline Through Four Points
Construct the natural cubic spline through $(0,1),\,(1,2),\,(2,0),\,(3,3)$, and evaluate the spline at $x=1.5$. Solution With equal spacing $h_0=h_1=h_2=1$ and natural conditions $c_0=c_3=0$, solving the tridiagonal system for the interior second-derivative terms $c_1,c_2$ gives $c_1=-3.400000$, $c_2=4.600000$. Back-substituting for $b_i,d_i$ on each piece produces $$S_1(x) = 2 -1.266667(x-1) -3.400000(x-1)^2 + 2.666667(x-1)^3 \quad \text{on } [1,2],$$ since $x=1.5$ falls in $[1,2]$. Evaluating at $x=1.5$ (so $x-1=0.5$): $$S_1(1.5) = 2 - 1.266667(0.5) - 3.400000(0.25) + 2.666667(0.125) = 0.850000.$$ $S(1.5) = 0.850000$ - notice this is well below the straight-line average of $y_1=2$ and $y_2=0$ (which would give 1.0), because the spline is curving sharply to stay smooth through the neighboring points.
Connections Across the Course
  • The tridiagonal solve here is a special, especially efficient case of the general linear-system methods in Chapter 14.
  • Clamped splines reuse exactly the derivative-matching idea of Hermite interpolation (Chapter 6), just enforced only at the two endpoints instead of every node.
  • Splines are themselves piecewise polynomials, so they can be differentiated and integrated term-by-term exactly the way Chapters 8 and 9 differentiate and integrate ordinary interpolating polynomials.
Scroll to Top