Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

08 numerical integration 2

763 views

Published on

Published in: Education, Technology
  • Be the first to comment

08 numerical integration 2

  1. 1. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Numerical Integration
  2. 2. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Objectives • The student should be able to – Understand the need for numerical integration – Derive the trapezoidal rule using geometric insight – Apply the trapezoidal rule – Apply Simpson’s rule
  3. 3. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Need for Numerical Integration! ( ) 6 11 01 2 1 3 1 23 1 1 0 231 0 2 =−      ++=       ++=++= ∫ x xx dxxxI ( ) 11 0 1 0 1 −−− −=−== ∫ eedxeI xx ∫ − = 1 0 2 dxeI x
  4. 4. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Area under the graph! • Definite integrations always result in the area under the graph (in x-y plane) • Are we capable of evaluating an approximate value for the area?
  5. 5. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Example • To perform the definite integration of the function between (x0 & x1), we may assume that the area is equal to that of the trapezium: ( ) ( )01 01 2 1 0 xx yy dxxf x x − + ≈∫
  6. 6. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Adding adjacent areas
  7. 7. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik The Trapezoidal Rule ( ) ( ) ( ) ( ) 2 2 12 12 01 01 yy xx yy xxI + −+ + −≈ Integrating from x0 to x2: ( ) ( ) ( ) ( ) 2 212112101001 yxxyxxyxxyxx I −+−+−+− ≈
  8. 8. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik The Trapezoidal Rule ( ) ( ) hxxxx =−=− 1201 If the points are equidistant 2 2110 hyhyhyhy I +++ ≈ ( )210 2 2 yyy h I ++≈
  9. 9. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Dividing the whole interval into “n” subintervals       ++≈ ∑ − = n n i i yyy h I 1 1 0 2 2
  10. 10. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik The Algorithm • To integrate f(x) from a to b, determine the number of intervals “n” • Calculate the interval length h=(b-a)/n • Evaluate the function at the points yi=f(xi) where xi=x0+i*h • Evaluate the integral by performing the summation       ++≈ ∑ − = n n i i yyy h I 1 1 0 2 2
  11. 11. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Note that X0=a Xn=b
  12. 12. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Example • Integrate • Using the trapezoidal rule • Use 2,3,&4 points and compare the results ∫= 1 0 2 dxxI
  13. 13. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution • Using 2 points (n=1), h=(1-0)/(1)=1 • Substituting: ( )21 2 1 yyI +≈ ( ) 5.010 2 1 =+≈I X Y 0 0 1 1 2 points, 1 interval
  14. 14. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution • Using 3 points (n=2), h=(1-0)/(2)=0.5 • Substituting: ( )321 2 2 5.0 yyyI ++≈ ( ) 375.0125.0*20 2 5.0 =++≈I X Y 0 0 0.5 0.25 1 1 3 points, 2 interval
  15. 15. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution • Using 4 points (n=3), h=(1-0)/(3)=0.333 • Substituting: ( )4321 22 2 333.0 yyyyI +++≈ ( ) 3519.01444.0*2111.0*20 2 333.0 =+++≈I X Y 0 0 0.33 0.111 0.667 0.444 1 1 4 points, 3 interval
  16. 16. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Simpson’s Rule Using a parabola to join three adjacent points!
  17. 17. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Working with three points! ( ) [ ]210 4 3 2 0 yyy h dxxf x x ++≈∫
  18. 18. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik For 4-Intervals ( ) [ ]432210 44 3 4 0 yyyyyy h dxxf x x +++++≈∫
  19. 19. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik In General: Simpson’s Rule ( )       +++≈ ∑∑∫ − = − = n n i i n i i x x yyyy h dxxf n 2 ,..4,2 1 ,..3,1 0 24 30 NOTE: the number of intervals HAS TO BE even
  20. 20. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Example • Integrate • Using the Simpson rule • Use 3 points ∫= 1 0 2 dxxI
  21. 21. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Solution • Using 3 points (n=2), h=(1-0)/(2)=0.5 • Substituting: • Which is the exact solution! ( )210 4 3 5.0 yyyI ++≈ ( ) 3 1 125.0*40 3 5.0 =++≈I
  22. 22. ENEM602 Spring 2007 Dr. Eng. Mohammad Tawfik Homework #7 • Chapter 21, pp. 610-612, numbers: 21.1, 21.3, 21.5, 21.25, 21.28. • Due date: Week 15-19 May 2005

×