Interpolation and the Lagrange Polynomial MATH 375 J. Robert Buchanan Department of Mathematics Fall 2013
Introduction We often choose polynomials to approximate other classes of functions. Theorem (Weierstrass Approximation Theorem) If f C[a, b] and ɛ > 0 then there exists a polynomial P such that f (x) P(x) < ɛ, for all x [a, b].
Introduction We often choose polynomials to approximate other classes of functions. Theorem (Weierstrass Approximation Theorem) If f C[a, b] and ɛ > 0 then there exists a polynomial P such that f (x) P(x) < ɛ, for all x [a, b]. We have used Taylor polynomials to approximate functions. n f (k) (x 0 ) P(x) = (x x 0 ) k k! k=0 Away from x 0 the approximation may be very poor.
Linear Approximation (1 of 2) y 1 f x 1 y 0 f x 0 x 1 x Using the two-point formula for a line we determine the equation of the line to be ( ) f (x1 ) f (x 0 ) y = f (x 0 ) + (x x 0 ). x 1 x 0
Linear Approximation (2 of 2) We can take another approach to finding the linear approximation. Define L 0 (x) = x x 1 x 0 x 1, L 1 (x) = x x 0 x 1 x 0,
Linear Approximation (2 of 2) We can take another approach to finding the linear approximation. Define L 0 (x) = x x 1 x 0 x 1, then L 0 (x 0 ) = 1 and L 0 (x 1 ) = 0. L 1 (x) = x x 0 x 1 x 0,
Linear Approximation (2 of 2) We can take another approach to finding the linear approximation. Define L 0 (x) = x x 1 x 0 x 1, then L 0 (x 0 ) = 1 and L 0 (x 1 ) = 0. L 1 (x) = x x 0 x 1 x 0, then L 1 (x 0 ) = 0 and L 1 (x 1 ) = 1.
Linear Approximation (2 of 2) We can take another approach to finding the linear approximation. Define L 0 (x) = x x 1 x 0 x 1, then L 0 (x 0 ) = 1 and L 0 (x 1 ) = 0. L 1 (x) = x x 0 x 1 x 0, then L 1 (x 0 ) = 0 and L 1 (x 1 ) = 1. If f (x) is any function then P(x) = f (x 0 ) L 0 (x) + f (x 1 ) L 1 (x) is a linear function which matches f (x) at x = x 0 and x = x 1.
Linear Approximation (2 of 2) We can take another approach to finding the linear approximation. Define L 0 (x) = x x 1 x 0 x 1, then L 0 (x 0 ) = 1 and L 0 (x 1 ) = 0. L 1 (x) = x x 0 x 1 x 0, then L 1 (x 0 ) = 0 and L 1 (x 1 ) = 1. If f (x) is any function then P(x) = f (x 0 ) L 0 (x) + f (x 1 ) L 1 (x) is a linear function which matches f (x) at x = x 0 and x = x 1. We want to extend this idea to higher order polynomials.
Construction of Polynomials Challenge: given a function f (x), construct a polynomial P(x) of degree at most n which matches f (x) at n + 1 distinct points. {(x 0, f (x 0 )), (x 1, f (x 1 )),..., (x n, f (x n ))}
Construction of Polynomials Challenge: given a function f (x), construct a polynomial P(x) of degree at most n which matches f (x) at n + 1 distinct points. {(x 0, f (x 0 )), (x 1, f (x 1 )),..., (x n, f (x n ))} Strategy: construct n + 1 polynomials L n,k (x) of degree n with the property that { 0 if k i, L n,k (x i ) = 1 if k = i for k = 0, 1, 2,..., n.
Lagrange Basis Polynomials Definition Suppose {x 0, x 1,..., x n } is a set of n + 1 distinct points. A Lagrange Basis Polynomial is a polynomial of degree n having the form L n,k (x) = n i=0, i k x x i x k x i.
Lagrange Basis Polynomials Definition Suppose {x 0, x 1,..., x n } is a set of n + 1 distinct points. A Lagrange Basis Polynomial is a polynomial of degree n having the form Remarks: L n,k (x) = We will let k = 0, 1, 2,..., n. L n,k (x i ) = 1 for i = k. L n,k (x i ) = 0 for i k. n i=0, i k x x i x k x i.
Example If x i = i for i = 0, 1, 2 then we can create three different Lagrange Basis Polynomials. L 2,0 (x) = L 2,1 (x) = L 2,2 (x) =
Example If x i = i for i = 0, 1, 2 then we can create three different Lagrange Basis Polynomials. L 2,0 (x) = x 1 0 1 x 2 0 2 = 1 (x 1)(x 2) 2 L 2,1 (x) = L 2,2 (x) =
Example If x i = i for i = 0, 1, 2 then we can create three different Lagrange Basis Polynomials. L 2,0 (x) = x 1 0 1 x 2 0 2 = 1 (x 1)(x 2) 2 L 2,1 (x) = x 0 1 0 x 2 = x(2 x) 1 2 L 2,2 (x) =
Example If x i = i for i = 0, 1, 2 then we can create three different Lagrange Basis Polynomials. L 2,0 (x) = x 1 0 1 x 2 0 2 = 1 (x 1)(x 2) 2 L 2,1 (x) = x 0 1 0 x 2 = x(2 x) 1 2 L 2,2 (x) = x 0 2 0 x 1 2 1 = 1 x(x 1) 2
Graph L 2,0 (x) = 1 (x 1)(x 2) 2 L 2,1 (x) = x(2 x) 3 2 1 L 2,2 (x) = 1 2 x(x 1) 1 1 2 3 x 1
Lagrange Interpolating Polynomials Definition Let {x 0, x 1,..., x n } be a set of n + 1 distinct points at which the function f (x) is defined. The (unique) Lagrange Interpolating Polynomial of f (x) of degree n is the polynomial having the form n P(x) = f (x k )L n,k (x). Properties: L n,k (x i ) = 0 for all i k. L n,k (x k ) = 1. k=0 P(x k ) = f (x k ) for k = 0, 1,..., n.
Example If n = 9 and the nodes are {0, 1,..., 9} then L 9,4 (x) has a graph resembling the following. 4 2 2 4 6 8 10 x 2 4
Example (1 of 3) Let f (x) = sin x, n = 3, and x k = kπ/3 for k = 0, 1, 2, 3. The four Lagrange Basis Polynomials are listed below. L 3,0 (x) = x π 3 0 π 3 x 2π 3 0 2π 3 x π 0 π = 1 (π 3x)(2π 3x)(π x) 2π3 L 3,1 (x) = 9 x(2π 3x)(π x) 2π3 L 3,2 (x) = 9 x(π 3x)(π x) 2π3 L 3,3 (x) = 1 x(π 3x)(2π 3x) 2π3
Example (2 of 3) The Lagrange Interpolating Polynomial of degree 3 for f (x) = sin x and x k = kπ/3 for k = 0, 1, 2, 3 is ( P(x) = (sin 0) L 3,0 (x) + sin π ) ( L 3,1 (x) + sin 2π ) L 3,2 (x) 3 3 = + (sin π) L 3,3 (x) 3 2 = 9 3 x(π x) 4π2 9 x(2π 3x)(π x) 2π3 3 2 9 x(π 3x)(π x) 2π3
Example (3 of 3) The graphs of P(x), f (x), and the absolute error are shown below. 1.0 Abs. Err. 0.8 0.04 0.6 0.03 0.4 0.02 0.2 0.01 0 Π x x
Lagrange Polynomial with Error Term Theorem Suppose x 0, x 1,..., x n are distinct numbers in the interval [a, b] and suppose f C n+1 [a, b]. Then for each x [a, b] there exists a number z(x) (a, b) for which f (x) = P(x) + f (n+1) (z(x)) (x x 0 )(x x 1 ) (x x n ), (n + 1)! where P(x) is the Lagrange Interpolating Polynomial.
Comments Compare the error terms of the Lagrange polynomial and the Taylor polynomial. Taylor: f (n+1) (z(x)) (x x 0 ) n+1 (n + 1)! f (n+1) (z(x)) Lagrange: (x x 0 )(x x 1 ) (x x n ) (n + 1)! Lagrange polynomials form the basis of many numerical approximations to derivatives and integrals, and thus the error term is important to understanding the errors present in those approximations.
Application Example Suppose we are preparing a table of values for cos x on [0, π]. The entries in the table will have eight accurate decimal places and we will linearly interpolate between adjacent entries to determine intermediate values. What should the spacing between adjacent x-values be to preserve the eight-decimal-place accuracy in the interpolation?
Solution cos x P(x) = cos z 2 x x j x x j+1 for some 0 z π 1 2 max 0 z π cos z max x x j x x j+1 x j x x j+1 = 1 2 = h2 8 max (x jh)(x (j + 1)h jh x (j+1)h Thus if h 2 /8 < 10 8 then h < 2 2 10 4 0.000282.
Error in sin x Earlier we found the Lagrange interpolating polynomial of degree 3 for f (x) = sin x using nodes x k = kπ/3 for k = 0, 1, 2, 3 was P(x) = 9 3 x(π x). 4π2 What is an error bound for this approximation?
Error in sin x Earlier we found the Lagrange interpolating polynomial of degree 3 for f (x) = sin x using nodes x k = kπ/3 for k = 0, 1, 2, 3 was P(x) = 9 3 x(π x). 4π2 What is an error bound for this approximation? R(x) = sin z ( (x 0) x π ) ( x 2π 4! 3 3 ) (x π) 0.050108
Error Bound vs. Actual Error 0.05 0.04 0.03 0.02 0.01 0 Π x
Homework Read Section 3.1 Exercises: 1, 3, 5a, 7a, 13, 17