# How to | Work with Spline Functions

*Mathematica*'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.

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

In[1]:= |

Out[1]= |

In[84]:= |

Out[84]= |

With Plot, you can visualize the basis functions:

In[3]:= |

Out[3]= |

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

In[42]:= |

Out[42]= |

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 to any positive integer:

In[4]:= |

Out[4]= |

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 to , where is the length of the knot sequence and is the degree of the B-spline:

In[5]:= |

Out[6]= |

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

In[7]:= |

Out[7]= |

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:

In[49]:= |

The curve can be illustrated by using ParametricPlot:

In[52]:= |

Out[52]= |

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

In[53]:= |

Out[53]= |

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

In[54]:= |

Out[54]= |

In[56]:= |

Out[56]= |

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:

In[57]:= |

Out[57]= |

In[71]:= |

Out[71]= |

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

In[72]:= |

Out[73]= |

In[75]:= |

Out[75]= |

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

In[82]:= |

Out[82]= |

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

In[83]:= |

Out[83]= |