Chapter 3 Interpolation and Polynomial Approximation Per-Olof Persson persson@berkeley.edu Department of Mathematics University of California, Berkeley Math 128A Numerical Analysis
Polynomial Interpolation Polynomials Polynomials P n (x) = a x x n + a 1 x + a 0 are commonly used for interpolation or approximation of functions Benefits include efficient methods, simple differentiation, and simple integration Also, Weierstrass Approximation Theorem says that for each ε > 0, there is a P (x) such that f(x) p(x) < ε for all x in [a, b] for f C[a, b]. In other words, polynomials are good at approximating general functions.
The Lagrange Polynomial Theorem If x 0,..., x n distinct and f given at these numbers, a unique polynomial P (x) of degree n exists with f(x k ) = P (x k ), for each k = 0, 1,..., n The polynomial is P (x) = f(x 0 )L n,0 (x) +... + f(x n )L n,n (x) = where n f(x k )L n,k (x) k=0 (x x 0 )(x x 1 ) (x x k 1 )(x x k+1 ) (x x n ) L n,k (x) = (x k x 0 )(x k x 1 ) (x k x k 1 )(x k x k+1 ) (x k x n ) = (x x i ) (x k x i ) i k
Lagrange Polynomial Error Term Theorem x 0,..., x n distinct in [a, b], f C n+1 [a, b], then for x [a, b] there exists ξ(x) in (a, b) with f(x) = P (x) + f (n+1) (ξ(x)) (x x 0 )(x x 1 ) (x x n ) (n + 1)! where P (x) is the interpolating polynomial.
Recursive Generation of Lagrange Polynomials Definition Let f be defined at x 0,..., x n, suppose m 1,..., m k distinct integers with 0 m i n. The Lagrange polynomial that agrees with f(x) at x m1, x m2,..., x mk is denoted P m1,m 2,...,m k (x). Theorem f defined at x 0,..., x k, and x j, x i two distinct numbers among these. 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 ) is the kth Lagrange polynomial that interpolates f.
Neville s Method Neville s Method Set Q i,j = P i j,i j+1,...,i 1,i and use the recursive formula to obtain the table: x 0 P 0 = Q 0,0 x 1 P 1 = Q 1,0 P 0,1 = Q 1,1 x 2 P 2 = Q 2,0 P 1,2 = Q 2,1 P 0,1,2 = Q 2,2 x 3 P 3 = Q 3,0 P 2,3 = Q 3,1 P 1,2,3 = Q 3,2 P 0,1,2,3 = Q 3,3 x 4 P 4 = Q 4,0 P 3,4 = Q 4,1 P 2,3,4 = Q 4,2 P 1,2,3,4 = Q 4,3 P 0,1,2,3,4 = Q 4,4
Neville s Method MATLAB Implementation function Q=neville(x,xi,fi) n=length(xi)-1; Q=zeros(n+1,n+1); Q(:,1)=fi(:); for i=1:n for j=1:i Q(i+1,j+1)=((x-xi(i-j+1))*Q(i+1,j)-... (x-xi(i+1))*q(i,j))... /(xi(i+1)-xi(i-j+1)); end end
Divided Differences Divided Differences Write the nth Lagrange polynomial in the form P n (x) = a 0 + a 1 (x x 0 ) + a 2 (x x 0 )(x x 1 ) + = a n (x x 0 )(x x 1 ) (x x n 1 ) Introduce the kth divided difference f[x i, x i+1,..., x i+k 1, x i+k ] = f[x i+1, x i+2,..., x i+k ] f[x i, x i+1,..., x i+k 1 ] x i+k x i The coefficients are then a k = f[x 0, x 1, x 2,..., x k ] and P n (x) = f[x 0 ] + n f[x 0, x 1,..., x k ](x x 0 ) (x x k 1 ) k=1
Newton s Divided-Difference MATLAB Implementation function F=divideddifference(x,f) n=length(x)-1; F=zeros(n+1,n+1); F(:,1)=f(:); for i=1:n for j=1:i F(i+1,j+1)=(F(i+1,j)-F(i,j))/(x(i+1)-x(i-j+1)); end end
Equally Spaced Nodes Equal Spacing Suppose x 0,..., x n increasing with equal spacing h = x i+1 x i and x = x 0 + sh The Newton Forward-Difference Formula then gives where P n (x) = f(x 0 ) + f(x 0 ) = f(x 1 ) f(x 0 ) n k=1 ( ) s k f(x 0 ) k 2 f(x 0 ) = f(x 1 ) f(x 0 ) = f(x 2 ) 2f(x 1 ) + f(x 0 )
Backward Differencing The Newton Backward-Difference Formula Reordering the nodes gives P n (x) = f[x n ] + f[x n, x n 1 ](x x n ) + = f[x n,..., x 0 ](x x n )(x x n 1 ) (x x 1 ) The Newton Backward-Difference Formula is n ( ) s P n (x) = f[x n ] + ( 1) k k f(x n ) k k=1 where the backward difference p n is defined by p n = p n p n 1 k p n = ( k 1 p n )
Osculating Polynomials Definition Let x 0,..., x n be distinct in [a, b], and m i nonnegative integers. Suppose f C m [a, b], with m = max 0 i n m i. The osculating polynomial approximating f is the P (x) of least degree such that d k P (x i ) dx k = dk f(x i ) dx k, for i = 0,..., n and k = 0,..., m i Special Cases n = 0: m 0 th Taylor polynomial m i = 0: nth Lagrange polynomial m i = 1: Hermite polynomial
Hermite Interpolation Theorem If f C 1 [a, b] and x 0,..., x n [a, b] distinct, the Hermite polynomial is H 2n+1 (x) = n f(x j )H n,j (x) + j=0 n f (x j )Ĥn,j(x) j=0 where H n,j (x) = [1 2(x x j )L n,j(x j )]L 2 n,j(x) Ĥ n,j (x) = (x x j )L 2 n,j(x). Moreover, if f C 2n+2 [a, b], then f(x) = H 2n+1 (x) + (x x 0) 2 (x x n ) 2 f (2n+2) (ξ(x)) (2n + 2)! for some ξ(x) (a, b).
Hermite Polynomials from Divided Differences Divided Differences Suppose x 0,..., x n and f, f are given at these numbers. Define z 0,..., z 2n+1 by z 2i = z 2i+1 = x i Construct divided difference table, but use f (x 0 ), f (x 1 ),..., f (x n ) instead of the undefined divided differences The Hermite polynomial is f[z 0, z 1 ], f[z 2, z 3 ],..., f[z 2n, z 2n+1 ] 2n+1 H 2n+1 (x) = f[z 0 ] + f[z 0,..., z k ](x z 0 ) (x z k 1 ) k=1
Cubic Splines Definition Given a function f on [a, b] and nodes a = x 0 < < x n = b, a cubic spline interpolant S for f satisfies: (a) S(x) is a cubic polynomial S j (x) on [x j, x j+1 ] (b) S j (x j ) = f(x j ) and S j (x j+1 ) = f(x j+1 ) (c) S j+1 (x j+1 ) = S j (x j+1 ) (d) S j+1 (x j+1) = S j (x j+1) (e) S j+1 (x j+1) = S j (x j+1) (f) One of the following boundary conditions: (i) S (x 0 ) = S (x n ) = 0 (free or natural boundary) (ii) S (x 0 ) = f (x 0 ) and S (x n ) = f (x n ) (clamped boundary)
Natural Splines Computing Natural Cubic Splines Solve for coefficients a j, b j, c j, d j in S j(x) = a j + b j(x x j) + c j(x x j) 2 + d j(x x j) 3 by setting a j = f(x j ), h j = x j+1 x j, and solving Ax = b: Finally, 1 0 h 0 2(h 0 + h 1) h 1 A =......... h n 2 2(h n 2 + h n 1) h n 1 0 1 b = (0, 3(a 2 a 1)/h 1 3(a 1 a 0)/h 0,..., 3(a n a n 1)/h n 1 3(a n 1 a n 2)/h n 2, 0) T x = (c 0,..., c n) T b j = (a j+1 a j)/h j h j(2c j + c j+1)/3, d j = (c j+1 c j)/(3h j)
Clamped Splines Computing Clamped Cubic Splines Solve for coefficients a j, b j, c j, d j in S j(x) = a j + b j(x x j) + c j(x x j) 2 + d j(x x j) 3 using same procedure as for natural cubic splines, but with 2h 0 h 0 h 0 2(h 0 + h 1) h 1 A =......... h n 2 2(h n 2 + h n 1) h n 1 h n 1 2h n 1 b = (3(a 1 a 0)/h 0 3f (a), 3(a 2 a 1)/h 1 3(a 1 a 0)/h 0,..., 3(a n a n 1)/h n 1 3(a n 1 a n 2)/h n 2, 3f (b) 3(a n a n 1)/h n 1) T