section 3 interpolation and polynomial approximation
play

Section 3 Interpolation and Polynomial Approximation Numerical - PowerPoint PPT Presentation

Section 3 Interpolation and Polynomial Approximation Numerical Analysis I Xiaojing Ye, Math & Stat, Georgia State University 78 Interpolation ( x i , y i ) : i = 1 , . . . , n Given data points , can we find a function to


  1. Section 3 Interpolation and Polynomial Approximation Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 78

  2. Interpolation � � ( x i , y i ) : i = 1 , . . . , n Given data points , can we find a function to “fit” the data? Theorem (Weierstrass approximation theorem) Suppose f ∈ C [ a , b ] , then ∀ ǫ > 0 , ∃ a polynomial P ( x ) such that | f ( x ) − P ( x ) | < ǫ , ∀ x ∈ [ a , b ] . y y � f ( x ) � ε y � P ( x ) y � f ( x ) y � f ( x ) � ε x a b Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 79

  3. Polynomial interpolation So polynomials could work. But how to find the polynomial? First Try: Taylor’s polynomial For any given function f ( x ) and a point x 0 , we approximate f ( x ) by the Taylor’s polynomial P n ( x ): f ( x ) ≈ P n ( x ) := f ( x 0 ) + f ′ ( x 0 )( x − x 0 ) + · · · + 1 n ! f ( n ) ( x 0 )( x − x 0 ) n Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 80

  4. Polynomial interpolation Example (Problem with Taylor’s polynomial) Let f ( x ) = e x and x 0 = 0. See how Taylor’s polynomial behaves. Solution. Taylor’s polynomial P n ( x ) = 1 + x + · · · + 1 n ! x n . However, no matter how large we choose n , P n ( x ) is far from f ( x ) where x is slightly large. Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 81

  5. Issue with Taylor’s polynomial approximation y 20 y � P 5 ( x ) y � e x y � P 4 ( x ) 15 y � P 3 ( x ) 10 y � P 2 ( x ) 5 y � P 1 ( x ) y � P 0 ( x ) x � 1 1 2 3 Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 82

  6. Example Example (Problem with Taylor’s polynomial) Let f ( x ) = 1 x and x 0 = 1. See how Taylor’s polynomial behaves. Solution. We know f ( n ) ( x ) = ( − 1) n n ! x n +1 . Then Taylor’s polynomial is n � ( − 1) n ( x − 1) n = 1 − ( x − 1)+( x − 1) 2 + · · · +( − 1) n ( x − 1) n P n ( x ) = i =0 Suppose we use P n ( x ) to approximate f at x = 3, we get P 0 (3) P 1 (3) P 2 (3) P 3 (3) P 4 (3) P 5 (3) P 6 (3) P 7 (3) 1 -1 3 -5 11 -21 43 -85 But the true value is f (3) = 1 3 . Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 83

  7. Lagrange interpolating polynomial We should not use Taylor’s polynomial since it only approximates well locally. Suppose we have two points ( x 0 , y 0 ) and ( x 1 , y 1 ), then best use a straight line to interpolate. Define two linear polynomials: L 0 ( x ) = x − x 1 L 1 ( x ) = x − x 0 and x 0 − x 1 x 1 − x 0 So L 0 and L 1 are polynomials of degree 1, and L 0 ( x 1 ) = 0 , L 0 ( x 0 ) = 1 , L 1 ( x 0 ) = 0 , L 1 ( x 1 ) = 1 Now set P ( x ) = f ( x 0 ) L 0 ( x ) + f ( x 1 ) L 1 ( x ), then P ( x ) coincides f ( x ) at x 0 and x 1 . Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 84

  8. Example Recall that the polynomial we derived is P ( x ) = f ( x 0 ) L 0 ( x ) + f ( x 1 ) L 1 ( x ) = x − x 0 f ( x 0 ) + x − x 1 f ( x 1 ) x 1 − x 0 x 0 − x 1 P ( x ) is called the Lagrange interpolating polynomial of f given values at x 0 and x 1 . Example (Linear Lagrange interpolating polynomial) Use linear Lagrange interpolating polynomial of f where f (2) = 5 and f (4) = 1. Solution. P ( x ) = − x + 6. Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 85

  9. Lagrange interpolating polynomial � � ( x i , f ( x i )) : 0 ≤ i ≤ n Given n + 1 points . For each i , define: ( x − x 0 ) . . . ( x − x k − 1 )( x − x k +1 ) . . . ( x − x n ) L n , k = ( x k − x 0 ) . . . ( x k − x k − 1 )( x k − x k +1 ) . . . ( x k − x n ) for k = 0 , 1 , . . . , n . Then it is easy to verify � 1 if x = x k L n , k ( x ) = 0 if x = x j , where j � = k Then the n th Lagrange interpolating polynomial of f is n � P ( x ) = f ( x k ) L n , k ( x ) k =0 Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 86

  10. Lagrange interpolating polynomial Illustration of L n , k ( x ): L n , k ( x ) 1 x x 0 x 1 x k � 1 x k x k � 1 x n � 1 x n . . . . . . Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 87

  11. Lagrange interpolating polynomial The n th Lagrange interpolating polynomial of f at x 0 , . . . , x n is n � P ( x ) = f ( x k ) L n , k ( x ) k =0 Properties : ◮ P ( x ) is a polynomial of degree n ◮ P ( x k ) = f ( x k ) for all k = 0 , . . . , n . Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 88

  12. Example Example (Lagrange interpolating polynomial) Let f ( x ) = 1 x , x 0 = 2, x 1 = 2 . 75, x 2 = 4. Find the 2nd Lagrange interpolating polynomial P ( x ) of f ( x ) and compute P (3). Solution. First we compute L 2 , k for k = 0 , 1 , 2: L 2 , 0 ( x ) = ( x − x 1 )( x − x 2 ) ( x 0 − x 1 )( x 0 − x 2 ) = ( x − 2 . 75)( x − 4) (2 − 2 . 75)(2 − 4) L 2 , 1 ( x ) = ( x − x 0 )( x − x 2 ) ( x − 2)( x − 4) ( x 1 − x 0 )( x 1 − x 2 ) = (2 . 75 − 2)(2 . 75 − 4) L 2 , 2 ( x ) = ( x − x 0 )( x − x 1 ) ( x 2 − x 0 )( x 2 − x 1 ) = ( x − 2)( x − 2 . 75) (4 − 2)(4 − 2 . 75) Then the 2nd Lagrange interpolating polynomial is 2 f ( x k ) L 2 , k ( x ) = · · · = x 2 22 − 35 x 88 + 49 � P ( x ) = 44 k =0 Note that P (3) = 3 2 22 − 35 × 3 + 49 44 ≈ 0 . 32955, close to f (3) = 1 3 . 88 Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 89

  13. Example Example (Lagrange interpolating polynomial) Let f ( x ) = 1 x , x 0 = 2, x 1 = 2 . 75, x 2 = 4. Find the 2nd Lagrange interpolating polynomial P ( x ) of f ( x ) and compute P (3). y 4 3 2 y � f ( x ) 1 y � P ( x ) x 1 2 3 4 5 Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 90

  14. Lagrange interpolating polynomial Theorem (Error of Lagrange interpolating polynomial) Suppose f ( x ) ∈ C n +1 [ a , b ] . Then for every x ∈ [ a , b ] , ∃ ξ ( x ) between x 0 , . . . , x n , s.t. f ( x ) = P ( x ) + f ( n +1) ( ξ ( x )) ( x − x 0 ) . . . ( x − x n ) ( n + 1)! Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 91

  15. Error of Lagrange interpolating polynomial Proof. For any given x ∈ [ a , b ] different from x 0 , . . . , x n , define g ( t ) as g ( t ) = f ( t ) − P ( t ) − ( f ( x ) − P ( x )) ( t − x 0 ) . . . ( t − x n ) ( x − x 0 ) . . . ( x − x n ) � �� � polynomial of t , degree n + 1 Note that f ( t ) = P ( t ) and ( t − x 0 ) . . . ( t − x n ) = 0 for t = x k and k = 0 , . . . , n . So g ( t ) = 0 for t = x , x 0 , . . . , x n (total n + 2 points). By generalized Rolle’s Thm, ∃ ξ ( x ) between x 0 , . . . , x n s.t. 0 = g ( n +1) ( ξ ( x )) = f ( n +1) ( ξ ( x )) − ( n + 1)! · ( f ( x ) − P ( x )) ( x − x 0 ) . . . ( x − x n ) since P ( t ) is a poly of t with degree n and ( t − x 0 ) · · · ( t − x n ) is a monic poly of t with degree n + 1. Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 92

  16. Example Example (Estimate error of Lagrange interpolating polynomial) Let f ( x ) = 1 x , x 0 = 2, x 1 = 2 . 75, x 2 = 4. Estimate the maximal error of the 2nd Lagrange interpolating polynomial P ( x ) given above on [2 , 4]. Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 93

  17. Example Solution. Let P ( x ) be the Lagrange interpolating polynomial, then f ( x ) − P ( x ) = f (3) ( ξ ( x )) ( x − 2)( x − 2 . 75)( x − 4) 3! We know f ′ ( x ) = − 1 x 2 , f ′′ ( x ) = 2 x 3 , f ′′′ ( x ) = − 3! x 4 , so � � � � f (3) ( ξ ( x )) � � 1 � ≤ 1 � � � � � = � − ( ∵ ξ ( x ) ∈ [2 , 4]) � � � � ( ξ ( x )) 4 2 4 3! � Further, denote h ( x ) := ( x − 2)( x − 2 . 75)( x − 4), find critical points and then the max/min values of h ( x ) on [2 , 4] to claim | h ( x ) | ≤ 9 16 for all x ∈ [2 , 4]. Hence � � f (3) ( ξ ( x )) � � � ≤ 1 9 � � | f ( x ) − P ( x ) | = h ( x ) 16 ≈ 0 . 00586 . � � 2 4 3! � Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 94

  18. Example Example (Estimate error of Lagrange interpolating polynomial) Suppose we use uniform partition of [0 , 1] and linear Lagrange interpolating polynomial on each segment to approximate f ( x ) = e x . How small the step size h should be to guarantee the error < 10 − 6 everywhere? Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 95

  19. Example Solution. With step size h , we have x j = jh for j = 0 , 1 , . . . . Then we use linear Lagrange polynomial to approximate e x on each [ x j , x j +1 ]. The error is 1 2 f (2) ( ξ ( x ))( x − x j )( x − x j +1 ) So | f (2) ( ξ ( x )) | = | e ξ ( x ) 2 | ≤ e 2 ( ∵ ξ ( x ) ∈ [0 , 1]). 2 Again take h ( x ) = ( x − x j )( x − x j +1 ) which has max h 2 2 . Then � � f (2) ( ξ ( x )) h 2 � � � ≤ e 4 ≤ 10 − 6 � � ( x − x j )( x − x j +1 ) � � 2 2 � So we need h ≤ (8 × 10 − 6 × e − 1 ) 1 / 2 ≈ 1 . 72 × 10 − 3 . Numerical Analysis I – Xiaojing Ye, Math & Stat, Georgia State University 96

Recommend


More recommend