numerical integration
play

Numerical Integration Numerical Integration 1 / 11 Objective b - PowerPoint PPT Presentation

Numerical Integration Numerical Integration 1 / 11 Objective b Approximate f ( x ) dx a Numerical Integration 2 / 11 Objective b Approximate f ( x ) dx a A jog down Calc I/II lane The integral is the area under the curve, i.e


  1. Numerical Integration Numerical Integration 1 / 11

  2. Objective � b Approximate f ( x ) dx a Numerical Integration 2 / 11

  3. Objective � b Approximate f ( x ) dx a A jog down Calc I/II lane The integral is the area under the curve, i.e between the curve and x -axis Numerical Integration 2 / 11

  4. Objective � b Approximate f ( x ) dx a A jog down Calc I/II lane The integral is the area under the curve, i.e between the curve and x -axis However, analytical anti-derivatives are not always easy to write down, making evaluation of some basic definite integrals difficult. � b e x 2 dx a Numerical Integration 2 / 11

  5. Objective � b Approximate f ( x ) dx a A jog down Calc I/II lane The integral is the area under the curve, i.e between the curve and x -axis However, analytical anti-derivatives are not always easy to write down, making evaluation of some basic definite integrals difficult. � b e x 2 dx a In some practical cases, we do not have an analytical representation of f but we still want to approximate the integral Numerical Integration 2 / 11

  6. Objective � b Approximate f ( x ) dx a A jog down Calc I/II lane The integral is the area under the curve, i.e between the curve and x -axis However, analytical anti-derivatives are not always easy to write down, making evaluation of some basic definite integrals difficult. � b e x 2 dx a In some practical cases, we do not have an analytical representation of f but we still want to approximate the integral Numerical integration techniques are necessary to approximate the integral Numerical Integration 2 / 11

  7. � b Approximating f ( x ) dx (basic idea) a Approximate the “area” under the curve on [ a , b ] using simple sub-regions Numerical Integration 3 / 11

  8. � b Approximating f ( x ) dx (basic idea) a Approximate the “area” under the curve on [ a , b ] using simple sub-regions Sub-divide the interval [ a , b ] into n subintervals of equal width ∆ x = b − a n Numerical Integration 3 / 11

  9. � b Approximating f ( x ) dx (basic idea) a Approximate the “area” under the curve on [ a , b ] using simple sub-regions Sub-divide the interval [ a , b ] into n subintervals of equal width ∆ x = b − a n More sophisticated methods use adaptive widths of subinterval depending on the behavior of the function Numerical Integration 3 / 11

  10. � b Approximating f ( x ) dx (basic idea) a Approximate the “area” under the curve on [ a , b ] using simple sub-regions Sub-divide the interval [ a , b ] into n subintervals of equal width ∆ x = b − a n More sophisticated methods use adaptive widths of subinterval depending on the behavior of the function As the number of sub-intervals increases, we obtain a more accurate approximation of the area under the curve Desmos demo Numerical Integration 3 / 11

  11. � b Approximating f ( x ) dx (Implementation) a Rectangles 1 Divide [ a , b ] so that a = x 1 < x 2 < · · · < x n < x n +1 = b , k = 1 , 2 , . . . , n with x k = a + ( k − 1)∆ x Numerical Integration 4 / 11

  12. � b Approximating f ( x ) dx (Implementation) a Rectangles 1 Divide [ a , b ] so that a = x 1 < x 2 < · · · < x n < x n +1 = b , k = 1 , 2 , . . . , n with x k = a + ( k − 1)∆ x 2 On each sub-interval [ x k , x k +1 ] select a sample point , x ∗ k ∈ [ x k , x k +1 ] Numerical Integration 4 / 11

  13. � b Approximating f ( x ) dx (Implementation) a Rectangles 1 Divide [ a , b ] so that a = x 1 < x 2 < · · · < x n < x n +1 = b , k = 1 , 2 , . . . , n with x k = a + ( k − 1)∆ x 2 On each sub-interval [ x k , x k +1 ] select a sample point , x ∗ k ∈ [ x k , x k +1 ] 3 Define the height of each sub-rectangle as f ( x ∗ k ) so that the area of each sub-rectangle is f ( x ∗ )∆ x 4 Summing up for the n sub-intervals � b n � f ( x ∗ f ( x ) dx ≈ k )∆ x a k =1 Numerical Integration 4 / 11

  14. � b Approximating f ( x ) dx (Implementation) a Trapeziods 1 Each trapezoid has a base of [ x k , x k +1 ] with parallel sides of length f ( x k ) and f ( x k +1 ) Numerical Integration 5 / 11

  15. � b Approximating f ( x ) dx (Implementation) a Trapeziods 1 Each trapezoid has a base of [ x k , x k +1 ] with parallel sides of length f ( x k ) and f ( x k +1 ) 2 The area of the k -th Trapezoid is ∆ x � � f ( x k ) + f ( x k +1 ) 2 Numerical Integration 5 / 11

  16. � b Approximating f ( x ) dx (Implementation) a Trapeziods 1 Each trapezoid has a base of [ x k , x k +1 ] with parallel sides of length f ( x k ) and f ( x k +1 ) 2 The area of the k -th Trapezoid is ∆ x � � f ( x k ) + f ( x k +1 ) 2 3 Summing up for the n sub-intervals � b n f ( x ) dx ≈ ∆ x � � � f ( x k ) + f ( x k +1 ) 2 a k =1 Numerical Integration 5 / 11

  17. � b Approximating f ( x ) dx (Implementation) a Trapezoids � b n f ( x ) dx ≈ ∆ x � � � f ( x k ) + f ( x k +1 ) 2 a k =1 = ∆ x � � [ f ( x 1 ) + f ( x 2 )] + [( f ( x 2 ) + f ( x 3 )] + · · · + [ f ( x n − 1 ) + f ( x n )] + [ f ( x n ) + f ( x n +1 )] 2 = ∆ x � � f ( x 1 ) + 2 f ( x 2 ) + · · · + 2 f ( x n ) + f ( x n +1 ) 2 � b n f ( x ) dx = ∆ x � � � f ( x 1 ) + 2 f ( x k ) + f ( x n +1 ) 2 a k =2 Numerical Integration 6 / 11

  18. Error Analysis (MA 428) Theorem a ≤ x ≤ b | f ′′ ( x ) | ≤ M. Then the midpoint method has error Assuming max M ( b − a )(∆ x ) 2 24 and the Trapezoidal method has error M ( b − a )(∆ x ) 2 12 Numerical Integration 7 / 11

  19. � b Simpson’s Method for approximating f ( x ) dx a Approximate the area under the function using second order curves Numerical Integration 8 / 11

  20. � b Simpson’s Method for approximating f ( x ) dx a Approximate the area under the function using second order curves Divide [ a , b ] into n sub-intervals of width ∆ x = b − a n , where n is even . 1 Numerical Integration 8 / 11

  21. � b Simpson’s Method for approximating f ( x ) dx a Approximate the area under the function using second order curves Divide [ a , b ] into n sub-intervals of width ∆ x = b − a n , where n is even . 1 On each pair of sub-intervals [ x k − 1 , x k ] and [ x k , x k +1 ] ( k = 2 , · · · , n ) 2 approximate the area under the curve with a quadratic function passing through the points: � � � � x k − 1 , f ( x k − 1 ) x k , f ( x k ) and ( x k +1 , f ( x k +1 )) , Numerical Integration 8 / 11

  22. � b Simpson’s Method for approximating f ( x ) dx a Approximate the area under the function using second order curves Divide [ a , b ] into n sub-intervals of width ∆ x = b − a n , where n is even . 1 On each pair of sub-intervals [ x k − 1 , x k ] and [ x k , x k +1 ] ( k = 2 , · · · , n ) 2 approximate the area under the curve with a quadratic function passing through the points: � � � � x k − 1 , f ( x k − 1 ) x k , f ( x k ) and ( x k +1 , f ( x k +1 )) , The area under each parabola on [ x k − 1 , x k ] and [ x k , x k +1 ] is 3 ∆ x � � f ( x k − 1 ) + 4 f ( x k ) + f ( x k +1 ) 3 Numerical Integration 8 / 11

  23. � b Simpson’s Method for approximating f ( x ) dx a Approximate the area under the function using second order curves Divide [ a , b ] into n sub-intervals of width ∆ x = b − a n , where n is even . 1 On each pair of sub-intervals [ x k − 1 , x k ] and [ x k , x k +1 ] ( k = 2 , · · · , n ) 2 approximate the area under the curve with a quadratic function passing through the points: � � � � x k − 1 , f ( x k − 1 ) x k , f ( x k ) and ( x k +1 , f ( x k +1 )) , The area under each parabola on [ x k − 1 , x k ] and [ x k , x k +1 ] is 3 ∆ x � � f ( x k − 1 ) + 4 f ( x k ) + f ( x k +1 ) 3 Summing up over all sub-intervals 4 � b f ( x ) dx ≈ ∆ x � � f 1 + 4 f 2 + 2 f 3 + 4 f 4 + · · · + 2 f n − 1 + 4 f n + f n +1 3 a Numerical Integration 8 / 11

  24. Error Analysis (MA 428) Theorem a ≤ x ≤ b | f (4) ( x ) | ≤ M. Then the Simpson’s method has error Assuming max M ( b − a )(∆ x ) 4 180 Composite Simpson’s method has a convergence rate of O (∆ x ) 4 compared to Midpoint and Trapezoidal that are O (∆ x ) 2 . Numerical Integration 9 / 11

  25. Error comparison Comparison -2 Simpsons Midpoint Trapeziod -4 -6 log 10 ( error ) -8 -10 -12 -14 -16 -1 -1.5 -2 -2.5 -3 -3.5 -4 log 10 ( ∆ x ) Midpoint and Trapezoidal methods are second order in ∆ x i.e. O ((∆ x ) 2 ) Simpsons method is fourth order in ∆ x i.e. O ((∆ x ) 4 ) Numerical Integration 10 / 11

  26. Generalized formula Higher order methods of the form � b N � f ( x ) dx = f ( x i ) w i a i =1 These methods can be extended to 2 D and 3 D integrals (see MA 428). Numerical Integration 11 / 11

Recommend


More recommend