Applied Mathematical Analysis Spline Library

The AMA Spline Library is comprised of several functions for the computation and evaluation of polynomial spline approximations of univariate and multivariate data.

A polynomial spline is a function consisting of one or more polynomial functions defined over finite intervals and joined together at the intervals' endpoints with a varying degree of smoothness. Probably the most commonly known polynomial spline is the piecewise linear spline interpolant of univariate data illustrated in the left hand panel of Figure Univariate Linear Splines. It illustrates a linear spline consisting of five linear segments which interpolates six data points, shown as red squares, extracted from the function $y=x^2$. Also, along the horizontal axes the endpoints of the intervals over which the linear segments are defined, referred to as the spline's knots, are represented as orange squares. In this case the knots coincide with the independent variable values for the data; which is often, but not necessarily, the case with linear spline interpolants. Another example of a linear spline is shown in the center panel of Figure Univariate Linear Splines. As before, the spline consists of five linear segments defined over the same intervals as the interpolant, but the spline is a least squares approximation of several data points extracted from $y=x^2$. A comparison of the spline interpolant, shown in blue, and the least squares approximation, shown in green, is given in the right hand panel of the figure. It shows that even through the two splines are linear and are based on the same knots, they are different. So, essentially an univariate polynomial spline is specified by its degree and knots, but its behavior is determined by the amount and position of the data with respect to its knots and the approximation method employed to compute the spline.

Univariate Linear Splines
Univariate Interpolation Univariate Least Squares Comparison

The AMA Spline Library provides five methods for computing spline approximations of univariate data. Besides the least squares approximation and interpolation methods illustrated above, the library contains functions for approximation, monotonic approximation and monotonic interpolation. The knots must be specified for the the least squares approximation function, but the functions corresponding to the other four methods define the knots based on the data and the spline's degree. For all five methods the spline's degree can vary from linear through quintic. Increasing the spline's degree increases its smoothness. For example, consider the cubic spline interpolant and cubic spline least squares approximation illustrated in Figure Univariate Cubic Splines.

Univariate Cubic Splines
Univariate Interpolation Univariate Least Squares

They are based on the same knots and data as the linear splines of Figure Univariate Linear Splines and consist of five polynomial segments. However, unlike the linear spline which has a discontinuous derivative at the knots, the cubic spline's first derivative and second derivative are continuous. This results in a curve which is smoother at the knots as illustrated in the figure. In general, within the AMA Spline Library a spline of degree $d$ is continuous up to its $d-1$-th derivative at the knots. It should be noted that since the data lies upon the function $y=x^2$, the cubic least squares approximation interpolates the data. In general, this is not the case. Additional examples of univariate spline approximations are presented on Page Univariate Data Functions.

The AMA Spline Library employs multivariate polynomial splines to approximation and interpolate multivariate data. Analogous to the univariate polynomial spline, a multivariate polynomial spline is a function consisting of one or more multivariate polynomial functions defined over finite regions and joined together along the regions' boundaries with a varying degree of smoothness. The boundaries of the polynomial functions are defined by a rectilinear grid which is formed by knots in each of the the spline's independent variables. An example of a multivariate spline is illustrated in the left hand panel of Figure Bivariate Linear Splines. It shows a bivariate spline which consists of twenty-five bilinear functions which interpolate thirty-six data points, show as red spheres, extracted from the function $z=xy^2$. Also shown is the rectilinear grid, given as black curves superimposed on the surface, defined by the spline's knots. In this case the vertices of the grid coincide with the independent variable values for the data; which is often, but not necessarily, the case with bilinear spline interpolants. Another example of a bivariate linear spline is shown in the right hand panel of Figure Bivariate Linear Splines. As before, the spline consists of twenty-five bilinear functions defined over the regions, but the spline is a least squares approximation of several data points extracted from $z=xy^2$. Like the univariate spline, a multivariate spline is specified by its degree and knots, but its behavior is determined by the amount and position of the data with respect to the rectilinear grid defined by the knots and the approximation method employed to compute the spline.

Bivariate Linear Splines
Bivariate Interpolation Bivariate Least Squares

As is the case with univariate data the AMA Spline Library provides five methods for computing spline approximations of multivariate data. Besides the least squares approximation and interpolation methods illustrated above, the library contains multivariate functions for approximation, monotonic approximation and monotonic interpolation. Functions for the special case of multivariate gridded data are also provided. The knots must be specified in each independent variable for the least squares approximation function, but the functions corresponding to the other four methods define the knots based on the data and the spline's degree. The multivariate spline's degree can vary from linear to quintic in each of the spline's independent variables. Increasing the spline's degree increases its smoothness along the grid boundaries. See Multivariate Data Functions for additional examples of multivariate spline approximations.

The AMA Spline Library also contains functions for evaluating a spline, computing a spline's analytic partial and its indefinite integral, and for working with the AMA Spline Library spline structure. This family of spline evaluation and manipulation functions provides the ability to include the spline approximations computed by the univariate or multivariate approximation functions into other analysis programs. If necessary, functions which compute linear combinations of two splines, compute the scalar, dot or cross products of two splines, trim a spline to a subregion of its domain or extrapolate a spline can be included in the AMA Spline Library.

Finally, the AMA Spline Library contains functions for controlling its computational environment. These functions provide the means to disable and redirect error messages, to enable and redirect output generated by library functions and to override algorithm defaults for the univariate and multivariate approximation functions.

In summary, the AMA Spline Library consists of functions for approximating univariate and multivariate data; for evaluating an approximation, its partial derivatives and its integrals; and functions for maintaining the AMA Spline Library's environment. A list of all AMA Spline Library functions and links to their abstracts is given in AMA Spline Library Functions. Usage examples for the four class of functions available in the AMA Spline Library are presented on the following related pages:

All the approximation and interpolation functions provided in Univariate Data Functions and Multivariate Data Functions are examples of Constrained Spline Approximation.