Optimization Function Classes
B-Splines
A numerically stable basis for piecewise polynomials, defined by de Boor's recurrence. Local support, partition-of-unity, banded design matrices, and why every numerical spline implementation uses B-splines rather than the truncated-power basis.
Why This Matters
A piecewise polynomial of degree with interior knots has degrees of freedom. The natural way to parametrize it is the truncated-power basis , where . This basis is mathematically clean and numerically terrible: the columns of the design matrix are highly correlated (the powers are all nearly collinear on any interval, and the truncated powers add little independent information), the condition number scales exponentially in , and at the ordinary least squares system is unsolvable in double precision.
B-splines solve all of these problems with a different basis for the
same function space. Each B-spline basis function has
support on only adjacent intervals between knots. The design
matrix becomes banded with bandwidth . The condition number is
bounded by a constant depending only on the knot ratios, not on the
knot count. Every numerical spline implementation (R's splines::bs,
scipy's BSpline, the COBS package, every CAD/CAM system) uses
B-splines.
ESL 2nd ed. Appendix to Ch 5 (pp. 186-189) develops the B-spline construction. The canonical book-length treatment is de Boor's A Practical Guide to Splines (2001 revised edition).
Quick Version
| Property | Value |
|---|---|
| Basis size at degree with interior knots | |
| Support of | ( intervals) |
| Partition of unity | for in interior of knot range |
| Nonnegativity | |
| Continuity | at simple knots; at knots of multiplicity |
| de Boor recurrence | |
| Design matrix bandwidth | |
| Condition number | in knot count |
The recurrence is the source of every numerical algorithm in the family: evaluation, differentiation, knot insertion, knot removal. It is exact in finite-precision arithmetic and free of cancellation.
Formal Setup
B-Spline of Degree 0
Given an ordered knot sequence , the degree-0 B-spline at index is the indicator of the interval : The set partitions the knot range into disjoint indicators.
B-Spline of Degree k by de Boor Recurrence
For , define When the knot sequence has interior knots plus repeated boundary knots at each end (typical), the basis spans the space of piecewise polynomials of degree that are at every interior knot.
The recurrence is the operational definition. The closed-form B-spline involves divided differences of the truncated-power functions; the recurrence implements the divided-difference computation without catastrophic cancellation.
Properties
Partition of Unity for B-Splines
Statement
For in the support of the B-spline basis (the interior of the knot range after the boundary repetitions), Each is nonnegative.
Intuition
At degree 0 the basis functions are indicator functions of disjoint intervals, so their sum equals 1 inside the knot range. The recurrence preserves the partition-of-unity property because the two convex coefficients in add up to 1 for inside the relevant intervals (a routine check).
Partition of unity has a practical consequence: a constant function is exactly representable as with . A linear function is representable as because B-splines reproduce polynomials up to degree exactly when the control points are placed at the Greville abscissae .
Why It Matters
The partition-of-unity property is what makes B-spline fitting numerically benign. The basis functions are interpolants in disguise: the coefficient in is approximately equal to for smooth , so the system matrix is close to the identity rather than to a near-singular Vandermonde matrix.
Failure Mode
Partition of unity fails outside the boundary repetition padding. If the boundary knots are not repeated to multiplicity , the basis at the boundary is incomplete and near the endpoints. The fix is the boundary-padding convention: replicate the boundary knot extra times so the basis is complete throughout the knot range.
Optional Proofde Boor's evaluation algorithmShow
ESL 2nd ed. pp. 186-187 and de Boor (2001) Ch IX give the algorithm. To evaluate at a query point in the interval :
- Initialize for .
- For , compute for :
- Return .
The algorithm is regardless of the knot count, evaluates without explicit basis functions, and is numerically stable: every in finite-precision arithmetic, so each step is a convex combination and introduces no cancellation.
The same recursion gives derivatives: where . Higher derivatives chain naturally.
Regression Splines
Use the B-spline basis to fit a piecewise polynomial of degree to data : This is ordinary least squares with design matrix having entries . The design matrix is banded (each row has at most nonzero entries). Normal equations have a banded coefficient matrix and solve in .
Knot placement. The classic recipes:
- Equal spacing on quantiles of : ESL's default. Places knots so that roughly equal numbers of observations fall between adjacent knots.
- Equal spacing on : simpler, fine when the input distribution is roughly uniform.
- Adaptive (MARS, BARS): choose knots by forward stagewise or Bayesian search. See MARS.
The knot count controls model complexity. AIC, BIC, or cross-validation select it. A common heuristic: start with to and add knots until the residual sum of squares stops improving by a meaningful margin.
Why Truncated Powers Fail
The truncated-power basis at degree 3 with knots is The four powers are nearly linearly dependent on any bounded interval after standardization. The Vandermonde-like structure of has condition number exponential in degree. At degree 5 with 10 knots, the condition number exceeds in double precision and the linear solve returns nonsense.
B-splines fix this by replacing (a highly correlated local-redundancy basis) with (a local-support basis with constant condition number). Same function space, vastly better numerics. ESL 2nd ed. pp. 186-189 makes this explicit.
Implementation Notes
The standard implementations.
- R:
splines::bs(x, df = ...)constructs the B-spline design matrix with quantile knot placement. The companionsplines::ns(x, df = ...)produces a natural cubic spline basis (B-splines with boundary linear-extension constraints).mgcv::s()provides smoothing splines via reduced-rank B-spline bases. - Python:
scipy.interpolate.BSplinefor general B-splines;patsy.dmatrix("bs(x, df=...)")mirrors R's formula syntax.
For numerically demanding work (high , many knots), scipy.interpolate
implements the de Boor algorithm directly. The pybind-ed FORTRAN version
in splines runs at memory-bandwidth-bound speed.
Boundary knot repetition is the most common implementation pitfall: a careful library handles it automatically, but rolling your own basis construction requires explicit padding to multiplicity at each boundary. Without that the basis is rank-deficient near the endpoints.
Canonical Example
Cubic regression spline on a sinusoid
Generate from , . Fit a cubic regression spline with interior knots placed at equal quantiles.
| () | residual SD | shape | |
|---|---|---|---|
| 2 | 6 | 0.32 | smooth; underfit at peaks |
| 5 | 9 | 0.22 | close to optimal |
| 15 | 19 | 0.21 | tracks noise; slight overfit |
| 50 | 54 | 0.20 | obvious overfit |
5-fold CV picks or . AIC and BIC pick similar values. The B-spline design matrix at has columns; the linear solve still takes a few milliseconds because of the bandedness.
The same fit with a truncated-power basis at : condition number , OLS fails, ridge with a small penalty is required to make the system invertible. The fit is visually identical to the B-spline fit (same function space), but the numerics are an order of magnitude worse.
Common Confusions
B-splines are a basis, not a fitting method
"Fit a B-spline" is shorthand for "fit a piecewise polynomial regression using the B-spline basis". The basis choice is orthogonal to the estimator (OLS, ridge, lasso, smoothing penalty). Smoothing splines and regression splines both use B-splines; they differ in the penalty, not the basis.
The Greville abscissae are not knots
The knots define the basis. The Greville abscissae are weighted averages of consecutive knots and live "where the basis function lives" approximately. They are useful for control-point interpolation in graphics but they are not the breakpoints of the spline.
Knot multiplicity controls smoothness, not interpolation accuracy
Increasing the multiplicity of a knot from to reduces smoothness at from to . The function space becomes strictly larger; the design matrix gains extra columns near . Use multiplicity to introduce intentional kinks or jumps; do not use it to "improve" a smooth fit.
Exercises
Problem
Verify the de Boor recurrence for : starting from , compute explicitly and confirm it is the standard linear-tent basis function peaking at .
Problem
Show that for a uniform knot sequence and degree , the B-spline equals the -fold convolution of the indicator with itself. Hence relate B-splines to the densities of sums of independent uniform random variables.
Problem
Construct a B-spline basis on a sphere with locally adaptive knot density. Discuss the obstructions: there is no canonical "knot sequence" on a manifold, no canonical boundary, and the partition-of-unity property must be enforced by hand via a finite cover and a smooth partition.
References
Canonical:
- de Boor, C. (2001). A Practical Guide to Splines (revised ed.). Springer Applied Mathematical Sciences, vol. 27. The definitive reference; covers evaluation, knot insertion, B-spline arithmetic, and rigorous proofs.
- Hastie, Tibshirani, Friedman. The Elements of Statistical Learning, 2nd ed. Springer (2009). Ch 5 "Basis Expansions and Regularization", §5.2 "Piecewise Polynomials and Splines" (pp. 141-148), Appendix on B-splines (pp. 186-189). The statistical-learning view.
- Green, P. J. and Silverman, B. W. (1994). Nonparametric Regression and Generalized Linear Models. Chapman and Hall. Connects B-splines to the smoothing-spline penalty framework.
Foundational:
- Schoenberg, I. J. (1946). "Contributions to the Problem of Approximation of Equidistant Data by Analytic Functions." Quarterly of Applied Mathematics 4, 45-99, 112-141. Original B-spline construction (for uniform knots).
- Curry, H. B. and Schoenberg, I. J. (1966). "On Pólya Frequency Functions IV: The Fundamental Spline Functions and Their Limits." Journal d'Analyse Mathématique 17, 71-107. Non-uniform-knot extension.
Numerical analysis:
- Lyche, T. and Mørken, K. (2008). Spline Methods. University of Oslo lecture notes. Modern numerical treatment with linear-algebra emphasis.
- Piegl, L. and Tiller, W. (1997). The NURBS Book (2nd ed.). Springer. B-splines in the CAD/CAM setting; the standard reference for non-uniform rational B-splines and knot insertion.
Next Topics
- Smoothing splines: penalized regression with B-spline basis and a roughness penalty.
- Thin-plate splines: the multivariate generalization with a radial basis representation.
- Generalized additive models: use B-splines as per-coordinate basis functions in a backfitting framework.
- MARS: adaptive knot selection on B-spline-like bases.
Last reviewed: May 13, 2026
Canonical graph
Required before and derived from this topic
These links come from prerequisite edges in the curriculum graph. Editorial suggestions are shown here only when the target page also cites this page as a prerequisite.
Required prerequisites
3- Linear Regressionlayer 1 · tier 1
- Smoothing Splineslayer 2 · tier 1
- Functional Analysis Corelayer 0B · tier 2
Derived topics
0No published topic currently declares this as a prerequisite.