Piecewise Polynomials and Splines
00 · Symbol Glossary
A function that is a cubic polynomial on each subinterval of a partition and belongs to across the whole interval. Once end conditions are fixed, the interpolating is the unknown this chapter solves for. Read "" as "the spline."
, the length of the th subinterval. The mesh is uniform when every equals the same . The largest spacing is written .
, the slope of the chord through consecutive data. Jumps are the right-hand side of the moment equations.
, the second derivative of the spline at a node. The vector of moments is the unknown in a tridiagonal linear system. On each subinterval, is the straight line joining to .
The functions on whose derivatives through order exist and are continuous. allows corners. is the smoothness a cubic spline is built to have.
is Chapter 03's space of polynomials of degree at most . The element is the unique member that matches samples at distinct nodes. Read "p sub n in P sub n."
Chapter 03's monic product . The pointwise error is . On one subinterval of length the same product is a power of .
01 · Where a Single Polynomial Breaks
Chapter 03 builds, for distinct nodes , a unique interpolant , and proves
whenever is continuous on an interval containing and the nodes. The same chapter proves that the formula need not tend to zero. For
with equispaced nodes , the uniform error is unbounded as . The degree- interpolant is already the wrong sign inside the interval: while . The poles at make the high derivatives large, and the equispaced Lebesgue constant
lets leave a good comparison polynomial by an exponential factor. Weierstrass still supplies some sequence in that converges to 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.
| uniform error of | uniform error of the cubic spline | |
|---|---|---|
At the polynomial is off by thousands where itself never exceeds . The spline error has dropped below . Adding equispaced nodes makes 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 has no local piece: every coefficient participates at every .
Chapter 03's other lever moves the nodes. The zeros of are the Chebyshev nodes, the monic nodal polynomial there satisfies , and the Lebesgue constant grows only like . A comparison error that decays geometrically dominates that logarithm, so for this 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 is a power of the local spacing.
The error formula has in the denominator, so a higher degree is expected to win. For the Runge function above, the degree- interpolant already has uniform error about , and the degree- interpolant has uniform error about .
Where it breaks: Chapter 03's asymptotic for grows exponentially, and the table is that growth made numerical. The factorial in the error formula does not dominate this 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 piecewise polynomial of degree at most is a function whose restriction to each is a polynomial of degree at most . 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.
A function on lies in when exist and are continuous on . Matching values at the interior nodes puts a piecewise polynomial in . Matching values and first derivatives puts it in . 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 means the function and its first derivatives exist and do not jump. At a knot, matches the value and matches the value and the slope. 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 with only values matched. It lies in and has a corner at each interior node, where the slope jumps from to . On a single subinterval the degree- case of Chapter 03's error formula gives, for some in that subinterval,
The quadratic factor has absolute value at most , so
The uniform error on the whole interval is when and . The power of is local: refining one subinterval improves the error on that subinterval, and the formula on a distant subinterval does not contain that node.
Degree is a trap if the goal is . A piecewise quadratic has coefficients. Continuity of the function, the first derivative, and the second derivative at the interior nodes imposes conditions and leaves free parameters. Those three parameters are exactly the global polynomials of degree at most : once is continuous and each piece has constant second derivative, is the same constant on every piece, and is one parabola. Every piecewise quadratic on the partition is a single global quadratic. Cubics are the lowest degree at which piecewise polynomials form a larger space than the global polynomials of that degree.
A cubic Hermite piece makes the local comparison precise. On , the unique cubic that matches and at both endpoints has error
and , so the uniform error on the piece is at most . That is an bound, two orders past piecewise linear, and each piece is determined by its own endpoint data. The price is the derivatives 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 to , which Section 06 records, and the power of stays when the end conditions agree with .
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 moves by a factor that shrinks geometrically in . The coupling is global, and the influence of one sample is local. A global polynomial has no such decay: each Lagrange weight is a degree- polynomial and feels every node at full strength.
03 · The Cubic Spline
Let and let be given. A cubic spline interpolant is a function such that
- on each , coincides with a polynomial of degree at most ;
- for every ;
- .
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 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 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 subintervals and coefficients on each, hence unknowns.
- Setting the left-hand and right-hand values on each subinterval equal to the prescribed data is conditions. At an interior node both one-sided values are set equal to the same , so is continuous there as soon as it interpolates.
- Continuity of at the interior nodes is conditions.
- Continuity of at those nodes is conditions.
The total is . Two degrees of freedom remain, for any and any strictly increasing nodes.
The same deficit appears from the other direction. The vector space of all piecewise cubics on the partition, before interpolation, has dimension . Interpolation at nodes imposes linear conditions and leaves 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.
- Natural. , that is .
- Clamped, also called complete. The end slopes are prescribed: and . When approximates a known , the accurate choice is and .
- Not-a-knot. The third derivative is required to be continuous at and at . Equivalently and . On a uniform mesh those relations are and .
Plain language: a natural end is zero bend at the ends, so . A clamped end is prescribed slopes at the ends: and are data you supply, and the accurate supply is and 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 interpolants of the data, the natural spline minimizes . The boundary term produced by integration by parts vanishes exactly when 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 only when .
Clamped conditions are the ones that match a function whose end slopes are known. The cubic 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 is that polynomial. Nothing similar holds for the natural spline and a quadratic: has second derivative , which is not the natural boundary value .
Not-a-knot is the closure to use when end slopes are unknown and the energy boundary condition is unmotivated. Continuity of at means the cubics on and on agree through order at . Their difference is a polynomial of degree at most with a zero of order , so the difference is identically zero: one cubic covers . The same reading applies at . For the not-a-knot interpolant has the same 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.
A polynomial of degree at most is a cubic on each subinterval, interpolates itself, and lies in . It is therefore some cubic spline interpolant. The natural end condition selects a different member of that family whenever or is nonzero.
Where it breaks: uniqueness holds inside one set of end conditions. The cubic satisfies the clamped conditions with and . It satisfies the natural conditions only when its second derivative already vanishes at both ends. On nodes , the natural interpolant of has middle moment , while . Exercise 4.3 computes that moment.
Consequence: reproduction of 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 .
05 · The Moment System
On each subinterval, is linear, because is cubic, and is continuous, so the linear function is the interpolant of the endpoint moments:
Integrate twice. The two constants of integration are fixed by and . Differentiating the resulting formula and matching 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
The row is tridiagonal because each interior knot only talks to its neighbors. At the unknowns are , , and ; 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.
Integrate twice. An antiderivative of is , and an antiderivative of is . A second integration produces the cubic
The same two integrations give
Fit and to the values. At the first cubic term equals and the second vanishes, so . At ,
Every coefficient of on this subinterval is now an affine function of and .
Read at the two ends of the subinterval. Substitute the expression for . The endpoint evaluations collapse to
The coefficient on at the left end is , the sum of the term coming from and the term coming from .
Match one-sided derivatives at the interior node . 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:
Move the moments to the left and multiply through by . The coefficient of becomes , and the displayed tridiagonal row follows.
The interior rows involve and only in the first and last of them. End conditions replace those two moments, or add equations for them.
For a natural spline, . The unknowns are , and the system is . The first row loses the term and the last row loses the term.
For a clamped spline the end slopes determine two extra rows, now in the unknowns . From the formula for on the first subinterval,
From the formula for on the last subinterval,
The interior rows are unchanged and now keep their and terms. The system is .
On a uniform mesh, for every , divide the interior row by and rewrite :
The coefficient pattern is . The right-hand side is six times the second difference of the data, divided by . The values enter the interior rows only through that second difference.
Take an interior node with , , and 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.
Take nodes and values , with . Then , and the single interior equation is , so . The data rise and then fall, and the middle moment is negative: the spline is concave down at .
On , and , so
On the same constants produce the translated form
Both formulas give , so the first derivative matches, and both give . The unique polynomial of degree at most through the same three points is . At , and . The two interpolants share the data and differ by in the middle of the first subinterval, because while the natural condition forces . 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.
Consider first the natural system, with rows in the unknowns . In row the diagonal entry is . The off-diagonal entries that are actually present are , or , or both. Their absolute sum is at most , which is strictly smaller than the diagonal because every spacing is positive. The matrix is strictly diagonally dominant.
Suppose and . Scale so that . The th equation reads , hence
which is impossible. Thus the only solution of the homogeneous system is zero, and the natural moment matrix is invertible. A solution exists and is unique. The formulas for and then determine on every subinterval.
For the clamped system the unknowns include and . The first row has diagonal and a single off-diagonal entry . The last row has diagonal and a single off-diagonal entry . Every interior row is the full three-term row, whose diagonal strictly exceeds . Strict diagonal dominance applies to every row, and the same argument gives uniqueness.
Let be the natural cubic spline interpolant, and let be any other function with for every . Set , so . Expand
Integrate the cross term by parts on each subinterval. The piecewise-constant third derivative satisfies . The boundary terms at interior nodes cancel because and are continuous: each interior node contributes from the left piece and the negative of the same quantity from the right piece. The remaining ends are , because is natural. The cross term vanishes, and
Equality holds precisely when . Then is linear, and forces . So the minimizer is unique, and it is . The same expansion with a clamped spline uses 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 that produces the pattern , is the symmetric Toeplitz matrix with on the diagonal and on the off-diagonals. If the system has unknowns, the eigenvalues are
To see it, fix and set for . The sine addition formula gives , so
The fictitious values and are exactly the missing neighbors at the two ends of , so with . The angles lie in , and the cosine ranges through a proper subset of . Every lies in . The -norm condition number is therefore strictly less than , for every . 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 grows.
What does grow as shrinks is the right-hand side itself. Absolute noise of size in the values produces a second difference of size about , and the uniform equation divides by . Moments inherit noise of size about . 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 . Chapter 05 studies that amplification for difference quotients directly.
The contrast with is the monomial Vandermonde on equispaced nodes, whose -norm condition number grows exponentially with . Even before Runge's divergence of the function values, the coefficients of 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 : 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 at every node, has uniform error at most . The clamped spline uses 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 in the constant and nothing in the power of .
Let , let , and let be the clamped cubic spline interpolant of at the nodes with and . Then
The same smoothness gives for . In particular approximates to order . Each differentiation of the error costs one power of .
Plain language: with the true end slopes, the widest gap controls the error, and the error is at most a fixed multiple of times the size of . Halving every spacing multiplies that bound by . The factor in is the surcharge for recovering interior slopes from values alone; the Hermite cubic of Section 02, which is given those slopes, has constant and the same power of . Each derivative of the error costs one power of , so slopes are order and bends are order .
The constant is not proved here; the proof is a Peano-kernel comparison between and the piecewise Hermite cubic. The power is the part the applications use. Halving every spacing multiplies the bound by . Extra smoothness past 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 . Analyticity improves the constant relative to a merely function, and it does not turn 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 . Forcing when is a nonzero constant is an error in the second derivative at the endpoint. Integrated twice across a subinterval of length , an moment error becomes an error in the function. The uniform norm sees that end layer, so the natural spline is 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 . If , the natural condition is the true one and the fourth-order bound is recovered.
Let on , so and , , neither of which is zero. Uniform errors, two significant figures:
| intervals | natural spline | clamped spline |
|---|---|---|
Doubling multiplies the natural error by about and the clamped error by about . Those are the ratios of and of . At the Hall–Meyer bound is , which sits above the clamped error . The natural error at that same is about , a hundred times larger than the clamped error, and its maximum lies next to the endpoint.
The companion function on has second derivative , which vanishes at both ends. Its natural spline then drops by a factor about when goes from to : the uniform errors are about and . The end condition decides the power of .
Put the two regimes next to each other. For the Runge function with equispaced nodes, Section 01 shows diverging while the cubic-spline error falls below . The clamped theorem supplies the fourth-power rate; for this the natural and clamped errors agree to the digits in the table, because the large fourth derivative sits in the interior and is only about . For , a global polynomial of modest degree is already an excellent uniform approximation: is entire, so equispaced interpolation on converges geometrically, and a cubic spline remains . The spline is the accurate tool when the nodes are prescribed and numerous and the equispaced element of 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 is entire, so that a geometric rate is available. Extra smoothness of , past , leaves a cubic spline at the same power of .
Let be a discount factor observed at maturities , and let interpolate those values. Wherever is nonzero and differentiable, the instantaneous forward is the logarithmic derivative
Continuity of needs continuity of . A piecewise-linear interpolant of has jumps in slope at the maturities, so the forward jumps. A cubic spline lies in , so lies in and, on any subinterval where stays positive, the forward lies in . The maturities are rarely equally spaced; the moment row of Section 05 is already written with unequal , and strict diagonal dominance did not require equality of the spacings.
The spline does not enforce or . 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 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 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
Count coefficients on each of subintervals. Values contribute conditions per subinterval. Each of and contributes one condition per interior node. The natural system drops and ; the clamped system keeps them and adds two rows.
There are coefficients. Matching both endpoint values on every subinterval contributes conditions and already forces continuity of at interior nodes. Continuity of contributes conditions, and continuity of contributes more. The sum is , so two conditions remain for the ends.
For there are coefficients and conditions before the ends are fixed. The natural system is , in the unknowns . The clamped system is , in the unknowns . The dimension count for the space of piecewise cubics gives the same deficit: dimension , interpolation imposes conditions, and parameters remain.
For a cubic spline on 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 , state the sizes of the natural and the clamped moment systems.
Spacings and give secants and . The single natural equation is . Then and .
and , so and . On , and , hence
This satisfies and . The one-sided derivative formula at the right end of the first subinterval gives . On one finds and , and the left-end derivative formula on that piece also equals . The first derivative is continuous at . The diagonal coefficient is strictly larger than , which is the dominance check for this single row, in agreement with the practice block.
Nodes carry values . Find the natural moments and the formula for on . Check that the two one-sided first derivatives at agree.
A linear function has second derivative , so it satisfies the natural end conditions and interpolates itself; uniqueness finishes the argument. For use in the uniform moment equation. For a cubic, compare end conditions with the clamped theorem's hypotheses and invoke uniqueness.
(a) If , then , so is a natural cubic spline interpolant of its own samples (each piece is the same degree- polynomial, which is a cubic with leading coefficients zero). Section 05 proved there is only one natural interpolant, so .
(b) Nodes , values , and . Then and , so the right-hand side is . With one gets and . But . The moments differ, so . Equivalently, , so itself violates the natural condition and cannot be the natural interpolant.
(c) Let , and let be the clamped interpolant with and . Then satisfies every requirement in the definition of that clamped spline. Uniqueness forces . 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 . (b) On the nodes , compute the natural middle moment of and compare it with . (c) Show that the clamped cubic spline, given the true end slopes, reproduces every polynomial of degree at most .
Replace by in the Hall–Meyer bound. For , compare the natural ratio with and with , and check against the natural condition. For Runge at equispaced nodes, read the two errors in Section 01. Geometric decay in the degree beats every fixed power of ; a cubic piece has vanishing fourth derivative, so the spline power stops at .
(a) , and does not depend on the mesh. The bound is multiplied by .
(b) The ratio is about , which is the factor for an bound when is halved. Here , so the natural condition contradicts 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 . For analytic on there are comparison polynomials in whose uniform error decays geometrically, and multiplication by preserves a geometric rate. A clamped cubic spline on a mesh of subintervals remains , because each piece has degree and the Hall–Meyer power stops at . A geometric sequence eventually lies under every constant times . 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 equispaced nodes, a polynomial error of about and a cubic-spline error of about . 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 .
(a) The clamped bound is . If every spacing is halved, by what factor does the bound change? (b) For on , the natural errors at and intervals are about and . Which power of 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 , and 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 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
| Object | Statement |
|---|---|
| Equispaced on Runge's | uniform error grows with ; good polynomials still exist |
| Piecewise linear | , corners at the nodes, uniform error |
| Why cubics | piecewise quadratics are exactly the global quadratics |
| Cubic spline | piecewise cubics interpolating the data; two end conditions remain |
| Moment row | |
| Natural ends | ; minimizes ; error unless vanishes at the ends |
| Clamped ends | prescribed end slopes; reproduces ; error at most |
| Not-a-knot | continuous at the first and last interior nodes; for |
| Uniform natural matrix | eigenvalues in , so |
| Where the spline wins | many prescribed nodes, especially equispaced, and a interpolant is wanted |
| Where wins | degree may grow and nodes may cluster, so a geometric rate is available |
The factor 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 and from values alone, and it balances their truncation against the rounding model of Chapter 01. The spline derivative is one such approximation, of order when the clamped theorem applies, and the second-difference term in the uniform moment equation is a difference quotient already.