Interpolation and Splines Anna Gryboś October 23, 27 1 Problem setting Many of physical phenomenona are described by the functions that we don t know exactly. Often we can calculate or measure the values of those functions or their derivatives for the given arguments. For example, we can measure position, velocity and acceleration of a moving object at the specified time points, hence we can gain a discrete information about the function f, i.e. for a given sequence of n distinct points x,..., x n called nodes of interpolation we obtain the sequence of values f(x i ) = y i, i =,..., n. From physical properties of the phenomenon, we may know approximately the behaviour of the function f, i.e. if it is polynomial, expotential, periodic, ect. Problem of interpolation consist of finding for the function f an approximation p within the fixed class of functions, in the way that they obtain the same values at the nodes, i.e. f(x i ) = p(x i ), i =,..., n (1) There are many ways to solve this problem, here we focus on a few of them: polynomial interpolation (Section 2) trigonometric interpolation (see Fast Fourier Transforms, Cooley-Tukey method) splines (Section 4) Let s note yet that for those classes of interpolating functions, storing the full information about the function (for example the coefficients of interpolating polynomial) does not require too much computer memory. Additionally, we can easily perform the operations on those functions like addition, multiplication, differentiation or integration. The latter property is important in particular for the applications (quadratures). 1
1 Sinus and its interpolant..8.6.4.2.2.4.6.8 1 1 2 3 4 6 7 Figure 1: Sinusoid function and its interpolating linear spline supported on six equidistant nodes (see Section 3.1). 2 Polynomial Interpolation 2.1 Vandermonde matrix Let s denote by P n the set of all real or complex polynomials P of degree not exceeding n: P (x) = a + a 1 x + a 2 x 2 +... + a n x n (2) To find the interpolating polynomial P we can substitute equation 1 into 2 and get a following system of linear equations in the coefficients a k. x n x n 1 x n 2... x 1 x n 1 x n 1 1 x1 n 2... x 1 1..... x n n x n 1 n xn n 2... x n 1 a n a n 1. a y y 1 =.. The square matrix on the left is commonly referred to as a Vandermonde matrix. Its determinant is nonzero, as we assumed that the nodes x,..., x n to be distinct, which proves the unisolvence theorem: there exists a unique interpolating polynomial P. y n 2.2 Lagrange Interpolation Theorem 1. For n+1 arbitrary nodes x,..., x n, x i x k, for i k and values y,..., y n there exists a unique polynomial P P n with P (x i ) = y i, i =, 1,..., n. We can construct the interpolating polynomial P explicitely with the help of Lagrange polynomials L i P n, i =, 1,..., n defined by: L i (x) = (x x ) (x x i 1 )(x x i+1 ) (x x n ) (x i x ) (x i x i 1 )(x i x i+1 ) (x i x n ) = ω(x) ω (x i )(x x i ) 2 (3)
with ω(x) = Π n i= (x x i). have the values L i (x k ) = δ ik. interpolation formula: At the nodes x,..., x n, the Lagrange polynomials defined that way Then the interpolating polynomial P can be expressed by Lagrange P (x) = 2.3 Error of approximation by interpolating polynomial n y i L i (x) (4) i= Let s consider a given function f(x) and its values in the nodes f(x i ) = y i, i =, 1,..., n. As we know, we can use the interpolating polynomial P supported on the nodes with the same values y i (see Equation 1) to approximate the function f(x). The error of approximation is estimated in the following theorem: Theorem 2. If the function f has an (n+1)st derivate, then for every argument x there exists a number ξ in the smallest interval I[x,..., x n, x] containing all nodes and x, satisfying: where ω(x) = Π n i= (x x i). f(x) P (x) = ω(x)f (n+1) (ξ) (n + 1)! When we denote by M n+1 = sup ξ I f (n+1) (ξ) then the error of approximation may be estimated by f(x) P (x) = M n+1 (n + 1)! ω(x) Example 1. Estimate the accuracy of calculating the value ln 1. with Lagrange interpolation formula, when the given values are: ln 1, ln 11, ln 12, ln 13. We have: f(x) = ln x, n = 3 and the nodes x = 1, x 3 = 13. As f (4) (x) = 6 x 4 hence M 4 = Following the Theorem 2, we obtain that ln(1.) P (1.) sup f (4) (x) = 6/1 4 x <1;13> 6 1 4.. 1. 2. 2.344 1 9 4! Remark 1. The degree of interpolating Lagrange polynomial P is strictly related to the amount of nodes x,..., x n, which makes the problems with high number of input data difficult to solve. Therefore, instead of interpolating the data by one polynomial, it is more applicable to divide the data into small groups, construct the interpolating polynomial P k in each group separately, then glue up the resulting interpolation polynomials P k into one function P. Such construction is realized by splines (see Section 3). Remark 2. Another problem with the polynomial interpolation with the polynomials of high degree is Runge s phenomenon. If the function f is interpolated at equidistant points x i in the interval [ 1, 1] with a polynomial P n (x) of degree n, the resulting interpolation oscillates near the ends of the 3
interval. It can even be proven that the interpolation error tends to infinity with increasing polynomial degree. The oscillation can be minimized by using Chebyshev nodes instead of equidistant nodes. In this case the maximum error is guaranteed to diminish with increasing polynomial order. The phenomenon demonstrates that high degree polynomials at equidistant nodes are generally unsuitable for interpolation. The problem can be avoided however by using splines again (see Section 3). 3 Splines In the one dimensional case, the splines are functions that are piecewiese polynomials associated with a partition of an interval [a, b] = {a = x < x 1 < < x n = b}. () The domain hence may be divided, as described above (Remark 1), into the smaller intervals, then on each subinterval an interpolating polynomial S i is constructed. The resulting spline function S is called a spline of order r or degree r 1 if, for each i =, 1,..., n 1, the restriction of S to the subinterval (x i, x i+1 ) agrees with a polynomial p i (x) of degree r 1. 3.1 Linear splines Linear spline interpolation is the simplest form of spline interpolation, the data points (x i, y i ) are graphically connected by straight lines (Fig.2). Algebraically, each S i for i =, 1,..., n is a linear function constructed as The spline must be continuous at each node, that is S i (x) = y i + y i+1 y i x i+1 x i (x x i ) (6) S i (x i ) = S i+1 (x i ), i = 1,... n 1 (7) This condition is satisfied as we can easily see: S i 1 (x i ) = y i 1 + y i y i 1 x i x i 1 (x i x i 1 ) = y i S i (x i ) = y i + y i+1 y i x i+1 x i (x i x i ) = y i This easy construction has however its disadvantages, the resulting linear spline S is usually not differentiable at the nodes x 1,..., x n 1. That s why the splines of higher order are used. 3.2 Cubic splines Definition 1. For a partition = {a = x < x 1 < < x n = b} of interval [a, b] a cubic spline is a real function S : [a, b] R with the properties: 4
3. 3 2. 2 1. 1... 1 1. 2 2. 3 3. Figure 2: Three data points (, 1), (1, 3), (3, 2) may be interpolated by the lines (linear splines) supported on intervals [, 1] and [1, 3] or by one parabol (cubic spline - see section 3.2). 1. S C 2 [a, b] 2. S coincides on every subinterval [x i, x i+1 ], i =, 1,... n 1 with a polynomial of degree three. 3. S satisfies the interpolation property S(x i ) = f(x i ), i = 1,... n 1 (see Equation 1). Thus the definition of cubic spline gives us the conditions for its construction. If S (x), x [x, x 1 ) S 1 (x), x [x 1, x 2 ) S(x) = S n 1 (x), x [x n 1, x n ] represents the spline function interpolating the function f, we require: the interpolating property S(x i ) = f(x i ) for i =,... n the splines to join up at nodes, S i 1 (x i ) = S i (x i ) for i = 1,... n 1 twice continuous differentiable, S i 1 (x i) = S i (x i), S i 1 (x i) = S i (x i) for i = 1,... n 1 However, an interpolating spline function S is not uniquely determined. We need to determine 4n conditions (since for one polynomial of degree three, there are four conditions on choosing the curve), while the definition gives 4n 2 conditions, there are still two degrees of freedom left. The following requirement may be considered resulting in the natural cubic spline. S (a) = S (b) =
4 B-splines B-spline are special piecewiese polynomial functions with following properties: they are nonnegative and vanish everywhere except on a few contiguous intervals [x i, x i+1 ]. Moreover, the function space S,k consisting of all splines of order k associated with the partition has a basis consisting of B-splines. Definition 2. Let χ A denote the characteristic function of a given set A. Then the nth-order B-spline B n (x) is defined inductively as follows: B n = B n 1 B 1 = B 1 (x) = χ [ 1 2, 1 2 ] 1 2 1 2 B n 1 (x t)dt signals spectra 1.2 B splines up to order 1 1 1 4 2 2 4 6 6 4 2 2 4 6.8 1.6 1 4 2 2 4 6 6 4 2 2 4 6 1.4 4 2 2 4 6 6 4 2 2 4 6 1.2 1 1 4 2 2 4 6 6 4 2 2 4 6.2 2 4 6 8 1 12 14 normalized so that they form a BUPU Figure 3: First four B-splines and their spectra on the left and B-splines up to order 1 on the right Theorem 3. Given n N, B-splines B n have the following properties: 1. If n 2, then B n C n 2 (R). 2. supp B n = [ n 2, n 2 ]. 3. B n (x) > for n 2 < x < n 2. 4. j B n(x j) = 1 for all x R.. B n(x)dx = 1. By the definition of the B-splines all the functions B n have support on a symmetric interval around zero. The translated spline N n (x) := T n 2 B n(x) = B n (x n 2 ) has support on the interval [, n]. The splines N n are called cardinal B-splines. Alternatively they can be defined inductively as the B-splines, starting with the function N 1 = χ [,1]. 6
4 6 8 1 12 14 B splines of first order B splines of second order.8.7.6..4.3.2.1.1 2 4 6 8 1 12 14 cubic B splines.7 B splines of fourth order.6..4.3.2.1 4 6 8 1 12 14.1 2 4 6 8 1 12 14 Figure 4: Normalized B-splines form a bounded uniform partition of unity (BUPU). The B-splines of first order in the upper left figure, B-splines of second order in upper right, cubic B-splines in lower left and finally B-splines of fourth order in lower right. Bibliography 1. Charles K. Chui, Multivariate splines, American Mathematical Society, 1988. 2. J. Stoer ; R. Bulirsch, Introduction to numerical analysis, Springer, 1993. 3. Wikipedia 7