Lecture Note 3: Polynomial Interpolation Xiaoqun Zhang Shanghai Jiao Tong University Last updated: October 24, 2013
1.1 Introduction We first look at some examples. Lookup table for f(x) = 2 π x 0 e x2 dx f(0.520) = 0.53790, f(0.521) = 0.53876 f(0.522) = 0.53962, f(0.523) = 0.54048 No f(0.52136) or f(0.52218). How should we do? Census of population: 1940 132165 1950 151326 1960 179323 1970 203302 1980 226542 1960 249633 There is no record for 1965. How to predict it? General questions: Let (x 0, y 0 ), (x 1, y 1 ),..., (x n, y n ) be given. Given a x which is not in {x 0, x 1,..., x n }, what is the corresponding y? Find a function f(x) such that y 0 = f(x 0 ), y 1 = f(x 1 ),..., y n = f(x n ). It s hard. There are too many functions. One solution is to use polynomials since polynomials have nice properties. Polynomial Interpolation: find a polynomial p(x) such that p(x 0 ) = y 0, p(x 1 ) = y 1,..., p(x n ) = y n 1.1.1 Existence and Uniqueness of polynomial interpolation Questions on polynomial interpolation: Does such a polynomial exist? Generally, you can not find a linear function to interpolate 3 points. If yes, what is the degree? 2 points, linear; 3 points, quadratic; 4 points cubic;... Is it unique? 2 points, linear; 3 points, quadratic; 4 points cubic;... What is a formula for producing p(x) from the given coordinates? 2 points, linear; 3 points, quadratic; 4 points cubic;... Given (x 0, y 0 ),..., (x n, y n ). 2
Polynomial representation p(x) = a 0 + a 1 x + a 2 x 2 +... + a m x m We want to find a 0, a 1,..., a m. m + 1 parameters, n + 1 conditions (p(x i ) = y i ) It is reasonable to try first with n = m. So we want to find a 0, a 1,..., a m such that a 0 + a 1 x 0 + a 2 x 2 0 +... + a n x n 0 = y 0 a 0 + a 1 x 1 + a 2 x 2 1 +... + a n x n 1 = y 1.. a 0 + a 1 x n + a 2 x 2 n +... + a n x n n = y n Write it into a system of linear equations 1 x 0 x 2 0... x n 0 a 0 y 0 1 x 1 x 2 1... x n 1 a 1 y 1 1 x 2 x 2 2... x n 2 a 2 = y 2..... 1 x n x 2 n... x n n a n y n X Vandermonde matrix. X a = y There exists a unique vector such that X a = y is equivalent to det(x) 0. Theorem 1 (Theorem 1.1) Given n + 1 distinct points x 0, x 1,..., x n and the corresponding y 0, y 1,..., y n, there is a polynomial p(x) of degree n such that p(x 0 ) = y 0, p(x 1 ) = y 1,..., p(x n ) = y n. This polynomial is unique among the set of all polynomials of degree n. Why degree n and not n? Why this set? Proof. We will prove that det(x) 0. Let 1 x 0 x 2 0... x n 0 1 x 1 x 2 1... x n 1 1 x 2 x 2 2... x n 2 V n (x) =... 1 x n 1 x 2 n 1... x n n 1 1 x x 2... x n 3
so that X = V n (x n ). We have the claims: 1. V n (x) is a polynomial of degree n. 2. The roots are x 0, x 1,..., x n 1. 3. The coefficients of the term x n is V n 1 (x n 1 ). Proof. 1. Expand the last row by minor. 2. If two row are the same then det(x) = 0. 3. Expand the last row by minor. So V n (x) = (x n 1 )(x x 0 )(x x 1 )... (x x n 1 )V n 1. By induction, [ ] 1 x0 V 1 (x 1 ) = det = (x 1 x 1 x 0 ) 1 V 2 (x 2 ) = (x 2 x 0 )(x 2 x 1 )(x 1 x 0 ) V 3 (x 3 ) = (x 3 x 0 )(x 3 x 1 )(x 3 x 2 )... V n (x n ) = Π 0 i<j n (x j x i ). Since x 0,..., x n are distinct, det(x) = V n (X n ) 0. 1.2 Lagrange Formula Find a polynomial P n (x) of order n passes through (x 0, y 0 ), (x 1, y 1 ), (x 2, y 2 ),... (x n, y n ). Method of undetermined coefficients: P n (x) = a 0 + a 1 x + a 2 x 2 +... + a n x n. Need to solve X a = y. Computational cost is high. Gaussian Elimination O(n 3 ). Find fast solvers of the linear equation or explicit expression of a. 4
Use bases other than {1, x, x 2,..., x n }. Two points case: (x 0, y 0 ), (x 1, y 1 ). Construct two linear functions (polynomials of order 1) L 1,0 (x) and L 1,1 (x) such that: L 1,0 (x 0 ) = 1 L 1,0 (x 1 ) = 0 and Then, let We have L 1,1 (x 0 ) = 0 L 1,1 (x 1 ) = 1. P 1 (x) = y 0 L 1,0 (x) + y 1 L 1,1 (x) P 1 (x 0 ) = y 0 L 1,0 (x 0 )+y 1 L 1,1 (x 0 ) = y 0 P 1 (x 1 ) = y 0 L 1,0 (x 1 )+y 1 L 1,1 (x 1 ) = y 1. Construct L 1,0 (x): L 1,0 (x) = x x 1 x 0 x 1 ; L 1,1 (x) = x x 0 x 1 x 0. Generalizing this idea to more points, we get Lagrange formula. Given (x 0, y 0 ), (x 1, y 1 ),... (x n, y n ). Construct polynomials L 0 (x), L 1 (x),..., L n (x) of order n such that L n,0 (x 0 ) = 1, L n,0 (x 1 ) = 0, L n,0 (x 2 ) = 0,... L n,0 (x n ) 0. L n,1 (x 0 ) = 0, L n,1 (x 1 ) = 1, L n,1 (x 2 ) = 0,... L n,1 (x n ) 0... L n,i (x i ) = 1, L n,i (x j ) = 0, j i. L n,n (x 0 ) = 0, L n,n (x 1 ) = 0,... L n,n (x n 1 ) = 0, L n,n (x n ) 1. Then construct P n (x) by n P n (x) = y i L n,i (x). i=0 We have P n (x i ) = y i. x 1, x 2,..., x n are the n roots of L n,0 (x), so L n,0 (x) = C(x x 1 )(x x 2 )... (x x n ), 5
where C is a constant. To find C, we use L n,0 (x 0 ) = 1. 1 = L n,0 (x 0 ) = C(x x 1 )(x x 2 )... (x x n ). So Therefore, C = 1 (x 0 x 1 )(x 0 x 2 )... (x 0 x n ) L n,0 (x) = (x x 1)(x x 2 )... (x x n ) (x 0 x 1 )(x 0 x 2 )... (x 0 x n ) = n j=1 (x x j) n j=1 (x 0 x j ) Similarly, n j=0,j i L n,i (x) = (x x j) n j=0,j i (x i x j ) Use a graph to illustrate it. Lagrange formula: Given (x 0, y 0 ), (x 1, y 1 ),..., (x n, y n ). Define n n j=0,j i P n (x) = y i (x x j) n j=0,j i (x i x j ). i=0 Example: x 0 = 1, x 1 = 2, x 2 = 4 and the correspondences y 0 = 8, y 1 = 1 and y 2 = 5. Find the polynomial p(x) of order 2 such that y 0 = p(x 0 ), y 1 = p(x 1 ), y 2 = p(x 2 ). (x 2)(x 4) P 2 (x) = 8 (1 2)(1 4) Drawbacks of Lagrange interpolation. 1. Given x, need O(n 2 ) to get P n (x). 1)(x 4) 1)(x 2) +1(x +5(x (2 1)(2 4) (4 1)(4 2) = 3x2 16x+21 2. No part of the previous calculation can be used. Interpolation for additional values of x requires the same amount of effort as the first value. 3. If we want to add a new point (x n+1, y n+1 ) or delete a point, all the basis L n,i (x) should be changed. 1.3 Neville s method Idea: use previous calculation and generate recursively Lagrange polynomial approximations. 6
Definition 1 Let f be a function defined at x 0, x 1,, x 2,, x n, and suppose that m 1, m 2,, m k are k distinct integers, with 0 m i n for each i. The Lagrange polynomial that agrees with f(x) at the k points x m1, x m2,, x mk is denoted P m1,,m k (x). Theorem 2 Let f be defined at x 0, x 1,, x k, and let x j and x i be two distinct numbers in this set. Then P (x) = (x x j)p 0,1,,j 1,j+1,,k (x) (x x i )P 0,1,,i 1,i+1,,k (x) x i x j describes the k-th Lagrange polynomial that interpolates f at the k + 1 points x 0, x 1,, x k. Algorithms INPUT: numbers x, x 0,, x n ; values f(x 0 ),, f(x n ) as the first column Q 0,0, Q 1,0,, Q n,0 of Q. OUTPUT: the table Q with P (x) = Q n,n. For i = 1, 2,, n for j = 1, 2,, i Output (Q). Stop. set Q i,j = (x xi j)qi,j 1 (x xi)qi 1,j 1 x i x j. 1.4 Newton s divided difference method of undetermined coefficient: bases {1, x, x 2,..., x n }. Expand P n (x) = a 0 + a 1 x + a 2 x 2 +... + a n x n. Need to solve a system linear equation to get a i. Each basis doesn t depend on given points. Lagrange: bases {L n,i (x)}, L i (x) are polynomials of degree n and L n,i (x) = L n,i (x i ) = 1, L n,i (x j ) = 0, j i. n j=0,j i (x xj) n j=0,j i (xi xj). The corresponding coefficient is y i. Each basis depends on x 0, x 1,..., x i 1, x i+1,..., x n. 7
Less flexibility when a new point (x i+1, y i+1 ) is added. Newton s divided difference Each basis depends on part of the given points. More flexibility when a new point (x i+1, y i+1 ) is added. Newton s divided difference: bases {1, x x 0, (x x 0 )(x x 1 ),..., (x x 0 )(x x 1 )... (x x n 1 )}. We assume P n (x) = c 0 +c 1 (x x 0 )+c 2 (x x 0 )(x x 1 )+...+c n (x x 0 )(x x 1 )... (x x n 1 ). We need to find c i. For c 0, Then, For c 1, So y 0 = P n (x 0 ) = c 0 = c 0 = y 0. P n (x) = y 0 + c 1 (x x 0 ) +... y 1 = P n (x 1 ) = y 0 + c 1 (x 1 x 0 ) c 1 = y 1 y 0 x 1 x 0 For c 2, y 2 = P n (x 2 ) = y 0 + c 1 (x 2 x 0 ) + c 2 (x 2 x 0 )(x 2 x 1 ) So c 2 = y 2 y 0 c 1 (x 2 x 0 ) (x 2 x 0 )(x 2 x 1 ) And so on. Example: (x 0, y 0 ) = (1, 8), (x 1, y 1 ) = (2, 1), (x 2, y 2 ) = (4, 5). c 0 = y 0 = 8. c 1 = (y 1 b 0 )/(x 1 x 0 ) = 7 c 2 = y 2 y 0 b 1 (x 2 x 0 ) (x 2 x 0 )(x 2 x 1 ) = 3. P n (x) = 8 7(x 1) + 3(x 1)(x 2) There exists a closed form for c i, i = 0,..., n. 8
Define f[x i ] = y i f[x i, x i+1 ] = f[x i+1] f[x i ] x i+1 x i f[x i, x i+1, x i+2 ] = f[x i+1, x i+2 ] f[x i, x i+1 ] x i+2 x i f[x i, x i+1, x i+2, x i+3 ] = f[x i+1, x i+2, x i+3 ] f[x i, x i+1, x i+2 ] x i+3 x i The prove will be delayed... c 0 = f[x 0 ] c 1 = f[x 0, x 1 ] c i = f[x 0, x 1,..., x i ] c n = f[x 0, x 1,..., x n ] divided difference table: x 1 f[x 1 ] f[x 1, x 2 ] x 2 f[x 2 ] f[x 1, x 2, x 3 ] f[x 2, x 3 ] f[x 1, x 2, x 3, x 4 ] x 3 f[x 3 ] f[x 2, x 3, x 4 ] f[x 1, x 2, x 3, x 4, x 5 ] f[x 3, x 4 ] f[x 2, x 3, x 4, x 5 ] x 4 f[x 4 ] f[x 3, x 4, x 5 ] f[x 4, x 5 ] x 5 f[x 5 ] Example: 1 8-7 2 1 3 2 4 5 Example: Give the example of interpolating f(x) = x on 2, 2.1, 2.2, 2.3, 2.4. 9
1.4.1 Newton s divided difference formula with equi-spaced nodes Let h = x i+1 x i, for each i = 0, 1,, n 1 and let x = x 0 + sh. Then the difference x x i = (s i)h. Thus the formula becomes where P n (x) =P n (x 0 + sh) = f[x 0 ] + shf[x 0, x 1 ] + s(s 1)h 2 f[x 0, x 1, x 2 ] + + s(s 1)(s n + 1)h n f[x 0, x 1,, x k ] n = s(s 1) (s k + 1)h k f[x 0, x 1,, x k ] k=0 =f[x 0 ] + n k=1 ( s k) f[x 0, x i,, x k ] ( ) s s(s 1) (s k + 1) = k k! is the generalized binomial coefficient notation. This formula (??) is called the Newton forward divided difference formula Using the notation as and in general f[x 0, x 1 ] = f(x 1) f(x 0 ) x 1 x 0 = 1 h f(x 0) f[x 0, x 1, x 2 ] = 1 δf(x 1 ) δf(x 0 ) = 1 2h x 1 x 0 2h 2 2 f(x 0 ) f[x 0, x 1,, x k ] = 1 k!h k k f(x 0 ) Newton forward difference formula P n (x) = f(x 0 ) + ( ) s n k f(x k 0 ) k=1 If the interpolating nodes are reordered, we can get the back divided difference formula and center-difference formula similarly. 1.4.2 Properties and Derivation of Newton s divided difference We recall Newton s divided difference formula: P n (x) = f[x 0 ] + f[x 0, x 1 ](x x 0 ) + f[x 0, x 1, x 2 ](x x 0 )(x x 1 )+... + f[x 0,..., x n ](x x 0 )(x x 1 )... (x x n 1 ) Note that adding a new point (x n+1, y n+1 ) we have to 10
add a new line in the divided difference table to get f[x 0,..., x n+1 ]. add a new term f[x 0,..., x n+1 ](x x 0 )(x x 1 )... (x x n ) into the expression of P n (x) to get P n+1. The derivation of Newton divided difference formula is given int he the following theorem Theorem 3 (Theorem 3.1) The unique polynomial of order n that passes through (x 0, y 0 ), (x 1, y 1 ),..., (x n, y n ) is given by P n (x) = f[x 0 ] + f[x 0, x 1 ](x x 0 ) + f[x 0, x 1, x 2 ](x x 0 )(x x 1 ) +... + f[x 0,..., x n ](x x 0 )(x x 1 )... (x x n 1 ) Proof. We prove it by induction. The unique polynomial of order 0 that passes through (x 0, y 0 ) is obviously P 0 (x) = y 0 = f[x 0 ]. is Suppose that the polynomial P k (x) of order k that passes through (x 0, y 0 ),(x 1, y 1 ),..., (x k, y k ) P k (x) = f[x 0 ] + f[x 0, x 1 ](x x 0 ) + f[x 0, x 1, x 2 ](x x 0 )(x x 1 )+... + f[x 0,..., x k ](x x 0 )(x x 1 )... (x x k 1 ) Write P k+1 (x), the unique polynomial of order k that passes through (x 0, y 0 ), (x 1, y 1 ),..., (x k, y k ), (x k+1, y k+1 ) by P k+1 (x) = f[x 0 ] + f[x 0, x 1 ](x x 0 ) + f[x 0, x 1, x 2 ](x x 0 )(x x 1 ) We only need to show that +... + f[x 0,..., x k ](x x 0 )(x x 1 )... (x x k 1 ) + C(x x 0 )(x x 1 )... (x x k 1 )(x x k ) C = f[x 0, x 1,..., x k, x k+1 ]. For this, let Q k (x) be the unique polynomial of order k that passes through (x 1, y 1 ),..., (x k, y k ), (x k+1, y k+1 ). Define R(x) = P k (x) + x x 0 x k+1 x 0 (Q k (x) P k (x)) Then, R(x) is a polynomial. The order of R(x) is k + 1. R(x 0 ) = P k (x 0 ) = y 0, R(x i ) = P k (x i )+ xi x0 x k+1 x 0 (Q k (x i ) P k (x i )) = P k (x i ) = y i, i = 1,..., k, R(x k+1 ) = Q k (x k+1 ) = y k+1 11
By the uniqueness, R(x) = P k+1 (x). The leading coefficient of P k+1 (x) is C. The leading coefficient of R(x) is the leading coefficient of which is x x 0 x k+1 x 0 (Q k (x) P k (x)), 1 x k+1 x 0 (leading coefficient of Q k (x) leading coefficient of P k (x)). On the other hand, the leading coefficient of Q k (x) is f[x 1,..., x k+1 ], and the leading coefficient of P k (x) is f[x 0,..., x k ]. So C = f[x 1,..., x k+1 ] f[x 0,..., x k ] x k+1 x 0 = f[x 0, x 1,..., x k+1 ] Note: f[x 0, x 1,..., x n ] is independent of the order of x 0,..., x n, since it is the leading coefficient of the polynomial P n (x). 1.4.3 Error Analysis of Polynomial interpolation We are given x 0, x 1,..., x n, and the corresponding function values f(x 0 ), f(x 1 ),..., f(x n ), but the we don t know the expression for the function. Let P n (x) be the polynomial of order n that passes through the n + 1 points (x 0, f(x 0 )), (x 1, f(x 1 )),..., (x n, f(x n )). Questions: What is the error between f(x) and P (x) even we don t know f(x) in advance? Lemma 1 Suppose that x 0, x 1,..., x m are distinct numbers. Let a = min i x i and b = max i x i. Suppose f C m [a, b]. Then, there exist ξ (a, b) such that f[x 0, x 1, x 2,..., x m ] = f (m) (ξ) m! Proof. Let P m (x) be the polynomial that passes through Then, the function has m + 1 zeros at x 0, x 1,..., x m. So, (x 0, f(x 0 )),..., (x m, f(x m )). f(x) P m (x) f (x) P m(x) has m zeros. has m 1 zeros, and so on. f (x) P m(x) f (m) (x) P m (m) (x) 12
has one zero. Denote that zero by ξ. f (m) (ξ) = P m (m) (ξ) P m (x) is a polynomial of order m. Therefore, P (m) m (x) = m!f[x 0,..., x m ] (Recall f[x 0,..., x m ] is the leading coefficient.) We get f (m) (ξ) = P (m) m (ξ) = m!f[x 0,..., x m ]. Theorem 4 Suppose that x 0, x 1,..., x n are distinct numbers in [a, b] and f C n+1 [a, b]. Let P n (x) be the unique polynomial of order n that passes through (x 0, f(x 0 )), (x 1, f(x 1 )),..., (x n, f(x n )) Then, such that x [a, b], ξ(x) (a, b) f(x) P n (x) = f (n+1) (ξ(x)) (x x 0 )(x x 1 )... (x x n ). (n + 1)! Proof. We use Newton s divided difference formula to prove it. You can also use Lagrange formula to prove it as shown in the book. If x = x i, i = 0,..., n, it obviously holds. For any z x i, i = 0,..., n, the polynomial of order n+1 that passes through is (x 0, f(x 0 )), (x 1, f(x 1 )),..., (x n, f(x n )), (z, f(z)) Q(x) =f[x 0 ] + f[x 0, x 1 ](x x 0 ) +... + f[x 0, x 1,..., x n ](x x 0 )(x x 1 )... (x x n 1 ) + f[x 0, x 1,..., x n, z](x x 0 )(x x 1 )... (x x n 1 )(x x n ) The polynomial Q(x) passes through (z, f(z)), so f(z) = Q(z) =f[x 0 ] + f[x 0, x 1 ](z x 0 ) +... + f[x 0, x 1,..., x n ](z x 0 )(z x 1 )... (z x n 1 ) + f[x 0, x 1,..., x n, z](z x 0 )(z x 1 )... (z x n 1 )(z x n ) Replace z by x, we get another expression for f(x) as f(x) =f[x 0 ] + f[x 0, x 1 ](x x 0 ) +... + f[x 0, x 1,..., x n ](x x 0 )(x x 1 )... (x x n 1 ) + f[x 0, x 1,..., x n, x](x x 0 )(x x 1 )... (x x n 1 )(x x n ) = P n (x) + f[x 0, x 1,..., x n, x](x x 0 )(x x 1 )... (x x n 1 )(x x n ). 13
By the lemma, there exists ξ (a, b) f[x 0, x 1,..., x n, x] = f (n+1) (ξ) (n + 1)!. So, f(x) = P n (x) + f (n+1) (ξ) (n + 1)! (x x 0)(x x 1 )... (x x n ) Note that the error is related to The maximum value of f (n+1) (x). This can be very large. (Runge Phenomenon) When x is out of [a, b], the error can be very large. (Interpolation vs extrapolation) 1.4.4 Runge Phenomenon Polynomial approximation may be very poor. 1 Example: f(x) = 1+25x on [ 1, 1]. It is in C. See the plot of f and the 2 interpolation polynomial P 12 (x) with 13 equispaced data in [ 1, 1]. We can see that Figure 1.1: Runge Pheonmenon 1. The error around 1 and 1 becomes larger and larger as n increases. P 12 (0.96) 3.5637, but f(0.96) 0.04. 14
2. The polynomial becomes more oscillating as n increases. This is called Runge s Phenomenon. In practice, the highest degree to be used is 3. Solution: piecewise interpolation (Hermit interpolation, spline interpolation), Chebyshev nodes (Gaussian quadrature). 1.5 Hermit interpolation Osculating polynomials generalize both Taylor polynomials and the Lagrange polynomials. Definition 2 (Osculating interpolation) Suppose that we are given n + 1 distinct numbers x 0, x 1, x n in [a, b] and nonnegative integers m 0, m 1,, m n, and m = max{m 0,, m n }. The osculating polynomial approximating a function f C m [a, b] at x i, for each i = 0,, n, is the polynomial of least degree such that for each i = 0,, n and k = 0,, m i. d k P (x i ) dx k = dk f(x i ) dx k If n = 0, the polynomial approximating f is m 0 -th Taylor polynomial for f at x 0. When m i = 0 for each i, the osculating polynomial is the n-th Lagrange polynomial interpolating f on x 0, x 1, x n. The case when m i = 1 for each i = 0, 1, n gives the Hermite polynomials: agree with f and f at x 0,, x n. Theorem 5 If f C 1 [a, b] and x 0,, x n [a, b] are distinct, the unique polynomial of degree at most 2n + 1 given by H 2n+1 (x) = n f(x j )H n,j (x) + j=0 n f (x j )Ĥn,j(x) where H n,j (x) = [1 2(x x j )L n,j ]L n,j(x) 2 and Ĥn,j(x) = (x x j )L,j (x) 2. In this context, L n,j denotes the j-th Lagrange coefficients polynomial. Moreover, if f C [ 2n + 2][a, b], then for some ξ with a < ξ < b. j=0 f(x) = H 2n+1 (x) + (x x 0) 2 (x x n ) 2 f (2n+2) (ξ) (2n + 2)! Scratch of proof: 1) show that H n,j (x i ) = δ ij and Ĥn,j(x i ) = 0 for any i, j. 2) Show that H n,j (x i) = 0 and Ĥ n,j (x i) = δ i,j. Although the above theorem provides a complete description of the Hermite polynomials, the computation is too tedious even for small n. Alternative method: use Newton divided difference formula. 15
1.5.1 Hermite interpolation by Newton divided difference Suppose that the distinct numbers (x i, f(x i ), f (x i )) for i = 0,, n are given. Procedure: Define a new sequence z 0, z 1, z 2n+1 by z 2i = z 2i+1 = x i, for each i = 0,, 1, n Compute first order divided difference for z i. Since z 2i = z 2i+1 = x i, f[z 2i, z 2i+1 ] is not defined. Instead, set f[z 2i, z 2i+1 ] = f (z 2i ) = f (x i )for each i = 0,, 1, n The remainning divided differences are produced as usual divided difference. The Hermite polynomial is given by 2n+1 H 2n+1 = f[z 0 ] + f[z 0,, z k ](x x 0 )(x z 1 ) (x z k 1 ) k=1 See divided difference table for n = 2. z f(z) 1st divided differences 2nd divided z 0 = x 0 f[z 0 ] = f(x 0 ) f[z 0, z 1 ] = f (x 0 ) z 1 = x 0 f[z 1 ] = f(x 0 ) f[z 0, z 1, z 2 ] = f[z1,z2] f[z0,z1] z 2 z 0 f[z 1, z 2 ] = f[z2] f[z1] z 2 z 1 z 2 = x 1 f[z 2 ] = f(x 1 ) f[z 1, z 2, z 3 ] = f[z2,z3] f[z1,z2] z 3 z 1 f[z 2, z 3 ] = f (x 1 ) z 3 = x 1 f[z 3 ] = f(x 1 ) f[z 2, z 3, z 4 ] = f[z3,z4] f[z2,z3] z 4 z 2 f[z 3, z 4 ] = f[z4] f[z3] z 4 z 3 z 4 = x 2 f[z 4 ] = f(x 2 ) f[z 3, z 4, z 5 ] = f[z4,z5] f[z3,z4] z 5 z 3 f[z 4, z 5 ] = f (x 2 ) z 5 = x 2 f[z 5 ] = f(x 2 ) 1.6 Cubic spline interpolation Oscillatory nature of high degree polynomial, and a fluctuation over a small portion can induce large error over the entire range, restricts their use. Alternative approach is to divide the interval into a collection of subintervals and construct different approximating polynomial on each subinterval. Approximation of this type is called piecewise-polynomial approximation. The most commmon piecewise polynomial approximation uses cubic polynomials between each successive pair of nodes and is called cubic spline interpolation. 16
Definition 3 Given a function f defined on [a, b] and a set of nodes a = x 0 < x 1 < < x n = b, a cubic spline interpolant S for f is a function that satisfies the following conditions S(x) a cubic polynomial, denotes S j (x), on the subinterval [x j, x j+1 for each j = 0, 1,, n 1. S j (x j ) = f(x j ) and S j (x j+1 ) = f(x j+1 ) for each j = 0, 1, n 1. S j+1 (x j+1 ) = S j (x j+1 ) for each j = 0, 1, n 2. S j+1 (x j+1) = S j (x j+1) for each j = 0, 1,, n 2 S j+1 (x j+1) = S j (x j+1) for each j = 0, 1,, n 2 One of the following sets of boundary conditions is satisfies : S (x 0 ) = S (x n ) = 0 (free or natural boundary) S (x 0 ) = f (x 0 ) and S (x n ) = f (x n ) (clamped boundary) Theorem 6 If f is defined at a = x 0 < x 1 < < x n = b, then f has a unique natural spline interpolant S on the nodes x 0, x 1,, x n. Theorem 7 If f is defined at a = x 0 < x 1 < < x n = b, then f has a unique clamped spline interpolant S on the nodes x 0, x 1,, x n. 17