numerical analysis i interpolation and polynomial
play

Numerical Analysis I Interpolation and Polynomial Approximation - PowerPoint PPT Presentation

Numerical Analysis I Interpolation and Polynomial Approximation Instructor: Wei-Cheng Wang 1 Department of Mathematics National TsingHua University Fall 2010 1These slides are based on Prof. Tsung-Ming Huang(NTNU)s original slides Wei-Cheng


  1. Numerical Analysis I Interpolation and Polynomial Approximation Instructor: Wei-Cheng Wang 1 Department of Mathematics National TsingHua University Fall 2010 1These slides are based on Prof. Tsung-Ming Huang(NTNU)’s original slides Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 1 / 64

  2. Outline 1 Interpolation and the Lagrange Polynomial 2 Divided Differences 3 Hermite Interpolation 4 Cubic Spline Interpolation Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 2 / 64

  3. Introduction Question From these data, how do we get a reasonable estimate of the population, say, in 1965, or even in 2010? Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 3 / 64

  4. Interpolation Suppose we do not know the function f , but a few information (data) about f , now we try to compute a function g that approximates f . Theorem (Weierstrass Approximation Theorem) Suppose that f is defined and continuous on [ a, b ] . For any ε > 0 , there exists a polynomial P ( x ) , such that | f ( x ) − P ( x ) | < ε, for all x in [ a, b ] . Reason for using polynomial 1 They uniformly approximate continuous functions (Weierstrass Theorem) 2 The derivatives and indefinite integral of a polynomial are easy to determine and are also polynomials. Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 4 / 64

  5. Interpolation and the Lagrange polynomial Property The linear function passing through ( x 0 , f ( x 0 )) and ( x 1 , f ( x 1 )) is unique. Let L 0 ( x ) = x − x 1 L 1 ( x ) = x − x 0 , x 0 − x 1 x 1 − x 0 and P ( x ) = L 0 ( x ) f ( x 0 ) + L 1 ( x ) f ( x 1 ) . Then P ( x 0 ) = f ( x 0 ) , P ( x 1 ) = f ( x 1 ) . Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 5 / 64

  6. Question How to find the polynomial of degree n that passes through ( x 0 , f ( x 0 )) , . . . , ( x n , f ( x n ))? Theorem If ( x i , y i ) , x i , y i ∈ R , i = 0 , 1 , . . . , n, are n + 1 distinct pairs of data point, then there is a unique polynomial P n of degree at most n such that P n ( x i ) = y i , (0 ≤ i ≤ n ) . (1) Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 6 / 64

  7. Proof of Existence (by mathematical induction) 1 The theorem clearly holds for n = 0 (only one data point ( x 0 , y 0 )) since one may choose the constant polynomial P 0 ( x ) = y 0 for all x . 2 Assume that the theorem holds for n ≤ k , that is, there is a polynomial P k , deg( P k ) ≤ k , such that y i = P k ( x i ), for 0 ≤ i ≤ k . 3 Next we try to construct a polynomial of degree at most k + 1 to interpolate ( x i , y i ) , 0 ≤ i ≤ k + 1. Let P k +1 ( x ) = P k ( x ) + c ( x − x 0 )( x − x 1 ) · · · ( x − x k ) , where y k +1 − P k ( x k +1 ) c = ( x k +1 − x 0 )( x k +1 − x 1 ) · · · ( x k +1 − x k ) . Since x i are distinct, the polynomial P k +1 ( x ) is well-defined and deg( P k +1 ) ≤ k + 1. It is easy to verify that P k +1 ( x i ) = y i , 0 ≤ i ≤ k + 1 . Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 7 / 64

  8. Proof of Uniqueness Suppose there are two such polynomials P n and Q n satisfying (1). Define S n ( x ) = P n ( x ) − Q n ( x ) . Since both deg( P n ) ≤ n and deg( Q n ) ≤ n , deg( S n ) ≤ n . Moreover S n ( x i ) = P n ( x i ) − Q n ( x i ) = y i − y i = 0 , for 0 ≤ i ≤ n . This means that S n has at least n + 1 zeros, it therefore must be S n = 0. Hence P n = Q n . Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 8 / 64

  9. Idea Construct polynomial P ( x ) with deg( P ) ≤ n as P ( x ) = f ( x 0 ) L n, 0 ( x ) + · · · + f ( x n ) L n,n ( x ) , where 1 L n,k ( x ) are polynomial with degree n for 0 ≤ k ≤ n . 2 L n,k ( x k ) = 1 and L n,k ( x i ) = 0 for i � = k . Then P ( x k ) = f ( x k ) for k = 0 , 1 , . . . , n. 1 deg( L n,k ) = n and L n,k ( x i ) = 0 for i � = k : L n,k ( x ) = c k ( x − x 0 )( x − x 1 ) · · · ( x − x k − 1 )( x − x k +1 ) · · · ( x − x n ) 2 L n,k ( x k ) = 1: ( 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 ) Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 9 / 64

  10. Theorem If x 0 , x 1 , . . . , x n are n + 1 distinct numbers and f is a function whose values are given at these numbers, then a unique polynomial of degree at most n exists with f ( x k ) = P ( x k ) , for k = 0 , 1 , . . . , n. This polynomial is given by n � P ( x ) = f ( x k ) L n,k ( x ) k =0 which is called the n th Lagrange interpolating polynomial. Note that we will write L n,k ( x ) simply as L k ( x ) when there is no confusion as to its degree. Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 10 / 64

  11. Example Given the following 4 data points, x i 0 1 3 5 y i 1 2 6 7 find a polynomial in Lagrange form to interpolate these data. Solution : The interpolating polynomial in the Lagrange form is P 3 ( x ) = L 0 ( x ) + 2 L 1 ( x ) + 6 L 2 ( x ) + 7 L 3 ( x ) with ( x − 1)( x − 3)( x − 5) (0 − 1)(0 − 3)(0 − 5) = − 1 L 0 ( x ) = 15( x − 1)( x − 3)( x − 5) , ( x − 0)( x − 3)( x − 5) (1 − 0)(1 − 3)(1 − 5) = 1 L 1 ( x ) = 8 x ( x − 3)( x − 5) , ( x − 0)( x − 1)( x − 5) (3 − 0)(3 − 1)(3 − 5) = − 1 L 2 ( x ) = 12 x ( x − 1)( x − 5) , ( x − 0)( x − 1)( x − 3) (5 − 0)(5 − 1)(5 − 3) = 1 L 3 ( x ) = 40 x ( x − 1)( x − 3) . Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 11 / 64

  12. Question What’s the error involved in approximating f ( x ) by the interpolating polynomial P ( x )? Theorem Suppose 1 x 0 , . . . , x n are distinct numbers in [ a, b ] , 2 f ∈ C n +1 [ a, b ] . Then, ∀ x ∈ [ a, b ] , ∃ ξ ( x ) ∈ ( a, b ) such that f ( x ) = P ( x ) + f n +1 ( ξ ( x )) ( n + 1)! ( x − x 0 )( x − x 1 ) · · · ( x − x n ) . (2) Proof : If x = x k , for any k = 0 , 1 , . . . , n , then f ( x k ) = P ( x k ) and (2) is satisfied. Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 12 / 64

  13. If x � = x k , for all k = 0 , 1 , . . . , n , define n � t − x i g ( t ) = f ( t ) − P ( t ) − [ f ( x ) − P ( x )] . x − x i i =0 Since f ∈ C n +1 [ a, b ] and P ∈ C ∞ [ a, b ], it follows that g ∈ C n +1 [ a, b ]. Since n � x k − x i g ( x k ) = [ f ( x k ) − P ( x k )] − [ f ( x ) − P ( x )] = 0 , x − x i i =0 and n � x − x i g ( x ) = [ f ( x ) − P ( x )] − [ f ( x ) − P ( x )] = 0 , x − x i i =0 it implies that g is zero at x, x 0 , x 1 , . . . , x n . By the Generalized Rolle’s Theorem, ∃ ξ ∈ ( a, b ) such that g n +1 ( ξ ) = 0. That is Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 13 / 64

  14. g ( n +1) ( ξ ) 0 = (3) � n � f ( n +1) ( ξ ) − P ( n +1) ( ξ ) − [ f ( x ) − P ( x )] d n +1 � ( t − x i ) = . dt n +1 ( x − x i ) i =0 t = ξ Since deg( P ) ≤ n , it implies that P ( n +1) ( ξ ) = 0. On the other hand, � n i =0 [( t − x i ) / ( x − x i )] is a polynomial of degree ( n + 1), so � � n � ( t − x i ) 1 t n +1 + (lower-degree terms in t ) , ( x − x i ) = � n i =0 ( x − x i ) i =0 and � n � � d n +1 ( t − x i ) ( n + 1)! = � n i =0 ( x − x i ) . dt n +1 ( x − x i ) i =0 Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 14 / 64

  15. Equation (3) becomes ( n + 1)! 0 = f ( n +1) ( ξ ) − [ f ( x ) − P ( x )] � n i =0 ( x − x i ) , i.e., n � f ( x ) = P ( x ) + f ( n +1) ( ξ ) ( x − x i ) . ( n + 1)! i =0 Example 1 Goal: Prepare a table for the function f ( x ) = e x for x ∈ [0 , 1]. 2 x j +1 − x j = h for j = 0 , 1 , . . . , n − 1. 3 What should h be for linear interpolation to give an absolute error of at most 10 − 6 ? Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 15 / 64

  16. Suppose x ∈ [ x j , x j +1 ]. Equation (2) implies that � � � � f (2) ( ξ ) � � | f ( x ) − P ( x ) | = ( x − x j )( x − x j +1 ) � � � 2! � | f (2) ( ξ ) | = | x − x j || x − x j +1 | 2! e ξ = 2 | x − jh || x − ( j + 1) h | � � � � 1 ξ ∈ [0 , 1] e ξ ≤ max x j ≤ x ≤ x j +1 | x − jh || x − ( j + 1) h | max 2 � � e = x j ≤ x ≤ x j +1 | x − jh || x − ( j + 1) h | max . 2 Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 16 / 64

  17. Let g ( x ) = ( x − jh )( x − ( j + 1) h ) , for jh ≤ x ≤ ( j + 1) h. Then � �� �� � � = h 2 � � j + 1 � � x j ≤ x ≤ x j +1 | g ( x ) | = max � g h 4 . 2 Consequently, | f ( x ) − P ( x ) | ≤ eh 2 ≤ 10 − 6 , 8 which implies that h < 1 . 72 × 10 − 3 . Since n = (1 − 0) /h must be an integer, one logical choice for the step size is h = 0 . 001. Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 17 / 64

  18. Difficulty for the Lagrange interpolation 1 If more data points are added to the interpolation problem, all the cardinal functions L k have to be recalculated. 2 We shall now derive the interpolating polynomials in a manner that uses the previous calculations to greater advantage. Definition 1 f is a function defined at x 0 , x 1 , . . . , x n 2 Suppose that m 1 , m 2 , . . . , m k are k distinct integers with 0 ≤ m i ≤ n for each i . The Lagrange polynomial that interpolates f at the k points x m 1 , x m 2 , . . . , x m k is denoted P m 1 ,m 2 ,...,m k ( x ). Wei-Cheng Wang (NTHU) Interpol. & Poly. Approx. Fall 2010 18 / 64

Recommend


More recommend