Chapter 04
Hard

Piecewise Polynomials and Splines

00 · Symbol Glossary

$s$s — cubic spline

A function that is a cubic polynomial on each subinterval of a partition and belongs to C2C^{2} across the whole interval. Once end conditions are fixed, the interpolating ss is the unknown this chapter solves for. Read "ss" as "the spline."

$h_i$h sub i — mesh spacing

hi=xi+1−xih_i=x_{i+1}-x_i, the length of the iith subinterval. The mesh is uniform when every hih_i equals the same hh. The largest spacing is written h=max⁡ihih=\max_i h_i.

$\delta_i$delta sub i — secant slope

δi=(yi+1−yi)/hi\delta_i=(y_{i+1}-y_i)/h_i, the slope of the chord through consecutive data. Jumps δi−δi−1\delta_i-\delta_{i-1} are the right-hand side of the moment equations.

$M_i$M sub i — moment

Mi=s′′(xi)M_i=s''(x_i), the second derivative of the spline at a node. The vector of moments is the unknown in a tridiagonal linear system. On each subinterval, s′′s'' is the straight line joining MiM_i to Mi+1M_{i+1}.

$C^{k}$C to the k — continuity class

The functions on [a,b][a,b] whose derivatives through order kk exist and are continuous. C0C^{0} allows corners. C2C^{2} is the smoothness a cubic spline is built to have.

$p_n\in\mathcal{P}_n$p sub n in P sub n — global interpolant

Pn\mathcal{P}_n is Chapter 03's space of polynomials of degree at most nn. The element pnp_n is the unique member that matches n+1n+1 samples at distinct nodes. Read "p sub n in P sub n."

$\omega(x)$omega of x — nodal polynomial

Chapter 03's monic product ∏i=0n(x−xi)\prod_{i=0}^{n}(x-x_i). The pointwise error is f(n+1)(ξ) ω(x)/(n+1)!f^{(n+1)}(\xi)\,\omega(x)/(n+1)!. On one subinterval of length hih_i the same product is a power of hih_i.


01 · Where a Single Polynomial Breaks

Chapter 03 builds, for distinct nodes x0,…,xnx_0,\ldots,x_n, a unique interpolant pn∈Pnp_n\in\mathcal{P}_n, and proves

f(x)−pn(x)=f(n+1)(ξ)(n+1)! ω(x)f(x)-p_n(x)=\frac{f^{(n+1)}(\xi)}{(n+1)!}\,\omega(x)

whenever f(n+1)f^{(n+1)} is continuous on an interval containing xx and the nodes. The same chapter proves that the formula need not tend to zero. For

f(x)=11+25x2on[−1,1],f(x)=\frac{1}{1+25x^{2}}\qquad\text{on}\quad [-1,1],

with equispaced nodes xi=−1+2i/nx_i=-1+2i/n, the uniform error ∥f−pn∥∞\|f-p_n\|_\infty is unbounded as n→∞n\to\infty. The degree-44 interpolant is already the wrong sign inside the interval: p4(4/5)=−11/29p_4(4/5)=-11/29 while f(4/5)=1/17f(4/5)=1/17. The poles at ±i/5\pm i/5 make the high derivatives large, and the equispaced Lebesgue constant

Λn∼2n+1e nln⁡n\Lambda_n\sim\frac{2^{n+1}}{e\, n\ln n}

lets pnp_n leave a good comparison polynomial by an exponential factor. Weierstrass still supplies some sequence in Pn\mathcal{P}_n that converges to ff uniformly. The equispaced selection is the one that diverges.

The uniform errors below continue that example and set the clamped cubic spline of this chapter beside it, on the same nodes. Two significant figures are enough to see the split.

nnuniform error of pnp_nuniform error of the cubic spline
881.051.055.6×10−25.6\times 10^{-2}
161614143.7×10−33.7\times 10^{-3}
32325.1×1035.1\times 10^{3}6.6×10−46.6\times 10^{-4}

At n=32n=32 the polynomial is off by thousands where ff itself never exceeds 11. The spline error has dropped below 10−310^{-3}. Adding equispaced nodes makes pnp_n worse and the spline better.

The split is local flexibility instead of one stiff high-degree curve. Each subinterval of a spline carries its own cubic, so a large derivative near the middle is not forced into a single polynomial that then overshoots both ends. The equispaced pnp_n has no local piece: every coefficient participates at every xx.

Chapter 03's other lever moves the nodes. The zeros of Tn+1T_{n+1} are the Chebyshev nodes, the monic nodal polynomial there satisfies max⁡[−1,1]∣ω∣=2−n\max_{[-1,1]}|\omega|=2^{-n}, and the Lebesgue constant grows only like (2/π)ln⁡(n+1)(2/\pi)\ln(n+1). A comparison error that decays geometrically dominates that logarithm, so for this ff the Chebyshev interpolant converges. Those nodes are a choice. When the samples are required to stay where they were measured, the degree on each piece stays fixed and the mesh is what gets refined. That is the construction below. The local bounds in Section 02 are Chapter 03's error formula applied to one subinterval, where ω\omega is a power of the local spacing.

❌ What Breaks — Raising the degree on a fixed equispaced mesh

The error formula has (n+1)!(n+1)! in the denominator, so a higher degree is expected to win. For the Runge function above, the degree-88 interpolant already has uniform error about 11, and the degree-3232 interpolant has uniform error about 5×1035\times 10^{3}.

Where it breaks: Chapter 03's asymptotic for Λn\Lambda_n grows exponentially, and the table is that growth made numerical. The factorial in the error formula does not dominate this ff on these nodes.

Consequence: a plot that oscillates near the endpoints is not an under-resolved picture of a convergent sequence. The next equispaced degree is a larger oscillation. Convergence has to come from a different space, or from different nodes.


02 · Piecewise Polynomials

Fix a partition a=x0<x1<⋯<xn=ba=x_0\lt x_1\lt \cdots\lt x_n=b. A piecewise polynomial of degree at most dd is a function whose restriction to each [xi,xi+1][x_i,x_{i+1}] is a polynomial of degree at most dd. The pieces are independent until continuity requirements glue them. The picture is many short polynomials taped together at the knots: on each open subinterval the formula is an ordinary polynomial, and neighboring pieces meet, if they meet, only at the shared knot.

Definition — Continuity of derivatives

A function gg on [a,b][a,b] lies in CkC^{k} when g,g′,…,g(k)g,g',\ldots,g^{(k)} exist and are continuous on [a,b][a,b]. Matching values at the interior nodes puts a piecewise polynomial in C0C^{0}. Matching values and first derivatives puts it in C1C^{1}. Each extra derivative that is required to match is one linear condition per interior node, and it spends degrees of freedom that could otherwise have fitted the data.

Plain language: lying in CkC^{k} means the function and its first kk derivatives exist and do not jump. At a knot, C0C^{0} matches the value and C1C^{1} matches the value and the slope. C2C^{2} matches value, slope, and bend, where the bend is the second derivative. A corner is a joint that matched the value and missed the slope. Each extra match is one linear condition at that knot, paid for out of coefficients that could otherwise have fitted the data.

The piecewise-linear interpolant is the case d=1d=1 with only values matched. It lies in C0C^{0} and has a corner at each interior node, where the slope jumps from δi−1\delta_{i-1} to δi\delta_i. On a single subinterval the degree-11 case of Chapter 03's error formula gives, for some ξ\xi in that subinterval,

f(x)−ℓ(x)=f′′(ξ)2(x−xi)(x−xi+1).f(x)-\ell(x)=\frac{f''(\xi)}{2}(x-x_i)(x-x_{i+1}).

The quadratic factor (x−xi)(x−xi+1)(x-x_i)(x-x_{i+1}) has absolute value at most hi2/4h_i^{2}/4, so

∣f(x)−ℓ(x)∣≤18hi2 ∥f′′∥∞.|f(x)-\ell(x)|\leq \frac{1}{8}h_i^{2}\,\|f''\|_\infty.

The uniform error on the whole interval is O(h2)O(h^{2}) when f∈C2f\in C^{2} and h=max⁡hih=\max h_i. The power of hh is local: refining one subinterval improves the error on that subinterval, and the formula on a distant subinterval does not contain that node.

Degree 22 is a trap if the goal is C2C^{2}. A piecewise quadratic has 3n3n coefficients. Continuity of the function, the first derivative, and the second derivative at the n−1n-1 interior nodes imposes 3(n−1)3(n-1) conditions and leaves 3n−3(n−1)=33n-3(n-1)=3 free parameters. Those three parameters are exactly the global polynomials of degree at most 22: once s′′s'' is continuous and each piece has constant second derivative, s′′s'' is the same constant on every piece, and ss is one parabola. Every C2C^{2} piecewise quadratic on the partition is a single global quadratic. Cubics are the lowest degree at which C2C^{2} piecewise polynomials form a larger space than the global polynomials of that degree.

A cubic Hermite piece makes the local comparison precise. On [xi,xi+1][x_i,x_{i+1}], the unique cubic that matches ff and f′f' at both endpoints has error

f(x)−Hi(x)=f(4)(ξ)24(x−xi)2(x−xi+1)2,f(x)-H_i(x)=\frac{f^{(4)}(\xi)}{24}(x-x_i)^{2}(x-x_{i+1})^{2},

and (x−xi)2(x−xi+1)2≤hi4/16(x-x_i)^{2}(x-x_{i+1})^{2}\leq h_i^{4}/16, so the uniform error on the piece is at most hi4 ∥f(4)∥∞/384h_i^{4}\,\|f^{(4)}\|_\infty/384. That is an O(h4)O(h^{4}) bound, two orders past piecewise linear, and each piece is determined by its own endpoint data. The price is the derivatives f′(xi)f'(x_i) at every node. A cubic spline pays a different price: it asks only for values, plus two end conditions, and it recovers the interior derivatives from a linear system. The error constant grows from 1/3841/384 to 5/3845/384, which Section 06 records, and the power of hh stays 44 when the end conditions agree with ff.

Global dependence with local influence

Every moment of a cubic spline depends on every data value, because the linear system of Section 05 is irreducible: each interior row ties three consecutive moments, so the chain runs from the first subinterval to the last. The inverse of a strictly diagonally dominant tridiagonal matrix has entries that decay geometrically away from the diagonal. Changing yky_k moves MiM_i by a factor that shrinks geometrically in ∣i−k∣|i-k|. The coupling is global, and the influence of one sample is local. A global polynomial has no such decay: each Lagrange weight ℓi\ell_i is a degree-nn polynomial and feels every node at full strength.


03 · The Cubic Spline

Definition — Cubic spline interpolant

Let a=x0<⋯<xn=ba=x_0\lt \cdots\lt x_n=b and let y0,…,yny_0,\ldots,y_n be given. A cubic spline interpolant is a function ss such that

  • on each [xi,xi+1][x_i,x_{i+1}], ss coincides with a polynomial of degree at most 33;
  • s(xi)=yis(x_i)=y_i for every ii;
  • s∈C2[a,b]s\in C^{2}[a,b].

The third derivative is then piecewise constant, with a possible jump at each interior node. Two further scalar conditions, imposed at the ends, are required before ss is unique. Those conditions are the subject of Section 04.

Plain language: tape one cubic onto each gap between consecutive knots, force every piece through the given values, and require value, slope, and bend to match at each interior knot. That is a C2C^{2} piecewise cubic through the data. The third derivative is still allowed to jump. Two end numbers remain free, so many such curves fit the same points until Section 04 spends those two numbers.

The count that forces the two end conditions is worth doing in coefficients. There are nn subintervals and 44 coefficients on each, hence 4n4n unknowns.

  • Setting the left-hand and right-hand values on each subinterval equal to the prescribed data is 2n2n conditions. At an interior node both one-sided values are set equal to the same yiy_i, so ss is continuous there as soon as it interpolates.
  • Continuity of s′s' at the n−1n-1 interior nodes is n−1n-1 conditions.
  • Continuity of s′′s'' at those nodes is n−1n-1 conditions.

The total is 2n+2(n−1)=4n−22n+2(n-1)=4n-2. Two degrees of freedom remain, for any n≥1n\geq 1 and any strictly increasing nodes.

The same deficit appears from the other direction. The vector space of all C2C^{2} piecewise cubics on the partition, before interpolation, has dimension 4n−3(n−1)=n+34n-3(n-1)=n+3. Interpolation at n+1n+1 nodes imposes n+1n+1 linear conditions and leaves (n+3)−(n+1)=2(n+3)-(n+1)=2 parameters. Both counts are the statement that a cubic spline interpolant is a two-dimensional affine family until the ends are tied down.


04 · End Conditions

The two free parameters are fixed by two linear conditions. Three choices cover the cases used in analysis. Each one produces a square system for the moments, and the first two are the systems proved nonsingular in Section 05.

Definition — Natural, clamped, and not-a-knot ends
  • Natural. s′′(x0)=s′′(xn)=0s''(x_0)=s''(x_n)=0, that is M0=Mn=0M_0=M_n=0.
  • Clamped, also called complete. The end slopes are prescribed: s′(x0)=d0s'(x_0)=d_0 and s′(xn)=dns'(x_n)=d_n. When ss approximates a known ff, the accurate choice is d0=f′(a)d_0=f'(a) and dn=f′(b)d_n=f'(b).
  • Not-a-knot. The third derivative is required to be continuous at x1x_1 and at xn−1x_{n-1}. Equivalently (M1−M0)/h0=(M2−M1)/h1(M_1-M_0)/h_0=(M_2-M_1)/h_1 and (Mn−Mn−1)/hn−1=(Mn−1−Mn−2)/hn−2(M_n-M_{n-1})/h_{n-1}=(M_{n-1}-M_{n-2})/h_{n-2}. On a uniform mesh those relations are M0−2M1+M2=0M_0-2M_1+M_2=0 and Mn−2−2Mn−1+Mn=0M_{n-2}-2M_{n-1}+M_n=0.

Plain language: a natural end is zero bend at the ends, so s′′(a)=s′′(b)=0s''(a)=s''(b)=0. A clamped end is prescribed slopes at the ends: s′(a)s'(a) and s′(b)s'(b) are data you supply, and the accurate supply is f′(a)f'(a) and f′(b)f'(b) when those derivatives are known. Not-a-knot refuses a jump in the third derivative at the first and last interior knots, so each outer pair of pieces is one cubic rather than two.

The name "natural" is variational, and the identity is proved in Section 05. Among all C2C^{2} interpolants of the data, the natural spline minimizes ∫ab(g′′)2 dx\int_a^b (g'')^{2}\,dx. The boundary term produced by integration by parts vanishes exactly when g′′g'' vanishes at the endpoints, which is why those conditions, and no others, fall out of the unconstrained minimization. They are natural for the energy. They agree with a particular ff only when f′′(a)=f′′(b)=0f''(a)=f''(b)=0.

Clamped conditions are the ones that match a function whose end slopes are known. The cubic ff itself, restricted to the partition, is a clamped spline for its own values and its own end slopes. Uniqueness then says the clamped interpolant of a polynomial of degree at most 33 is that polynomial. Nothing similar holds for the natural spline and a quadratic: x2x^{2} has second derivative 22, which is not the natural boundary value 00.

Not-a-knot is the closure to use when end slopes are unknown and the energy boundary condition s′′=0s''=0 is unmotivated. Continuity of s′′′s''' at x1x_1 means the cubics on [x0,x1][x_0,x_1] and on [x1,x2][x_1,x_2] agree through order 33 at x1x_1. Their difference is a polynomial of degree at most 33 with a zero of order 44, so the difference is identically zero: one cubic covers [x0,x2][x_0,x_2]. The same reading applies at xn−1x_{n-1}. For f∈C4f\in C^{4} the not-a-knot interpolant has the same O(h4)O(h^{4}) uniform rate as the clamped interpolant. The diagonal-dominance proof in Section 05 covers the natural and clamped rows. The not-a-knot rows replace the two end equations; for distinct nodes that square system is nonsingular as well.

❌ What Breaks — Expecting every cubic spline to reproduce cubics

A polynomial of degree at most 33 is a cubic on each subinterval, interpolates itself, and lies in C2C^{2}. It is therefore some cubic spline interpolant. The natural end condition s′′(a)=s′′(b)=0s''(a)=s''(b)=0 selects a different member of that family whenever f′′(a)f''(a) or f′′(b)f''(b) is nonzero.

Where it breaks: uniqueness holds inside one set of end conditions. The cubic ff satisfies the clamped conditions with d0=f′(a)d_0=f'(a) and dn=f′(b)d_n=f'(b). It satisfies the natural conditions only when its second derivative already vanishes at both ends. On nodes 0,1/2,10,1/2,1, the natural interpolant of x2x^{2} has middle moment 33, while (x2)′′=2(x^{2})''=2. Exercise 4.3 computes that moment.

Consequence: reproduction of P3\mathcal{P}_3 is a theorem about the clamped spline with the true end slopes. A natural spline on curved data near the boundary leaves the end error that Section 06 measures as O(h2)O(h^{2}).


05 · The Moment System

On each subinterval, s′′s'' is linear, because ss is cubic, and s′′s'' is continuous, so the linear function is the interpolant of the endpoint moments:

s′′(x)=xi+1−xhiMi+x−xihiMi+1,x∈[xi,xi+1].s''(x)=\frac{x_{i+1}-x}{h_i}M_i+\frac{x-x_i}{h_i}M_{i+1},\qquad x\in[x_i,x_{i+1}].

Integrate twice. The two constants of integration are fixed by s(xi)=yis(x_i)=y_i and s(xi+1)=yi+1s(x_{i+1})=y_{i+1}. Differentiating the resulting formula and matching s′s' from the left and from the right at each interior node produces one equation in three consecutive moments. The algebra is the content of the next block; the equation it reaches is

hi−1Mi−1+2(hi−1+hi)Mi+hiMi+1=6(δi−δi−1),i=1,…,n−1.h_{i-1}M_{i-1}+2(h_{i-1}+h_i)M_i+h_i M_{i+1}=6(\delta_i-\delta_{i-1}),\qquad i=1,\ldots,n-1.

The row is tridiagonal because each interior knot only talks to its neighbors. At xix_i the unknowns are Mi−1M_{i-1}, MiM_i, and Mi+1M_{i+1}; every farther moment is absent from that equation. The chain still carries a message from the first subinterval to the last, one neighbor at a time. Section 02's note is the quantitative form of that relay: the coupling is global, and one sample's influence decays geometrically with distance.

Step-by-step — From a linear second derivative to a tridiagonal row
1

Integrate s′′s'' twice. An antiderivative of (xi+1−x)/hi(x_{i+1}-x)/h_i is −(xi+1−x)2/(2hi)-(x_{i+1}-x)^{2}/(2h_i), and an antiderivative of (x−xi)/hi(x-x_i)/h_i is (x−xi)2/(2hi)(x-x_i)^{2}/(2h_i). A second integration produces the cubic

s(x)=Mi(xi+1−x)36hi+Mi+1(x−xi)36hi+Ai(x−xi)+Bi.s(x)=M_i\frac{(x_{i+1}-x)^{3}}{6h_i}+M_{i+1}\frac{(x-x_i)^{3}}{6h_i}+A_i(x-x_i)+B_i.

The same two integrations give

s′(x)=−Mi(xi+1−x)22hi+Mi+1(x−xi)22hi+Ai.s'(x)=-M_i\frac{(x_{i+1}-x)^{2}}{2h_i}+M_{i+1}\frac{(x-x_i)^{2}}{2h_i}+A_i.
2

Fit AiA_i and BiB_i to the values. At x=xix=x_i the first cubic term equals Mihi2/6M_i h_i^{2}/6 and the second vanishes, so Bi=yi−Mihi2/6B_i=y_i-M_i h_i^{2}/6. At x=xi+1x=x_{i+1},

Ai=δi−hi6(Mi+1−Mi).A_i=\delta_i-\frac{h_i}{6}(M_{i+1}-M_i).

Every coefficient of ss on this subinterval is now an affine function of MiM_i and Mi+1M_{i+1}.

3

Read s′s' at the two ends of the subinterval. Substitute the expression for AiA_i. The endpoint evaluations collapse to

s′(xi)=δi−hi3Mi−hi6Mi+1,s'(x_i)=\delta_i-\frac{h_i}{3}M_i-\frac{h_i}{6}M_{i+1},
s′(xi+1)=δi+hi6Mi+hi3Mi+1.s'(x_{i+1})=\delta_i+\frac{h_i}{6}M_i+\frac{h_i}{3}M_{i+1}.

The coefficient −hi/3-h_i/3 on MiM_i at the left end is −hi/2+hi/6-h_i/2+h_i/6, the sum of the term coming from s′′s'' and the term coming from AiA_i.

4

Match one-sided derivatives at the interior node xix_i. The right-hand derivative on the previous subinterval, written from the second display with the index shifted down by one, equals the left-hand derivative on the current subinterval:

δi−1+hi−16Mi−1+hi−13Mi=δi−hi3Mi−hi6Mi+1.\delta_{i-1}+\frac{h_{i-1}}{6}M_{i-1}+\frac{h_{i-1}}{3}M_i=\delta_i-\frac{h_i}{3}M_i-\frac{h_i}{6}M_{i+1}.

Move the moments to the left and multiply through by 66. The coefficient of MiM_i becomes 2(hi−1+hi)2(h_{i-1}+h_i), and the displayed tridiagonal row follows.

The interior rows involve M0M_0 and MnM_n only in the first and last of them. End conditions replace those two moments, or add equations for them.

For a natural spline, M0=Mn=0M_0=M_n=0. The unknowns are M1,…,Mn−1M_1,\ldots,M_{n-1}, and the system is (n−1)×(n−1)(n-1)\times(n-1). The first row loses the M0M_0 term and the last row loses the MnM_n term.

For a clamped spline the end slopes determine two extra rows, now in the n+1n+1 unknowns M0,…,MnM_0,\ldots,M_n. From the formula for s′(x0)s'(x_0) on the first subinterval,

2h0M0+h0M1=6(δ0−d0).2h_0 M_0+h_0 M_1=6(\delta_0-d_0).

From the formula for s′(xn)s'(x_n) on the last subinterval,

hn−1Mn−1+2hn−1Mn=6(dn−δn−1).h_{n-1}M_{n-1}+2h_{n-1}M_n=6(d_n-\delta_{n-1}).

The interior rows are unchanged and now keep their M0M_0 and MnM_n terms. The system is (n+1)×(n+1)(n+1)\times(n+1).

On a uniform mesh, hi=hh_i=h for every ii, divide the interior row by hh and rewrite δi−δi−1=(yi+1−2yi+yi−1)/h\delta_i-\delta_{i-1}=(y_{i+1}-2y_i+y_{i-1})/h:

Mi−1+4Mi+Mi+1=6h2(yi+1−2yi+yi−1).M_{i-1}+4M_i+M_{i+1}=\frac{6}{h^{2}}(y_{i+1}-2y_i+y_{i-1}).

The coefficient pattern is 1,4,11,4,1. The right-hand side is six times the second difference of the data, divided by h2h^{2}. The values yiy_i enter the interior rows only through that second difference.

Practice — One unequal row

Take an interior node with hi−1=1h_{i-1}=1, hi=2h_i=2, and Mi−1,Mi,Mi+1M_{i-1},M_i,M_{i+1} still unknown. Write the numerical coefficients in the moment row, and check that the diagonal coefficient is strictly larger than the sum of the absolute values of the other two.

Example — Three nodes, natural, uniform

Take nodes 0,1,20,1,2 and values 0,1,00,1,0, with h=1h=1. Then M0=M2=0M_0=M_2=0, and the single interior equation is 4M1=6(0−2+0)=−124M_1=6(0-2+0)=-12, so M1=−3M_1=-3. The data rise and then fall, and the middle moment is negative: the spline is concave down at x=1x=1.

On [0,1][0,1], B0=0B_0=0 and A0=1−(1/6)(−3)=3/2A_0=1-(1/6)(-3)=3/2, so

s(x)=32x−12x3.s(x)=\frac{3}{2}x-\frac{1}{2}x^{3}.

On [1,2][1,2] the same constants produce the translated form

s(x)=1−32(x−1)2+12(x−1)3.s(x)=1-\frac{3}{2}(x-1)^{2}+\frac{1}{2}(x-1)^{3}.

Both formulas give s′(1)=0s'(1)=0, so the first derivative matches, and both give s′′(1)=−3s''(1)=-3. The unique polynomial of degree at most 22 through the same three points is p(x)=2x−x2p(x)=2x-x^{2}. At x=1/2x=1/2, s(1/2)=11/16s(1/2)=11/16 and p(1/2)=3/4=12/16p(1/2)=3/4=12/16. The two interpolants share the data and differ by 1/161/16 in the middle of the first subinterval, because p′′(x)=−2p''(x)=-2 while the natural condition forces s′′(0)=s′′(2)=0s''(0)=s''(2)=0. With only two subintervals, the end conditions are a large part of the whole set of constraints. The advantage in the Runge table appears when many subintervals share those same two conditions.

Proof — The moment matrix is nonsingular

Consider first the natural system, with rows i=1,…,n−1i=1,\ldots,n-1 in the unknowns M1,…,Mn−1M_1,\ldots,M_{n-1}. In row ii the diagonal entry is 2(hi−1+hi)2(h_{i-1}+h_i). The off-diagonal entries that are actually present are hi−1h_{i-1}, or hih_i, or both. Their absolute sum is at most hi−1+hih_{i-1}+h_i, which is strictly smaller than the diagonal because every spacing is positive. The matrix is strictly diagonally dominant.

Suppose Av=0A\mathbf{v}=\mathbf{0} and v≠0\mathbf{v}\neq\mathbf{0}. Scale so that ∣vk∣=max⁡j∣vj∣=1|v_k|=\max_j|v_j|=1. The kkth equation reads akkvk=−∑j≠kakjvja_{kk}v_k=-\sum_{j\neq k}a_{kj}v_j, hence

∣akk∣=∣akkvk∣≤∑j≠k∣akj∣ ∣vj∣≤∑j≠k∣akj∣<∣akk∣,|a_{kk}|=|a_{kk}v_k|\leq\sum_{j\neq k}|a_{kj}|\,|v_j|\leq\sum_{j\neq k}|a_{kj}|\lt |a_{kk}|,

which is impossible. Thus the only solution of the homogeneous system is zero, and the natural moment matrix is invertible. A solution (Mi)(M_i) exists and is unique. The formulas for AiA_i and BiB_i then determine ss on every subinterval.

For the clamped system the unknowns include M0M_0 and MnM_n. The first row has diagonal 2h02h_0 and a single off-diagonal entry h0h_0. The last row has diagonal 2hn−12h_{n-1} and a single off-diagonal entry hn−1h_{n-1}. Every interior row is the full three-term row, whose diagonal 2(hi−1+hi)2(h_{i-1}+h_i) strictly exceeds hi−1+hih_{i-1}+h_i. Strict diagonal dominance applies to every row, and the same argument gives uniqueness.

Proof — The natural spline minimizes bending energy

Let ss be the natural cubic spline interpolant, and let g∈C2[a,b]g\in C^{2}[a,b] be any other function with g(xi)=yig(x_i)=y_i for every ii. Set z=g−sz=g-s, so z(xi)=0z(x_i)=0. Expand

∫ab(g′′)2 dx=∫ab(s′′)2 dx+∫ab(z′′)2 dx+2∫abs′′z′′ dx.\int_a^b (g'')^{2}\,dx=\int_a^b(s'')^{2}\,dx+\int_a^b(z'')^{2}\,dx+2\int_a^b s''z''\,dx.

Integrate the cross term by parts on each subinterval. The piecewise-constant third derivative satisfies ∫xixi+1s′′′z′ dx=s′′′(z(xi+1)−z(xi))=0\int_{x_i}^{x_{i+1}} s''' z'\,dx=s'''\big(z(x_{i+1})-z(x_i)\big)=0. The boundary terms at interior nodes cancel because s′′s'' and z′z' are continuous: each interior node contributes s′′(xi)z′(xi)s''(x_i)z'(x_i) from the left piece and the negative of the same quantity from the right piece. The remaining ends are s′′(b)z′(b)−s′′(a)z′(a)=0s''(b)z'(b)-s''(a)z'(a)=0, because ss is natural. The cross term vanishes, and

∫ab(g′′)2 dx=∫ab(s′′)2 dx+∫ab(z′′)2 dx≥∫ab(s′′)2 dx.\int_a^b(g'')^{2}\,dx=\int_a^b(s'')^{2}\,dx+\int_a^b(z'')^{2}\,dx\geq\int_a^b(s'')^{2}\,dx.

Equality holds precisely when z′′≡0z''\equiv 0. Then zz is linear, and z(a)=z(b)=0z(a)=z(b)=0 forces z≡0z\equiv 0. So the minimizer is unique, and it is ss. The same expansion with a clamped spline uses z′(a)=z′(b)=0z'(a)=z'(b)=0 to kill the boundary term, and the clamped spline minimizes the energy among interpolants with those prescribed end slopes.

On a uniform mesh the natural matrix, after the division by hh that produces the pattern 1,4,11,4,1, is the symmetric Toeplitz matrix AA with 44 on the diagonal and 11 on the off-diagonals. If the system has m=n−1m=n-1 unknowns, the eigenvalues are

λk=4+2cos⁡kπm+1,k=1,…,m.\lambda_k=4+2\cos\frac{k\pi}{m+1},\qquad k=1,\ldots,m.

To see it, fix θ=kπ/(m+1)\theta=k\pi/(m+1) and set vj=sin⁡(jθ)v_j=\sin(j\theta) for j=1,…,mj=1,\ldots,m. The sine addition formula gives sin⁡((j−1)θ)+sin⁡((j+1)θ)=2sin⁡(jθ)cos⁡θ\sin((j-1)\theta)+\sin((j+1)\theta)=2\sin(j\theta)\cos\theta, so

vj−1+4vj+vj+1=(4+2cos⁡θ) vj.v_{j-1}+4v_j+v_{j+1}=(4+2\cos\theta)\,v_j.

The fictitious values v0=sin⁡0=0v_0=\sin 0=0 and vm+1=sin⁡(kπ)=0v_{m+1}=\sin(k\pi)=0 are exactly the missing neighbors at the two ends of AA, so Av=λkvA\mathbf{v}=\lambda_k\mathbf{v} with λk=4+2cos⁡θ\lambda_k=4+2\cos\theta. The angles kπ/(m+1)k\pi/(m+1) lie in (0,π)(0,\pi), and the cosine ranges through a proper subset of (−1,1)(-1,1). Every λk\lambda_k lies in (2,6)(2,6). The 22-norm condition number λmax⁡/λmin⁡\lambda_{\max}/\lambda_{\min} is therefore strictly less than 33, for every mm. A relative perturbation of the right-hand side moves the moment vector by a relative amount less than three times as large. The amplification stays bounded as nn grows.

What does grow as hh shrinks is the right-hand side itself. Absolute noise of size ε\varepsilon in the values yiy_i produces a second difference of size about ε\varepsilon, and the uniform equation divides by h2h^{2}. Moments inherit noise of size about ε/h2\varepsilon/h^{2}. That factor is the conditioning of a second derivative estimated from samples. Chapter 01 separates a well-conditioned map from a rounding error that a later operation can amplify; here the tridiagonal map stays well-conditioned, and the amplification sits in forming (δi−δi−1)/h(\delta_i-\delta_{i-1})/h. Chapter 05 studies that amplification for difference quotients directly.

The contrast with pnp_n is the monomial Vandermonde on equispaced nodes, whose 22-norm condition number grows exponentially with nn. Even before Runge's divergence of the function values, the coefficients of pnp_n in the monomial basis are an unstable encoding of the samples. The moment vector is a stable one. Stability of the encoding is a separate fact from smallness of ∥f−s∥∞\|f-s\|_\infty: a well-conditioned system can still be the exact system for a crude approximation. Section 06 is about the approximation.


06 · Error against a Global Polynomial

The local Hermite cubic of Section 02, which is allowed to use f′f' at every node, has uniform error at most h4 ∥f(4)∥∞/384h^{4}\,\|f^{(4)}\|_\infty/384. The clamped spline uses f′f' only at the two ends and determines every interior slope from the moment system. The classical bound, due to Hall and Meyer, says the loss is a factor 55 in the constant and nothing in the power of hh.

Theorem — Clamped cubic spline error

Let f∈C4[a,b]f\in C^{4}[a,b], let h=max⁡ihih=\max_i h_i, and let ss be the clamped cubic spline interpolant of ff at the nodes with s′(a)=f′(a)s'(a)=f'(a) and s′(b)=f′(b)s'(b)=f'(b). Then

∥f−s∥∞≤5384 h4 ∥f(4)∥∞.\|f-s\|_\infty\leq\frac{5}{384}\,h^{4}\,\|f^{(4)}\|_\infty.

The same smoothness gives ∥f(r)−s(r)∥∞=O(h4−r)\|f^{(r)}-s^{(r)}\|_\infty=O(h^{4-r}) for r=0,1,2r=0,1,2. In particular s′s' approximates f′f' to order h3h^{3}. Each differentiation of the error costs one power of hh.

Plain language: with the true end slopes, the widest gap hh controls the error, and the error is at most a fixed multiple of h4h^{4} times the size of f(4)f^{(4)}. Halving every spacing multiplies that bound by 1/161/16. The factor 55 in 5/3845/384 is the surcharge for recovering interior slopes from values alone; the Hermite cubic of Section 02, which is given those slopes, has constant 1/3841/384 and the same power of hh. Each derivative of the error costs one power of hh, so slopes are order h3h^{3} and bends are order h2h^{2}.

The constant is not proved here; the proof is a Peano-kernel comparison between ss and the piecewise Hermite cubic. The power h4h^{4} is the part the applications use. Halving every spacing multiplies the bound by 1/161/16. Extra smoothness past C4C^{4} does not raise the power. A cubic piece has a fourth derivative equal to zero, so the error expansion stops at the fourth derivative of ff. Analyticity improves the constant ∥f(4)∥∞\|f^{(4)}\|_\infty relative to a merely C4C^{4} function, and it does not turn O(h4)O(h^{4}) into a geometric rate. Geometric convergence requires the degree to grow, which is the global-polynomial regime, or it requires the spline degree itself to grow.

The natural end condition does not meet the hypotheses of the theorem unless f′′(a)=f′′(b)=0f''(a)=f''(b)=0. Forcing M0=0M_0=0 when f′′(a)f''(a) is a nonzero constant is an O(1)O(1) error in the second derivative at the endpoint. Integrated twice across a subinterval of length hh, an O(1)O(1) moment error becomes an O(h2)O(h^{2}) error in the function. The uniform norm sees that end layer, so the natural spline is O(h2)O(h^{2}) in general. On subintervals bounded away from the ends the influence of the wrong moment decays geometrically in the number of nodes, and the interior error returns to O(h4)O(h^{4}). If f′′(a)=f′′(b)=0f''(a)=f''(b)=0, the natural condition is the true one and the fourth-order bound is recovered.

Example — $e^{x}$ on $[0,1]$, two end conditions

Let f(x)=exf(x)=e^{x} on [0,1][0,1], so f′′=ff''=f and f′′(0)=1f''(0)=1, f′′(1)=ef''(1)=e, neither of which is zero. Uniform errors, two significant figures:

intervals nnnatural splineclamped spline
448.2×10−38.2\times 10^{-3}2.6×10−52.6\times 10^{-5}
882.1×10−32.1\times 10^{-3}1.7×10−61.7\times 10^{-6}
16165.2×10−45.2\times 10^{-4}1.1×10−71.1\times 10^{-7}
32321.3×10−41.3\times 10^{-4}6.7×10−96.7\times 10^{-9}

Doubling nn multiplies the natural error by about 1/41/4 and the clamped error by about 1/161/16. Those are the ratios of h2h^{2} and of h4h^{4}. At n=8n=8 the Hall–Meyer bound is (5/384)(1/8)4e≈8.6×10−6(5/384)(1/8)^{4}e\approx 8.6\times 10^{-6}, which sits above the clamped error 1.7×10−61.7\times 10^{-6}. The natural error at that same nn is about 2×10−32\times 10^{-3}, a hundred times larger than the clamped error, and its maximum lies next to the endpoint.

The companion function sin⁡(πx)\sin(\pi x) on [0,1][0,1] has second derivative −π2sin⁡(πx)-\pi^{2}\sin(\pi x), which vanishes at both ends. Its natural spline then drops by a factor about 1616 when nn goes from 1616 to 3232: the uniform errors are about 3.9×10−63.9\times 10^{-6} and 2.4×10−72.4\times 10^{-7}. The end condition decides the power of hh.

Put the two regimes next to each other. For the Runge function with equispaced nodes, Section 01 shows pnp_n diverging while the cubic-spline error falls below 10−310^{-3}. The clamped theorem supplies the fourth-power rate; for this ff the natural and clamped errors agree to the digits in the table, because the large fourth derivative sits in the interior and f′′(±1)f''(\pm 1) is only about 0.210.21. For exe^{x}, a global polynomial of modest degree is already an excellent uniform approximation: exe^{x} is entire, so equispaced interpolation on [0,1][0,1] converges geometrically, and a cubic spline remains O(h4)O(h^{4}). The spline is the accurate tool when the nodes are prescribed and numerous and the equispaced element of Pn\mathcal{P}_n is divergent. The global polynomial is the accurate tool when the degree may grow and either the nodes may be placed at the Chebyshev zeros or ff is entire, so that a geometric rate is available. Extra smoothness of ff, past C4C^{4}, leaves a cubic spline at the same power of hh.

Example — A discount function and the forward it induces

Let P(t)P(t) be a discount factor observed at maturities tit_i, and let ss interpolate those values. Wherever ss is nonzero and differentiable, the instantaneous forward is the logarithmic derivative

f(t)=−s′(t)s(t).f(t)=-\frac{s'(t)}{s(t)}.

Continuity of ff needs continuity of s′s'. A piecewise-linear interpolant of PP has jumps in slope at the maturities, so the forward jumps. A cubic spline lies in C2C^{2}, so s′s' lies in C1C^{1} and, on any subinterval where ss stays positive, the forward lies in C1C^{1}. The maturities are rarely equally spaced; the moment row of Section 05 is already written with unequal hih_i, and strict diagonal dominance did not require equality of the spacings.

The spline does not enforce s>0s\gt 0 or s′<0s'\lt 0. Positivity of discount factors and positivity of forwards are constraints on the data and on the end conditions, checked after the moments are known. The natural choice s′′(t0)=s′′(tn)=0s''(t_0)=s''(t_n)=0 is the energy boundary condition of Section 05. It is the right condition when that minimization is the one being solved, and it is the wrong match to a discount function whose end curvature is known to be something else. If the end slopes of PP are known, the clamped rows are the equations whose hypotheses agree with those slopes. The linear system is the same mathematics as the rest of the chapter.


07 · Exercises

EXERCISE 4.1

Count 44 coefficients on each of nn subintervals. Values contribute 22 conditions per subinterval. Each of s′s' and s′′s'' contributes one condition per interior node. The natural system drops M0M_0 and MnM_n; the clamped system keeps them and adds two rows.

There are 4n4n coefficients. Matching both endpoint values on every subinterval contributes 2n2n conditions and already forces continuity of ss at interior nodes. Continuity of s′s' contributes n−1n-1 conditions, and continuity of s′′s'' contributes n−1n-1 more. The sum is 4n−24n-2, so two conditions remain for the ends.

For n=5n=5 there are 2020 coefficients and 1818 conditions before the ends are fixed. The natural system is 4×44\times 4, in the unknowns M1,M2,M3,M4M_1,M_2,M_3,M_4. The clamped system is 6×66\times 6, in the unknowns M0,…,M5M_0,\ldots,M_5. The dimension count for the space of C2C^{2} piecewise cubics gives the same deficit: dimension n+3=8n+3=8, interpolation imposes n+1=6n+1=6 conditions, and 22 parameters remain.

For a cubic spline on nn subintervals, count the polynomial coefficients and the conditions coming from values, from continuity of the first derivative, and from continuity of the second derivative. How many conditions are left for the ends? For n=5n=5, state the sizes of the natural and the clamped moment systems.

EXERCISE 4.2

Spacings h0=1h_0=1 and h1=2h_1=2 give secants δ0=1\delta_0=1 and δ1=0\delta_1=0. The single natural equation is 2(h0+h1)M1=6(δ1−δ0)2(h_0+h_1)M_1=6(\delta_1-\delta_0). Then A0=δ0−(h0/6)(M1−M0)A_0=\delta_0-(h_0/6)(M_1-M_0) and B0=y0B_0=y_0.

M0=M2=0M_0=M_2=0 and 2(1+2)M1=6(0−1)2(1+2)M_1=6(0-1), so 6M1=−66M_1=-6 and M1=−1M_1=-1. On [0,1][0,1], B0=0B_0=0 and A0=1−(1/6)(−1)=7/6A_0=1-(1/6)(-1)=7/6, hence

s(x)=76x−16x3.s(x)=\frac{7}{6}x-\frac{1}{6}x^{3}.

This satisfies s(0)=0s(0)=0 and s(1)=1s(1)=1. The one-sided derivative formula at the right end of the first subinterval gives s′(1)=δ0+(h0/3)M1=1−1/3=2/3s'(1)=\delta_0+(h_0/3)M_1=1-1/3=2/3. On [1,3][1,3] one finds A1=−1/3A_1=-1/3 and B1=5/3B_1=5/3, and the left-end derivative formula on that piece also equals 2/32/3. The first derivative is continuous at x=1x=1. The diagonal coefficient 66 is strictly larger than 1+21+2, which is the dominance check for this single row, in agreement with the practice block.

Nodes 0,1,30,1,3 carry values 0,1,10,1,1. Find the natural moments and the formula for ss on [0,1][0,1]. Check that the two one-sided first derivatives at x=1x=1 agree.

EXERCISE 4.3

A linear function has second derivative 00, so it satisfies the natural end conditions and interpolates itself; uniqueness finishes the argument. For x2x^{2} use h=1/2h=1/2 in the uniform moment equation. For a cubic, compare end conditions with the clamped theorem's hypotheses and invoke uniqueness.

(a) If f(x)=α+βxf(x)=\alpha+\beta x, then f′′≡0f''\equiv 0, so ff is a natural cubic spline interpolant of its own samples (each piece is the same degree-11 polynomial, which is a cubic with leading coefficients zero). Section 05 proved there is only one natural interpolant, so s=fs=f.

(b) Nodes 0,1/2,10,1/2,1, values 0,1/4,10,1/4,1, and h=1/2h=1/2. Then 6/h2=246/h^{2}=24 and y0−2y1+y2=1/2y_0-2y_1+y_2=1/2, so the right-hand side is 1212. With M0=M2=0M_0=M_2=0 one gets 4M1=124M_1=12 and M1=3M_1=3. But f′′(1/2)=2f''(1/2)=2. The moments differ, so s≠fs\neq f. Equivalently, f′′(0)=2≠0f''(0)=2\neq 0, so ff itself violates the natural condition and cannot be the natural interpolant.

(c) Let f∈P3f\in\mathcal{P}_3, and let ss be the clamped interpolant with d0=f′(a)d_0=f'(a) and dn=f′(b)d_n=f'(b). Then ff satisfies every requirement in the definition of that clamped spline. Uniqueness forces s=fs=f. The natural end condition lies outside those requirements, which is why (b) can fail for a natural spline of a quadratic.

(a) Show that the natural cubic spline reproduces every polynomial of degree at most 11. (b) On the nodes 0,1/2,10,1/2,1, compute the natural middle moment of f(x)=x2f(x)=x^{2} and compare it with f′′(1/2)f''(1/2). (c) Show that the clamped cubic spline, given the true end slopes, reproduces every polynomial of degree at most 33.

EXERCISE 4.4

Replace hh by h/2h/2 in the Hall–Meyer bound. For exe^{x}, compare the natural ratio 2.1×10−3/5.2×10−42.1\times 10^{-3}/5.2\times 10^{-4} with 44 and with 1616, and check f′′(1)f''(1) against the natural condition. For Runge at 3232 equispaced nodes, read the two errors in Section 01. Geometric decay in the degree beats every fixed power of 1/n1/n; a cubic piece has vanishing fourth derivative, so the spline power stops at 44.

(a) (h/2)4=h4/16(h/2)^{4}=h^{4}/16, and ∥f(4)∥∞\|f^{(4)}\|_\infty does not depend on the mesh. The bound is multiplied by 1/161/16.

(b) The ratio is about 4.04.0, which is the factor for an O(h2)O(h^{2}) bound when hh is halved. Here f′′(1)=e≠0f''(1)=e\neq 0, so the natural condition Mn=0M_n=0 contradicts f′′f'' at the endpoint. The Hall–Meyer bound applies to the clamped spline with the true end slopes. This natural spline falls outside those hypotheses, and the table shows the slower rate.

(c) Chapter 03 gives the Chebyshev nodes a Lebesgue constant of size about (2/π)ln⁡(n+1)(2/\pi)\ln(n+1). For analytic ff on [−1,1][-1,1] there are comparison polynomials in Pn\mathcal{P}_n whose uniform error decays geometrically, and multiplication by 1+Λn1+\Lambda_n preserves a geometric rate. A clamped cubic spline on a mesh of nn subintervals remains O(h4)=O(n−4)O(h^{4})=O(n^{-4}), because each piece has degree 33 and the Hall–Meyer power stops at 44. A geometric sequence eventually lies under every constant times n−4n^{-4}. With nodes free to move, the Chebyshev interpolant is the method that keeps the geometric decay. Raising the piecewise degree is what a spline would need in order to join it.

(d) Section 01 records, at n=32n=32 equispaced nodes, a polynomial error of about 5.1×1035.1\times 10^{3} and a cubic-spline error of about 6.6×10−46.6\times 10^{-4}. The samples are fixed, so the Chebyshev option in (c) is unavailable. The spline is the accurate interpolant of these samples. The polynomial has left any neighborhood of ff.

(a) The clamped bound is (5/384) h4 ∥f(4)∥∞(5/384)\,h^{4}\,\|f^{(4)}\|_\infty. If every spacing is halved, by what factor does the bound change? (b) For exe^{x} on [0,1][0,1], the natural errors at 88 and 1616 intervals are about 2.1×10−32.1\times 10^{-3} and 5.2×10−45.2\times 10^{-4}. Which power of hh does that ratio indicate, and why do the hypotheses of the clamped theorem fail for this natural spline? (c) Nodes may be placed anywhere in [−1,1][-1,1], and ff is analytic there. Explain why a single polynomial at Chebyshev nodes can eventually beat every cubic spline on the uniform error, even though the spline's mesh is also allowed to be refined. (d) The 3232 nodes are required to be equispaced samples of the Runge function in Section 01. Which interpolant is accurate, and what are the two uniform errors?


08 · Summary

ObjectStatement
Equispaced pnp_n on Runge's ffuniform error grows with nn; good polynomials still exist
Piecewise linearC0C^{0}, corners at the nodes, uniform error O(h2)O(h^{2})
Why cubicsC2C^{2} piecewise quadratics are exactly the global quadratics
Cubic splineC2C^{2} piecewise cubics interpolating the data; two end conditions remain
Moment rowhi−1Mi−1+2(hi−1+hi)Mi+hiMi+1=6(δi−δi−1)h_{i-1}M_{i-1}+2(h_{i-1}+h_i)M_i+h_i M_{i+1}=6(\delta_i-\delta_{i-1})
Natural endsM0=Mn=0M_0=M_n=0; minimizes ∫(g′′)2\int(g'')^{2}; error O(h2)O(h^{2}) unless f′′f'' vanishes at the ends
Clamped endsprescribed end slopes; reproduces P3\mathcal{P}_3; error at most (5/384)h4∥f(4)∥∞(5/384)h^{4}\|f^{(4)}\|_\infty
Not-a-knots′′′s''' continuous at the first and last interior nodes; O(h4)O(h^{4}) for f∈C4f\in C^{4}
Uniform natural matrixeigenvalues 4+2cos⁡(kπ/(m+1))4+2\cos(k\pi/(m+1)) in (2,6)(2,6), so κ2<3\kappa_2\lt 3
Where the spline winsmany prescribed nodes, especially equispaced, and a C2C^{2} interpolant is wanted
Where pnp_n winsdegree may grow and nodes may cluster, so a geometric rate is available

The factor ε/h2\varepsilon/h^{2} in the moment right-hand side is a second derivative estimated from values. That estimation is differentiation, and its roundoff is the subject of the next chapter.

Next: Chapter 05 — Numerical Differentiation (coming soon). It builds difference quotients for f′f' and f′′f'' from values alone, and it balances their truncation against the rounding model of Chapter 01. The spline derivative s′s' is one such approximation, of order h3h^{3} when the clamped theorem applies, and the second-difference term 6(δi−δi−1)/h6(\delta_i-\delta_{i-1})/h in the uniform moment equation is a difference quotient already.