How to | Work with Spline Functions

The Wolfram Language's powerful spline functionality includes both numeric and symbolic support. Built-in basis polynomials and efficient spline construction provide a way to research the properties of splines as well as to perform various mathematical tasks using splines.

The Wolfram Language provides two spline bases, BSplineBasis and BernsteinBasis. Like other special functions, they can be evaluated with numerical values:

With Plot, you can visualize the basis functions:

The basis functions can be expanded by PiecewiseExpand to see their symbolic representation:

BSplineBasis supports detailed control over the basis functions. For instance, the following plot illustrates a family of uniform quadratic B-spline basis functions by varying the second argument from 0 to any positive integer:

A nonuniform B-spline basis can be represented by specifying a nondecreasing real sequence, called the knots. A knot sequence defines a set of B-splines. An individual basis can be specified by the second argument ranging from 0 to , where is the length of the knot sequence and is the degree of the B-spline:

    

The basis functions for higher dimensions can be generated by tensor products. This shows a uniform bicubic B-spline basis function:

    

B-spline manifolds, such as curves and surfaces, can be represented as a sum of products between B-spline basis functions and points in a range space. For example, a typical B-spline curve in 2D can be represented using Dot:

The curve can be illustrated by using ParametricPlot:

BSplineFunction provides a convenient and efficient way to represent the B-spline curve:

Similar to InterpolatingFunction, the result from BSplineFunction can be evaluated at a point on the given domain, or plotted using ParametricPlot:

The derivative of a BSplineFunction results in a BSplineFunction of one lesser degree. The following example draws tangent vectors on top of the B-spline curve using the derivative:

    

BSplineFunction can also represent B-spline surfaces, which can be specified by an array of 3D points. It can be plotted by using ParametricPlot3D:

The number of parameters can be given to BSplineFunction as the second argument. For example, this generates a bivariate B-spline function:

Since it is a function over , we can use Plot3D to display it: