In numerical analysis, a B-spline (short for basis spline) is a type of spline function designed to have minimal support (overlap) for a given degree, smoothness, and set of breakpoints (knots that partition its domain), making it a fundamental building block for all spline functions of that degree. A B-spline is defined as a piecewise polynomial of order , meaning a degree of . It is built from sections that meet at these knots, where the continuity of the function and its derivatives depends on how often each knot repeats (its multiplicity). Any spline function of a specific degree can be uniquely expressed as a linear combination of B-splines of that degree over the same knots, a property that makes them versatile in mathematical modeling. A special subtype, cardinal B-splines, uses equidistant knots.
The concept of B-splines traces back to the 19th century, when Nikolai Lobachevsky explored similar ideas at Kazan University in Russia,Farin, G. E. (2002). Curves and surfaces for CAGD: a practical guide. Morgan Kaufmann. p. 119. though the term "B-spline" was coined by Isaac Jacob Schoenbergde Boor, p. 114. in 1967, reflecting their role as basis functions.Gary D. Knott (2000), Interpolating cubic splines. Springer. p. 151.
B-splines are widely used in fields like computer-aided design (CAD) and computer graphics, where they shape curves and surfaces through a set of control points, as well as in data analysis for tasks like curve fitting and numerical differentiation of experimental data.
Definition
A B-spline of order is a collection of piecewise polynomial functions of degree in a variable . The values of where the pieces of polynomial meet are known as knots, denoted and sorted into nondecreasing order.
For a given sequence of knots, there is, up to a scaling factor, a unique spline satisfying
If we add the additional constraint that
for all between the knots and , then the scaling factor of becomes fixed. The knots in-between (and not including) and are called the internal knots.
B-splines can be constructed by means of the Cox–de Boor recursion formula. We start with the B-splines of degree , i.e. piecewise constant polynomials.
The higher -degree B-splines are defined by recursion
Properties
A B-spline function is a combination of flexible bands that is controlled by a number of points that are called control points, creating smooth curves. These functions are used to create and manage complex shapes and surfaces using a number of points. B-spline function and Bézier functions are applied extensively in shape optimization methods.
A B-spline of order is a piecewise polynomial function of degree in a variable . It is defined over locations , called knots or breakpoints, which must be in non-descending order . The B-spline contributes only in the range between the first and last of these knots and is zero elsewhere. If each knot is separated by the same distance (where ) from its predecessor, the knot vector and the corresponding B-splines are called "uniform" (see cardinal B-spline below).
For each finite knot interval where it is non-zero, a B-spline is a polynomial of degree . A B-spline is a continuous function at the knots.Strictly speaking, B-splines are usually defined as being left-continuous. When all knots belonging to the B-spline are distinct, its derivatives are also continuous up to the derivative of degree . If the knots are coincident at a given value of , the continuity of derivative order is reduced by 1 for each additional coincident knot. B-splines may share a subset of their knots, but two B-splines defined over exactly the same knots are identical. In other words, a B-spline is uniquely defined by its knots.
One distinguishes internal knots and end points. Internal knots cover the -domain one is interested in. Since a single B-spline already extends over knots, it follows that the internal knots need to be extended with endpoints on each side, to give full support to the first and last B-spline, which affect the internal knot intervals. The values of the endpoints do not matter, usually the first or last internal knot is just repeated.
The usefulness of B-splines lies in the fact that any spline function of order on a given set of knots can be expressed as a linear combination of B-splines:
B-splines play the role of basis functions for the spline function space, hence the name. This property follows from the fact that all pieces have the same continuity properties, within their individual range of support, at the knots.de Boor, p. 113.
Expressions for the polynomial pieces can be derived by means of the Cox–de Boor recursion formulade Boor, p 131.
That is, is piecewise constant one or zero indicating which knot span x is in (zero if knot span i is repeated). The recursion equation is in two parts:
ramps from zero to one as x goes from to , and
ramps from one to zero as x goes from to . The corresponding Bs are zero outside those respective ranges. For example, is a triangular function that is zero below , ramps to one at and back to zero at and beyond . However, because B-spline basis functions have local support, B-splines are typically computed by algorithms that do not need to evaluate basis functions where they are zero, such as de Boor's algorithm.
This relation leads directly to the FORTRAN-coded algorithm BSPLV, which generates values of the B-splines of order n at x.de Boor, p. 134. The following scheme illustrates how each piece of order n is a linear combination of the pieces of B-splines of order n − 1 to its left.
Application of the recursion formula with the knots at gives the piecewise components of the uniform B-spline of order 3
where
These pieces are shown in the diagram. The continuity property of a quadratic spline function and its first derivative at the internal knots are illustrated, as follows
The second derivative of a B-spline of degree 2 is discontinuous at the knots:
Faster variants of the de Boor algorithm have been proposed, but they suffer from comparatively lower stability.
Cardinal B-spline
A cardinal B-spline has a constant separation h between knots. The cardinal B-splines for a given order n are just shifted copies of each other. They can be obtained from the simpler definition.de Boor, p. 322.
The "placeholder" notation is used to indicate that the n-th divided difference of the function of the two variables t and x is to be taken by fixing x and considering as a function of t alone.
A cardinal B-spline has uniformly spaced knots, therefore interpolation between the knots equals convolution with a smoothing kernel.
Example, if we want to interpolate three values in between B-spline nodes (), we can write the signal as
Convolution of the signal with a rectangle function gives first order interpolated B-spline values. Second-order B-spline interpolation is convolution with a rectangle function twice ; by iterative filtering with a rectangle function, higher-order interpolation is obtained.
Fast B-spline interpolation on a uniform sample domain can be done by iterative mean-filtering. Alternatively, a rectangle function equals sinc in Fourier domain. Therefore, cubic spline interpolation equals multiplying the signal in Fourier domain with sinc4.
See Irwin–Hall distribution#Special cases for algebraic expressions for the cardinal B-splines of degree 1–4.
P-spline
The term P-spline stands for "penalized B-spline". It refers to using the B-spline representation where the coefficients are determined partly by the data to be fitted, and partly by an additional penalty function that aims to impose smoothness to avoid overfitting.Eilers, P. H. C. and Marx, B. D. (1996). Flexible smoothing with B-splines and penalties (with comments and rejoinder). Statistical Science 11(2): 89–121.
Two- and multidimensional P-spline approximations of data can use the face-splitting product of matrices to the minimization of calculation operations.
Derivative expressions The derivative of a B-spline of degree k is simply a function of B-splines of degree k − 1:de Boor, p. 115.
This implies that
which shows that there is a simple relationship between the derivative of a spline function and the B-splines of degree one less.
Moments of univariate B-splines
Univariate B-splines, i.e. B-splines where the knot positions lie in a single dimension, can be used to represent 1-d probability density functions . An example is a weighted sum of B-spline basis functions of order , which each are area-normalized to unity (i.e. not directly evaluated using the standard de-Boor algorithm)
and with normalization constant constraint . The k-th raw moment of a normalized B-spline can be written as Carlson's Dirichlet average , which in turn can be solved exactly via a contour integral and an iterative sum ) as
with
and . Here, represents a vector with the knot positions and a vector with the respective knot multiplicities. One can therefore calculate any moment of a probability density function represented by a sum of B-spline basis functions exactly, without resorting to numerical techniques.
Relationship to piecewise/composite Bézier A Bézier curve is also a polynomial curve definable using a recursion from lower-degree curves of the same class and encoded in terms of control points, but a key difference is that all terms in the recursion for a Bézier curve segment have the same domain of definition (usually ), whereas the supports of the two terms in the B-spline recursion are different (the outermost subintervals are not common). This means that a Bézier curve of degree given by control points consists of about mostly independent segments, whereas the B-spline with the same parameters smoothly transitions from subinterval to subinterval. To get something comparable from a Bézier curve, one would need to impose a smoothness condition on transitions between segments, resulting in some manner of Bézier spline (for which many control points would be determined by the smoothness requirement).
A piecewise/composite Bézier curve is a series of Bézier curves joined with at least continuity (the last point of one curve coincides with the starting point of the next curve). Depending on the application, additional smoothness requirements (such as or continuity) may be added. continuous curves have identical tangents at the breakpoint (where the two curves meet). continuous curves have identical curvature at the breakpoint.
Curve fitting Usually in curve fitting, a set of data points is fitted with a curve defined by some mathematical function. For example, common types of curve fitting use a polynomial or a set of exponential functions. When there is no theoretical basis for choosing a fitting function, the curve may be fitted with a spline function composed of a sum of B-splines, using the method of least squares.de Boor, Chapter XIV, p. 235.de Boor gives FORTRAN routines for least-squares fitting of experimental data. Thus, the objective function for least-squares minimization is, for a spline function of degree k,
where W(x) is a weight, and y(x) is the datum value at x. The coefficients are the parameters to be determined. The knot values may be fixed or treated as parameters.