4.8.12 · D1Numerical Methods

Foundations — Cubic spline interpolation — natural, clamped

1,964 words9 min readBack to topic

Before you can read the parent note, you must be able to read every mark on the page without flinching. Below is a from-zero tour of each symbol and concept, ordered so that each one leans only on the ones before it. If the parent note wrote it and assumed you knew it — it's built here.


1. Points, and the subscript trick

The mark is read "x-sub-i" and simply means "the -value of point number ". So is the first, the next, up to (the last). The letter is the number of the last point, so there are points in total (because we started counting at , not ).

Figure — Cubic spline interpolation — natural, clamped

Look at the figure: the dots are the . The condition (the parent writes exactly this) just says the points march strictly left to right — no two share an , and none go backwards. This ordering is what lets us talk about "the interval between neighbours."


2. The interval and its width

Picture: is the horizontal gap between two neighbouring dots (see figure s01, the orange bracket underneath). Why the topic needs it: every formula divides by — because a slope or a curvature is always "how much change per unit width," and you cannot measure change per width without knowing the width.


3. What a cubic is (and why cubic)

Picture: a single smooth wiggle that can go up then down (or vice-versa) — see figure s02. A straight line () can't bend; a parabola () bends one way only; a cubic can bend, straighten, and bend back — flexible enough to smoothly link two heights while also controlling slope and curvature at the joins.

Figure — Cubic spline interpolation — natural, clamped

4. Function notation and the piecewise idea

So is piecewise: different formula on different stretches, but one continuous curve overall. The parent writes — read that as "piece , evaluated at the left node , gives the data height ." That is the interpolation condition: the curve must pass exactly through the dots.


5. Slope: the first derivative

Picture: the tilt of a tiny straight ruler laid tangent to the curve at a point (figure s03, the magenta tangent). Why we need it: if two pieces meet at a node but have different slopes, the curve has a visible kink — like the corner of a roof. Demanding (slopes agree from the left and the right) erases the kink. This is where the pieces "talk to each other."


6. Curvature: the second derivative

Picture: figure s03 shows two arcs — one gently curved (small ) and one sharply curved (large ). Why we need it: matching slope removes kinks in the tilt, but you can still have a subtle "bendiness jump." Matching too makes the curve fair — the eye sees no abrupt change of curvature. Demanding , , and all continuous is exactly what the parent calls being ====.

Figure — Cubic spline interpolation — natural, clamped

7. The moment — a nickname for end-curvature

Why work with at all? Because on a single interval, is a straight line (a cubic's second derivative is linear). A straight line is completely pinned by its two endpoint values and . So instead of chasing four coefficients per piece, we only track one number per node — far fewer unknowns, and they link up neatly into a solvable chain.


8. Slopes-of-slopes: the right-hand side is discrete curvature

The parent's master equation has a right side Read the inner pieces: is "rise over run" = the average slope on the right interval; the other term is the average slope on the left interval. Their difference is how much the slope changed as you crossed node — a raw, data-only estimate of curvature. This "difference of differences" idea is the world of Finite differences. The is a constant that pops out of integrating a cubic twice; you'll take it on faith here.


9. Boundary conditions — the two missing facts

The parent counts coefficient-dials but only equations from interpolation + smoothness, leaving the system 2 short. Two more facts must be supplied at the two free ends:

Both plug in as the missing two rows. The word "natural" = No curvature; "clamped" = Controlled slope.


10. Tridiagonal system — the shape of the equations

Why care: a tridiagonal system is solved super-fast and stably by the Tridiagonal systems & Thomas algorithm — no need for heavy general matrix methods. This is a big practical reason splines are cheap to compute.


Prerequisite map

Data points x_i y_i ordered left to right

Interval width h_i

Cubic pieces S_i

Slope S prime

Curvature S double prime

Moment M_i equals S double prime at node

C2 smoothness at joins

Master tridiagonal system

Solve via Thomas algorithm

Boundary conditions natural or clamped

Runge phenomenon warns against one big polynomial

Cubic spline S x

Read it downward: points give widths and cubic pieces; cubics give slope, then curvature, then moments; smoothness plus moments plus boundary facts assemble the tridiagonal system; solving it yields the spline.


Equipment checklist

Cover the answers and check you can produce each from memory before reading the parent.

What does mean, and where does counting start?
The -value of point number ; counting starts at , so there are points .
What is and why does every formula divide by it?
, the interval width; slopes and curvatures are "change per unit width," so you must divide by the width.
Write the general cubic on one interval.
, with four coefficients.
Why one cubic per interval instead of a single high-degree polynomial?
A single high-degree polynomial oscillates (Runge phenomenon); per-interval cubics stay local and calm.
In plain words, what is ?
The slope — how steeply the curve rises or falls at that point.
In plain words, what is ?
The curvature — the bendiness, i.e. how fast the slope itself is changing.
What does continuity demand at each interior node?
Value, slope, and curvature all match from both sides — no kink and no curvature jump.
Define the moment .
, the spline's curvature exactly at node .
Why is the RHS a curvature estimate?
It is the difference of the two neighbouring average slopes — how much the slope changed across the node.
Why are we "2 short" and how is the gap filled?
unknown coefficients vs equations; the two missing facts are the boundary conditions (natural or clamped).
What does "tridiagonal" mean and why is it good news?
Nonzeros only on the main diagonal and its two neighbours; it solves quickly and stably via the Thomas algorithm.