Inter - Bayamon Lecture MECN 3500 1 0 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo omeza@bayamon.inter.edu http://www.bc.inter.edu/facultad/omeza Department of Mechanical Engineering Inter American University of Puerto Rico Bayamon Campus Inter - Bayamon Tentative Lectures Schedule Topic Lecture Mathematical Modeling and Engineering Problem Solving 1 Introduction to Matlab 2 Numerical Error 3 Root Finding 4-5-6 System of Linear Equations 7-8 Least Square Curve Fitting 9 Numerical Integration 10 MECN 3500 Ordinary Differential Equations 2 Lecture 10 Inter - Bayamon Numerical Integration MECN 3500 Newton-Cotes Integration Formulas 3 Lecture 10 Inter - Bayamon MECN 3500 Course Objectives To solve numerical problems appreciate their applications engineering problem solving. 4 and for Lecture 10 Inter - Bayamon Introduction b a f ( x)dx area under the curve between a and b MECN 3500 • Indefinite integratio n : f ( x)dx b • Definite integratio n : f ( x)dx a Lecture 10 Inter - Bayamon They are based on the strategy of replacing a complicated function or tabulated data with an approximating function that is easier to integrate: b b a a I f ( x)dx f n ( x)dx where fn(x) is a polynomial of degree n. MECN 3500 f1(x) f2(x) Lecture 10 Inter - Bayamon MECN 3500 Piecewise functions can be used also to approximate the integral. 3 piecewise linear functions to approximate f(x) between a and b. Lecture 10 Inter - Bayamon MECN 3500 Two forms of the Newton-Cotes formulas: Closed Forms: the data points at the beginning and end of the limits of integration are known. Open Forms: integration limits extend beyond the range of the data. Lecture 10 Inter - Bayamon The Trapezoidal Rule The integral is approximated by a line: b b a a I f ( x)dx f1 ( x)dx MECN 3500 (b a ) f (a ) f (b) 2 Lecture 10 Inter - Bayamon Example 21.1 Statement: Use the trapezoidal rule to estimate 0.2 25x 200 x 0.8 2 675 x 3 900 x 4 400 x 5 dx 0 MECN 3500 Solution: f (a) f (b) I (b a) 2 f (0) f (0.8) (0.8 0) 2 0.2 0.232 0.8 2 0.1728 t 89.5% Lecture 10 Inter - Bayamon The Multiple-Application Trapezoidal Rule One way to improve the accuracy of the trapezoidal rule is to divide the integration interval from a to b into a number of segments and apply the method to each segment. MECN 3500 The areas of individual segments can then be added to yield the integral for the entire interval. Lecture 10 MECN 3500 Lecture 10 Inter - Bayamon MECN 3500 Lecture 10 Inter - Bayamon Inter - Bayamon The total integral is I x1 x2 xn x0 x1 xn1 f ( x)dx f ( x)dx f ( x)dx Substituting the trapezoidal rule for each integral: I h f ( x0 ) f ( x1 ) f ( xn 1 ) f ( xn ) f ( x1 ) f ( x2 ) h h 2 2 2 Grouping terms: MECN 3500 n 1 I h f ( x ) 2 f ( x ) f ( x ) 0 i n (b a ) 2 i 1 n 1 f ( x0 ) 2 f ( xi ) f ( xn ) i 1 2n Lecture 10 MECN 3500 15 Lecture 10 Inter - Bayamon Inter - Bayamon Example 21.1 Statement: Use the multiple-application trapezoidal rule for n = 2 to estimate 0.2 25x 200 x 0.8 MECN 3500 Solution: 2 675 x 3 900 x 4 400 x 5 dx 0 f ( x0 ) 2 f ( x1 ) f ( x2 ) I (b a) 2(2) f (0) 2 f (0.4) f (0.8) (0.8 0) 4 0.2 2(2.456) 0.232 0.8 4 1.0688 t 34.9% Lecture 10 MECN 3500 Lecture 10 Inter - Bayamon Inter - Bayamon MECN 3500 Computer Algorithms for the Trapezoidal Rule Lecture 10 Inter - Bayamon MECN 3500 Simpson’s Rules More accurate estimate of an integral is obtained if a high-order polynomial is used to connect the points. The formulas that result from taking the integrals under such polynomials are called Simpson’s rules. Lecture 10 Inter - Bayamon Simpson’s 1/3 Rule This rule results when a second-order interpolating polynomial is used. b b a a I f ( x)dx f 2 ( x)dx Let a x0 and b x2 , ( x x1 )( x x2 ) ( x x0 )( x x2 ) I f ( x0 ) f ( x1 ) ( x0 x1 )( x0 x2 ) ( x1 x0 )( x1 x2 ) x0 x2 MECN 3500 ( x x0 )( x x1 ) f ( x2 ) dx ( x2 x0 )( x2 x1 ) • After integration, I h f ( x0 ) 4 f ( x1 ) f ( x2 ) where 3 h ba 2 Lecture 10 MECN 3500 21 Lecture 10 Inter - Bayamon Inter - Bayamon Example 21.4 Statement: Single Application of Simpson’s 1/3 Rule f ( x) 0.2 25x 200 x 2 675x3 900 x 4 400 x 5 From a=0 to b=0.8. recall that the exact integral is 1.640533 Solution: MECN 3500 0.2 4(2.456) 0.232 I 0.8 1.367467 6 where Et 1.640533 1.367467 0.2730667, t 16.6% Which is approximately 5 times more accurate than for a single application of the trapezoidal rule (Example 21.1) Lecture 10 Inter - Bayamon Simpson’s 8/3 Rule This rule results polynomial is used. when b b a a a third-order interpolating I f ( x)dx f 3 ( x)dx This yields , MECN 3500 I 3h f ( x0 ) 3 f ( x1 ) 3 f ( x2 ) f ( x3 ) where 8 h ba 3 Lecture 10 MECN 3500 24 Lecture 10 Inter - Bayamon Inter - Bayamon Example 21.6 Statement: Single Application of Simpson’s 3/8 rule to integrate f ( x) 0.2 25x 200 x 2 675x3 900 x 4 400 x 5 From a=0 to b=0.8. Solution: Simpson’s rule 3/8 requires four equally spaced points: f (0) 0.2, f (0.2667) 1.432724, f (0.5333) 3.487177, f (0.8) 0.232 MECN 3500 I 0.8 where 0.2 3(1.432724 3.487177) 0.232 1.519170 8 Et 1.640533 1.519170 0.1213630, t 7.4% Lecture 10 Inter - Bayamon MECN 3500 Case Studies Statement: Estimate the cross section area of the stream. Lecture 10 Inter - Bayamon MECN 3500 • Consider this example Lecture 10 Inter - Bayamon • Trapezoidal rule (h = 4): 0 2(2 4 4 3.4) 0 I (20 0) 53.6 m 2 10 • Trapezoidal rule (h = 2): MECN 3500 0 2(1.8 2 4 4 6 4 3.6 3.4 2.8) 0 I (20 0) 63.2 m 2 20 Lecture 10 Inter - Bayamon MECN 3500 Software Integration with Matlab • Use quad for functions. Lecture 10 Inter - Bayamon MECN 3500 Homework8 www.bc.inter.edu/facultad/omeza Omar E. Meza Castillo Ph.D. 30 Lecture 10