Spline (mathematics)

Last updated
Single knots at 1/3 and 2/3 establish a spline of three cubic polynomials meeting with C parametric continuity. Triple knots at both ends of the interval ensure that the curve interpolates the end points Parametic Cubic Spline.svg
Single knots at 1/3 and 2/3 establish a spline of three cubic polynomials meeting with C parametric continuity. Triple knots at both ends of the interval ensure that the curve interpolates the end points

In mathematics, a spline is a function defined piecewise by polynomials. In interpolating problems, spline interpolation is often preferred to polynomial interpolation because it yields similar results, even when using low degree polynomials, while avoiding Runge's phenomenon for higher degrees.

Contents

In the computer science subfields of computer-aided design and computer graphics, the term spline more frequently refers to a piecewise polynomial (parametric) curve. Splines are popular curves in these subfields because of the simplicity of their construction, their ease and accuracy of evaluation, and their capacity to approximate complex shapes through curve fitting and interactive curve design.

The term spline comes from the flexible spline devices used by shipbuilders and draftsmen to draw smooth shapes.

Introduction

The term "spline" is used to refer to a wide class of functions that are used in applications requiring data interpolation and/or smoothing. The data may be either one-dimensional or multi-dimensional. Spline functions for interpolation are normally determined as the minimizers of suitable measures of roughness (for example integral squared curvature) subject to the interpolation constraints. Smoothing splines may be viewed as generalizations of interpolation splines where the functions are determined to minimize a weighted combination of the average squared approximation error over observed data and the roughness measure. For a number of meaningful definitions of the roughness measure, the spline functions are found to be finite dimensional in nature, which is the primary reason for their utility in computations and representation. For the rest of this section, we focus entirely on one-dimensional, polynomial splines and use the term "spline" in this restricted sense.

Definition

We begin by limiting our discussion to polynomials in one variable. In this case, a spline is a piecewise polynomial function. This function, call it S, takes values from an interval [a,b] and maps them to the set of real numbers,

We want S to be piecewise defined. To accomplish this, let the interval [a,b] be covered by k ordered, disjoint subintervals,

On each of these k "pieces" of [a,b], we want to define a polynomial, call it Pi.

On the ith subinterval of [a,b], S is defined by Pi,

The given k + 1 points ti are called knots. The vector t = (t0, …, tk) is called a knot vector for the spline. If the knots are equidistantly distributed in the interval [a,b] we say the spline is uniform, otherwise we say it is non-uniform.

If the polynomial pieces Pi each have degree at most n, then the spline is said to be of degreen (or of ordern + 1).

If in a neighborhood of ti, then the spline is said to be of smoothness (at least) at ti. That is, at ti the two polynomial pieces Pi–1 and Pi share common derivative values from the derivative of order 0 (the function value) up through the derivative of order ri (in other words, the two adjacent polynomial pieces connect with loss of smoothness of at most nri)

A vector r = (r1, …, rk–1) such that the spline has smoothness at ti for i = 1, …, k – 1 is called a smoothness vector for the spline.

Given a knot vector t, a degree n, and a smoothness vector r for t, one can consider the set of all splines of degree n having knot vector t and smoothness vector r. Equipped with the operation of adding two functions (pointwise addition) and taking real multiples of functions, this set becomes a real vector space. This spline space is commonly denoted by

In the mathematical study of polynomial splines the question of what happens when two knots, say ti and ti+1, are taken to approach one another and become coincident has an easy answer. The polynomial piece Pi(t) disappears, and the pieces Pi−1(t) and Pi+1(t) join with the sum of the smoothness losses for ti and ti+1. That is,

where ji = nri.

This leads to a more general understanding of a knot vector. The continuity loss at any point can be considered to be the result of multiple knots located at that point, and a spline type can be completely characterized by its degree n and its extended knot vector

where ti is repeated ji times for i = 1, …, k – 1.

A parametric curve on the interval [a,b]

is a spline curve if both X and Y are spline functions of the same degree with the same extended knot vectors on that interval.

Examples

Suppose the interval [a, b] is [0, 3] and the subintervals are [0, 1], [1, 2], [2, 3]. Suppose the polynomial pieces are to be of degree 2, and the pieces on [0, 1] and [1, 2] must join in value and first derivative (at t = 1) while the pieces on [1, 2] and [2, 3] join simply in value (at t = 2). This would define a type of spline S(t) for which

would be a member of that type, and also

would be a member of that type. (Note: while the polynomial piece 2t is not quadratic, the result is still called a quadratic spline. This demonstrates that the degree of a spline is the maximum degree of its polynomial parts.) The extended knot vector for this type of spline would be (0, 1, 2, 2, 3).

The simplest spline has degree 0. It is also called a step function. The next most simple spline has degree 1. It is also called a linear spline. A closed linear spline (i.e, the first knot and the last are the same) in the plane is just a polygon.

A common spline is the natural cubic spline. A cubic spline has degree 3 with continuity C2, i.e. the values and first and second derivatives are continuous. Natural means that the second derivatives of the spline polynomials are zero at the endpoints of the interval of interpolation.

Thus, the graph of the spline is a straight line outside of the interval, but still smooth.

Algorithm for computing natural cubic splines

Cubic splines are of the form

Given set of coordinates

we wish to find set of n splines Si(x) for i = 0, …, n – 1.

These must satisfy:

Let us define one cubic spline S as a 5-tuple (a, b , c, d, xt) where a, b, c, d correspond to coefficients in the form shown earlier and xt is equal to xj.

Algorithm for computing Natural Cubic Splines:
Input: set of coordinates C, with |C| = n + 1
Output: set splines which is composed of n 5-tuples.

  1. Create new array a of size n + 1 and for i = 0, …, n set
  2. Create new arrays b and d, each of size n.
  3. Create new array h of size n and for i = 0, …, n – 1 set
  4. Create new array α of size n and for i = 1, …, n – 1 set
  5. Create new arrays c, l, μ, z, each of size n + 1.
  6. Set
  7. For i = 1, …, n – 1 set the following:
  8. Set
  9. For j = n – 1, n – 2, …, 0, set the following:
  10. Create new set Splines and call it output_set. Populate it with n splines S.
  11. For i = 0, …, n – 1 set the following:
  12. Output output_set

C++ implementation:

#include<array>template<intn>std::array<std::array<float,5>,n>natural_cubic_splines_impl(conststd::array<float,n+1>&x,conststd::array<float,n+1>&y){std::array<float,n+1>a;for(inti=0;i<=n;i++)a[i]=y[i];std::array<float,n>b,d,h;for(inti=0;i<=n-1;i++)h[i]=x[i+1]-x[i];std::array<float,n>alpha;for(inti=1;i<=n-1;i++)alpha[i]=3.0f/h[i]*(a[i+1]-a[i])-3.0f/h[i-1]*(a[i]-a[i-1]);std::array<float,n+1>c,l,mu,z;l[0]=1,mu[0]=z[0]=0;for(inti=1;i<=n-1;i++){l[i]=2*(x[i+1]-x[i-1])-h[i-1]*mu[i-1];mu[i]=h[i]/l[i];z[i]=(alpha[i]-h[i-1]*z[i-1])/l[i];}l[n]=1,z[n]=c[n]=0;for(intj=n-1;j>=0;j--){c[j]=z[j]-mu[j]*c[j+1];b[j]=(a[j+1]-a[j])/h[j]-(h[j]*(c[j+1]+2*c[j]))/3.0f;d[j]=(c[j+1]-c[j])/(3.0f*h[j]);}std::array<std::array<float,5>,n>output_set;for(inti=0;i<=n-1;i++){output_set[i][0]=a[i];output_set[i][1]=b[i];output_set[i][2]=c[i];output_set[i][3]=d[i];output_set[i][4]=x[i];}returnoutput_set;}

Notes

It might be asked what meaning more than n multiple knots in a knot vector have, since this would lead to continuities like

at the location of this high multiplicity. By convention, any such situation indicates a simple discontinuity between the two adjacent polynomial pieces. This means that if a knot ti appears more than n + 1 times in an extended knot vector, all instances of it in excess of the (n + 1)th can be removed without changing the character of the spline, since all multiplicities n + 1, n + 2, n + 3, etc. have the same meaning. It is commonly assumed that any knot vector defining any type of spline has been culled in this fashion.

The classical spline type of degree n used in numerical analysis has continuity

which means that every two adjacent polynomial pieces meet in their value and first n 1 derivatives at each knot. The mathematical spline that most closely models the flat spline is a cubic (n = 3), twice continuously differentiable (C2), natural spline, which is a spline of this classical type with additional conditions imposed at endpoints a and b.

Another type of spline that is much used in graphics, for example in drawing programs such as Adobe Illustrator from Adobe Systems, has pieces that are cubic but has continuity only at most

This spline type is also used in PostScript as well as in the definition of some computer typographic fonts.

Many computer-aided design systems that are designed for high-end graphics and animation use extended knot vectors, for example Autodesk Maya. Computer-aided design systems often use an extended concept of a spline known as a Nonuniform rational B-spline (NURBS).

If sampled data from a function or a physical object is available, spline interpolation is an approach to creating a spline that approximates that data.

General expression for a C2 interpolating cubic spline

The general expression for the ith C2 interpolating cubic spline at a point x with the natural condition can be found using the formula

where

Representations and names

For a given interval [a,b] and a given extended knot vector on that interval, the splines of degree n form a vector space. Briefly this means that adding any two splines of a given type produces spline of that given type, and multiplying a spline of a given type by any constant produces a spline of that given type. The dimension of the space containing all splines of a certain type can be counted from the extended knot vector:

The dimension is equal to the sum of the degree plus the multiplicities

If a type of spline has additional linear conditions imposed upon it, then the resulting spline will lie in a subspace. The space of all natural cubic splines, for instance, is a subspace of the space of all cubic C2 splines.

The literature of splines is replete with names for special types of splines. These names have been associated with:

Often a special name was chosen for a type of spline satisfying two or more of the main items above. For example, the Hermite spline is a spline that is expressed using Hermite polynomials to represent each of the individual polynomial pieces. These are most often used with n = 3; that is, as Cubic Hermite splines. In this degree they may additionally be chosen to be only tangent-continuous (C1); which implies that all interior knots are double. Several methods have been invented to fit such splines to given data points; that is, to make them into interpolating splines, and to do so by estimating plausible tangent values where each two polynomial pieces meet (giving us Cardinal splines, Catmull-Rom splines, and Kochanek-Bartels splines, depending on the method used).

For each of the representations, some means of evaluation must be found so that values of the spline can be produced on demand. For those representations that express each individual polynomial piece Pi(t) in terms of some basis for the degree n polynomials, this is conceptually straightforward:

However, the evaluation and summation steps are often combined in clever ways. For example, Bernstein polynomials are a basis for polynomials that can be evaluated in linear combinations efficiently using special recurrence relations. This is the essence of De Casteljau's algorithm, which features in Bézier curves and Bézier splines).

For a representation that defines a spline as a linear combination of basis splines, however, something more sophisticated is needed. The de Boor algorithm is an efficient method for evaluating B-splines.

History

Before computers were used, numerical calculations were done by hand. Although piecewise-defined functions like the sign function or step function were used, polynomials were generally preferred because they were easier to work with. Through the advent of computers, splines have gained importance. They were first used as a replacement for polynomials in interpolation, then as a tool to construct smooth and flexible shapes in computer graphics.

It is commonly accepted that the first mathematical reference to splines is the 1946 paper by Schoenberg, which is probably the first place that the word "spline" is used in connection with smooth, piecewise polynomial approximation. However, the ideas have their roots in the aircraft and shipbuilding industries. In the foreword to (Bartels et al., 1987), Robin Forrest describes "lofting", a technique used in the British aircraft industry during World War II to construct templates for airplanes by passing thin wooden strips (called "splines") through points laid out on the floor of a large design loft, a technique borrowed from ship-hull design. For years the practice of ship design had employed models to design in the small. The successful design was then plotted on graph paper and the key points of the plot were re-plotted on larger graph paper to full size. The thin wooden strips provided an interpolation of the key points into smooth curves. The strips would be held in place at discrete points (called "ducks" by Forrest; Schoenberg used "dogs" or "rats") and between these points would assume shapes of minimum strain energy. According to Forrest, one possible impetus for a mathematical model for this process was the potential loss of the critical design components for an entire aircraft should the loft be hit by an enemy bomb. This gave rise to "conic lofting", which used conic sections to model the position of the curve between the ducks. Conic lofting was replaced by what we would call splines in the early 1960s based on work by J. C. Ferguson at Boeing and (somewhat later) by M.A. Sabin at British Aircraft Corporation.

The word "spline" was originally an East Anglian dialect word.

The use of splines for modeling automobile bodies seems to have several independent beginnings. Credit is claimed on behalf of de Casteljau at Citroën, Pierre Bézier at Renault, and Birkhoff, Garabedian, and de Boor at General Motors (see Birkhoff and de Boor, 1965), all for work occurring in the very early 1960s or late 1950s. At least one of de Casteljau's papers was published, but not widely, in 1959. De Boor's work at General Motors resulted in a number of papers being published in the early 1960s, including some of the fundamental work on B-splines.

Work was also being done at Pratt & Whitney Aircraft, where two of the authors of (Ahlberg et al., 1967) — the first book-length treatment of splines — were employed, and the David Taylor Model Basin, by Feodor Theilheimer. The work at General Motors is detailed nicely in (Birkhoff, 1990) and (Young, 1997). Davis (1997) summarizes some of this material.

Related Research Articles

<span class="mw-page-title-main">Bézier curve</span> Curve used in computer graphics and related fields

A Bézier curve is a parametric curve used in computer graphics and related fields. A set of discrete "control points" defines a smooth, continuous curve by means of a formula. Usually the curve is intended to approximate a real-world shape that otherwise has no mathematical representation or whose representation is unknown or too complicated. The Bézier curve is named after French engineer Pierre Bézier (1910–1999), who used it in the 1960s for designing curves for the bodywork of Renault cars. Other uses include the design of computer fonts and animation. Bézier curves can be combined to form a Bézier spline, or generalized to higher dimensions to form Bézier surfaces. The Bézier triangle is a special case of the latter.

<span class="mw-page-title-main">Interpolation</span> Method for estimating new data within known data points

In the mathematical field of numerical analysis, interpolation is a type of estimation, a method of constructing (finding) new data points based on the range of a discrete set of known data points.

<span class="mw-page-title-main">B-spline</span> Spline function

In the mathematical subfield of numerical analysis, a B-spline or basis spline is a spline function that has minimal support with respect to a given degree, smoothness, and domain partition. Any spline function of given degree can be expressed as a linear combination of B-splines of that degree. Cardinal B-splines have knots that are equidistant from each other. B-splines can be used for curve-fitting and numerical differentiation of experimental data.

In arithmetic and computer programming, the extended Euclidean algorithm is an extension to the Euclidean algorithm, and computes, in addition to the greatest common divisor (gcd) of integers a and b, also the coefficients of Bézout's identity, which are integers x and y such that

In numerical analysis, polynomial interpolation is the interpolation of a given bivariate data set by the polynomial of lowest possible degree that passes through the points of the dataset.

<span class="mw-page-title-main">Lagrange polynomial</span> Polynomials used for interpolation

In numerical analysis, the Lagrange interpolating polynomial is the unique polynomial of lowest degree that interpolates a given set of data.

In mathematics, in particular in algebraic topology, differential geometry and algebraic geometry, the Chern classes are characteristic classes associated with complex vector bundles. They have since become fundamental concepts in many branches of mathematics and physics, such as string theory, Chern–Simons theory, knot theory, Gromov–Witten invariants. Chern classes were introduced by Shiing-Shen Chern.

<span class="mw-page-title-main">Non-uniform rational B-spline</span> Method of representing curves and surfaces in computer graphics

Non-uniform rational basis spline (NURBS) is a mathematical model using basis splines (B-splines) that is commonly used in computer graphics for representing curves and surfaces. It offers great flexibility and precision for handling both analytic and modeled shapes. It is a type of curve modeling, as opposed to polygonal modeling or digital sculpting. NURBS curves are commonly used in computer-aided design (CAD), manufacturing (CAM), and engineering (CAE). They are part of numerous industry-wide standards, such as IGES, STEP, ACIS, and PHIGS. Tools for creating and editing NURBS surfaces are found in various 3D graphics, rendering, and animation software packages.

In the mathematical subfield of numerical analysis, de Boor's algorithm is a polynomial-time and numerically stable algorithm for evaluating spline curves in B-spline form. It is a generalization of de Casteljau's algorithm for Bézier curves. The algorithm was devised by German-American mathematician Carl R. de Boor. Simplified, potentially faster variants of the de Boor algorithm have been created but they suffer from comparatively lower stability.

In the mathematical field of numerical analysis, spline interpolation is a form of interpolation where the interpolant is a special type of piecewise polynomial called a spline. That is, instead of fitting a single, high-degree polynomial to all of the values at once, spline interpolation fits low-degree polynomials to small subsets of the values, for example, fitting nine cubic polynomials between each of the pairs of ten points, instead of fitting a single degree-nine polynomial to all of them. Spline interpolation is often preferred over polynomial interpolation because the interpolation error can be made small even when using low-degree polynomials for the spline. Spline interpolation also avoids the problem of Runge's phenomenon, in which oscillation can occur between points when interpolating using high-degree polynomials.

In numerical analysis, a cubic Hermite spline or cubic Hermite interpolator is a spline where each piece is a third-degree polynomial specified in Hermite form, that is, by its values and first derivatives at the end points of the corresponding domain interval.

In mathematics, trigonometric interpolation is interpolation with trigonometric polynomials. Interpolation is the process of finding a function which goes through some given data points. For trigonometric interpolation, this function has to be a trigonometric polynomial, that is, a sum of sines and cosines of given periods. This form is especially suited for interpolation of periodic functions.

<span class="mw-page-title-main">Interior-point method</span> Algorithms for solving convex optimization problems

Interior-point methods are algorithms for solving linear and non-linear convex optimization problems. IPMs combine two advantages of previously-known algorithms:

In mathematics, the Lebesgue constants (depending on a set of nodes and of its size) give an idea of how good the interpolant of a function (at the given nodes) is in comparison with the best polynomial approximation of the function (the degree of the polynomials are fixed). The Lebesgue constant for polynomials of degree at most n and for the set of n + 1 nodes T is generally denoted by Λn(T ). These constants are named after Henri Lebesgue.

In applied mathematics, polyharmonic splines are used for function approximation and data interpolation. They are very useful for interpolating and fitting scattered data in many dimensions. Special cases include thin plate splines and natural cubic splines in one dimension.

In the mathematical field of numerical analysis, monotone cubic interpolation is a variant of cubic interpolation that preserves monotonicity of the data set being interpolated.

In numerical analysis, multivariate interpolation is interpolation on functions of more than one variable ; when the variates are spatial coordinates, it is also known as spatial interpolation.

Isogeometric analysis is a computational approach that offers the possibility of integrating finite element analysis (FEA) into conventional NURBS-based CAD design tools. Currently, it is necessary to convert data between CAD and FEA packages to analyse new designs during development, a difficult task since the two computational geometric approaches are different. Isogeometric analysis employs complex NURBS geometry in the FEA application directly. This allows models to be designed, tested and adjusted in one go, using a common data set.

In the mathematical field of numerical analysis, discrete spline interpolation is a form of interpolation where the interpolant is a special type of piecewise polynomial called a discrete spline. A discrete spline is a piecewise polynomial such that its central differences are continuous at the knots whereas a spline is a piecewise polynomial such that its derivatives are continuous at the knots. Discrete cubic splines are discrete splines where the central differences of orders 0, 1, and 2 are required to be continuous.

In applied mathematics, an Akima spline is a type of non-smoothing spline that gives good fits to curves where the second derivative is rapidly varying. The Akima spline was published by Hiroshi Akima in 1970 from Akima's pursuit of a cubic spline curve that would appear more natural and smooth, akin to an intuitively hand-drawn curve. The Akima spline has become the algorithm of choice for several computer graphics applications. Its advantage over the cubic spline curve is its stability with respect to outliers.

References

Theory

Excel Function

Online utilities

Computer Code