Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Numerical Methods Part: Simpson Integration. 3 8 Rule For http://numericalmethods.eng.usf.edu For more details on this topic Go to http://numericalmethods.eng.usf.edu Click on Keyword You are free to Share – to copy, distribute, display and perform the work to Remix – to make derivative works Under the following conditions Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). Noncommercial — You may not use this work for commercial purposes. Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. Lecture # 1 Chapter 07.08: Simpson 3 8 Rule For Integration. Major: All Engineering Majors Authors: Duc Nguyen http://numericalmethods.eng.usf.edu Numerical Methods for STEM undergraduates 11/14/2011 http://numericalmethods.eng.usf.edu 5 Introduction The main objective in this chapter is to develop appropriated formulas for obtaining the integral expressed in the following form: b I = ∫ f ( x)dx a (1) where f (x) is a given function. Most (if not all) of the developed formulas for integration is based on a simple concept of replacing a given (oftently complicated) function f (x) by a simpler function (usually a polynomial function) fi (x) where i 6 represents the order of the polynomial function. In the previous chapter, it has been explained and illustrated that Simpsons 1/3 rule for integration can be derived by replacing the given function f (x) with the 2nd –order (or quadratic) polynomial function fi ( x) = f 2 ( x), defined as: f 2 ( x) = a0 + a1x + a2 x 7 2 (2) http://numericalmethods.eng.usf.edu 8 In a similar fashion, Simpson 3 8 rule for integration can be derived by replacing the given function f (x ) with the 3rd-order (or cubic) polynomial (passing through 4 known data points) function fi ( x ) = f3 ( x ) defined as f ( x) = a + a x + a x 2 + a x 3 3 0 1 2 3 a0 a (3) 1 2 3 = {1, x, x , x }× a 2 a3 which can also be symbolically represented in Figure 1. Method 1 The unknown coefficients a0 , a1 , a2 and a3 (in Eq. (3)) can be obtained by substituting 4 known coordinate data points {x0 , f ( x0 ), {x1 , f ( x1 )}, {x2 , f (x2 )} and {x3 , f (x3 )}} into Eq. (3), as following 9 f ( x0 ) = a0 + a1x0 + a2 x02 + a3 x02 f ( x1 ) = a0 + a1x1 + a2 x12 + a3 x12 (4) 2 2 f ( x2 ) = a0 + a1x2 + a2 x2 + a3 x2 2 2 f ( x3 ) = a0 + a1x3 + a2 x3 +http://numericalmethods.eng.usf.edu a3 x3 Eq. (4) can be expressed in matrix notation as 1 1 1 1 x0 x02 x1 x2 x3 x12 x22 x32 x03 a0 f ( x0 ) 3 a f ( x ) x1 1 1 = 3 a f ( x ) x2 2 2 3 a f ( x ) x3 3 3 (5) The above Eq. (5) can be symbolically represented as [A]4×4 a4×1 = f 4×1 10 (6) http://numericalmethods.eng.usf.edu Thus, a0 a 1 −1 a = = [ A] × f a2 a3 (7) Substituting Eq. (7) into Eq. (3), one gets { } f3 ( x ) = 1, x, x , x × [ A] 11 2 3 −1 ×f (8) http://numericalmethods.eng.usf.edu Remarks As indicated in Figure 1, one has x0 = a b − a 2a + b x1 = a + h = a + = 3 3 2b − 2a a + 2b x2 = a + 2h = a + = 3 3 3b − 3a x3 = a + 3h = a + =b 3 (9) With the help from MATLAB [2], the unknown vector a (shown in Eq. 7) can be solved. 12 http://numericalmethods.eng.usf.edu Method 2 Using Lagrange interpolation, the cubic polynomial function f i = 3 x that passes through 4 data points (see Figure 1) can be explicitly given as ( ) ( x − x1 )( x − x2 )( x − x3 ) × f ( x ) + ( x − x0 )( x − x2 )( x − x3 ) × f ( x ) 0 1 ( x0 − x1 )( x0 − x2 )( x0 − x3 ) ( x1 − x0 )( x1 − x2 )( x1 − x3 ) ( ( x − x0 )( x − x1 )( x − x3 ) x − x0 )( x − x1 )( x − x2 ) + × f ( x3 ) + × f ( x3 ) (x2 − x0 )(x2 − x1 )(x2 − x3 ) (x3 − x0 )(x3 − x1 )(x3 − x2 ) f3 ( x ) = (10) 13 http://numericalmethods.eng.usf.edu Simpsons 8 Rule For Integration 3 Thus, Eq. (1) can be calculated as (See Eqs. 8, 10 for Method 1 and Method 2, respectively): b b a a I = ∫ f ( x )dx ≈ ∫ f3 ( x )dx Integrating the right-hand-side equations, one obtains of the above { f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 )} I = (b − a ) × (11) 8 14 http://numericalmethods.eng.usf.edu b−a Since h = hence b − a = 3h , and the above 3 equation becomes: 3h I ≈ × { f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 )} 8 (12) The error introduced by the Simpson 3/8 rule can be derived as [Ref. 1]: (b − a ) × f ′′′′(ζ ) , where Et = − 6480 5 15 a ≤ζ ≤b (13) http://numericalmethods.eng.usf.edu Example 1 (Single Simpson 3 8 rule) Compute b = 30 140,000 I = ∫ 2000 ln − 9.8 x dx, 140,000 − 2100 x a =8 16 by using a single segment Simpson 3 8 rule Solution In this example: b − a 30 − 8 h= = = 7.3333 3 3 http://numericalmethods.eng.usf.edu 140000 x0 = 8 ⇒ f ( x0 ) = 2000 ln − 9.8 × 8 = 177.2667 140000 − 2100 × 8 x1 = x0 + h = 8 + 7.3333 = 15.3333 140000 f ( x1 ) = 2000 ln 140000 − 2100 × 15.3333 − 9.8 × 15.3333 = 372.4629 17 http://numericalmethods.eng.usf.edu x2 = x0 + 2h = 8 + 2(7.3333) = 22.6666 140000 ( ) = 2000 ln f x − 9.8 × 22.6666 = 608.8976 2 140000 − 2100 × 22.6666 x3 = x0 + 3h = 8 + 3(7.3333) = 30 140000 ( ) = 2000 ln f x − 9.8 × 30 = 901.6740 3 140000 − 2100 × 30 18 http://numericalmethods.eng.usf.edu Applying Eq. (12), one has: 3 I = × 7.3333 × {177.2667 + 3 × 372.4629 + 3 × 608.8976 + 901.6740} 8 I = 11063.3104 The “exact” answer can be computed as I exact = 11061.34 19 http://numericalmethods.eng.usf.edu 3. Multiple Segments for Simpson 3 8 Rule Using "n" = number of equal (small) segments, the width "h" can be defined as b−a h= 3 (14) Notes: n = multiple of 3 = number of small "h" segments 20 http://numericalmethods.eng.usf.edu The integral, shown in Eq. (1), can be expressed as b b a a I = ∫ f ( x )dx ≈ ∫ f3 ( x )dx I≈ 21 x3 x6 xn = b x0 = a x3 x n −3 ∫ f3 (x )dx + ∫ f3 (x )dx + ........ + ∫ f3 (x )dx (15) http://numericalmethods.eng.usf.edu Substituting Simpson 3 8 rule (See Eq. 12) into Eq. (15), one gets 3h f ( x0 ) + 3 f ( x1 ) + 3 f ( x2 ) + f ( x3 ) + f ( x3 ) + 3 f ( x4 ) + 3 f ( x5 ) + f ( x6 ) I= 8 + ..... + f ( xn −3 ) + 3 f ( xn − 2 ) + 3 f ( xn −1 ) + f ( xn ) (16) n−2 n −1 n −3 3h I = f ( x0 ) + 3 ∑ f ( xi ) + 3 ∑ f ( xi ) + 2 ∑ f ( xi ) + f ( xn ) 8 i =1, 4, 7 ,.. i = 2,5,8,.. i = 3, 6,9,.. (17) 22 http://numericalmethods.eng.usf.edu Example 2 (Multiple segments Simpson 3 8 rule) b = 30 140,000 Compute I = ∫ 2000 ln − 9.8 x dx, 140,000 − 2100 x a =8 3 using Simple 8 multiple segments rule, with number (of "h" ) segments = n = 6 (which corresponds to 2 “big” segments). 23 http://numericalmethods.eng.usf.edu Solution In this example, one has (see Eq. 14): 30 − 8 h= = 3.6666 6 {x0 , f (x0 )} = {8,177.2667} {x1, f (x1 )} = {11.6666,270.4104}; where x1 = x0 + h = 8 + 3.6666 = 11.6666 {x2 , f (x2 )} = {15.3333,372.4629}; where x2 = x0 + 2h = 15.3333 {x3 , f (x3 )} = {19,484.7455}; where x3 = x0 + 3h = 19 24 http://numericalmethods.eng.usf.edu {x4 , f (x4 )} = {22.6666,608.8976}; where x4 = x0 + 4h = 22.6666 {x5 , f (x5 )} = {26.3333,746.9870}; where x5 = x0 + 5h = 26.3333 {x6 , f (x6 )} = {30,901.6740}; where x6 = x0 + 6h = 30 25 http://numericalmethods.eng.usf.edu Applying Eq. (17), one obtains: n −2=4 n −1= 5 n − 3= 3 3 I = (3.6666)177.2667 + 3 ∑ f ( xi ) + 3 ∑ f ( xi ) + 2 ∑ f ( xi ) + 901.6740 8 i =1, 4,.. i = 2,5,.. i = 3, 6,.. 177.2667 + 3(270.4104 + 608.8976 ) + 3(372.4629 + 746.9870 ) I = (1.3750 ) + 2(484.7455) + 901.6740 I = 11,601.4696 26 http://numericalmethods.eng.usf.edu 3 1 Example 3 (Mixed, multiple segments Simpson 3 and 8 rules) b = 30 140,000 Compute I = ∫ 2000 ln − 9.8 x dx, 140,000 − 2100 x a =8 using Simpson 1/3 rule (with n1 = 4 small segments), and Simpson 3/8 rule (with n2 = 3 small segments). Solution: In this example, one has: 27 b−a b−a 30 − 8 h= = = = 3.1429 n n1 + n2 (4 + 3) http://numericalmethods.eng.usf.edu x0 = a = 8 x1 = x0 + 1h = 8 + 3.1429 = 11.1429 x2 = x0 + 2h = 8 + 2(3.1429) = 14.2857 Simpson 1 rule 3 x3 = x0 + 3h = 8 + 3(3.1429) = 17.4286 x4 = x0 + 4h = 8 + 4(3.1429) = 20.5714 x5 = x0 + 5h = 8 + 5(3.1429 ) = 23.7143 x6 = x0 + 6h = 8 + 6(3.1429 ) = 26.8571 x7 = x0 + 7 h = 8 + 7(3.1429 ) = 30 28 http://numericalmethods.eng.usf.edu 140,000 ( ) 8 2000 ln f x0 = = − 9.8 × 8 = 177.2667 140,000 − 2100 × 8 Similarly: f ( x1 = 11.1429 ) = 256.5863 f ( x2 ) = 342.3241 f ( x3 ) = 435.2749 f ( x4 ) = 536.3909 f ( x5 ) = 646.8260 f ( x6 ) = 767.9978 29 f ( x7 ) = 901.6740 http://numericalmethods.eng.usf.edu For multiple segments (n1 = first 4 segments ) using Simpson 1 rule, one obtains (See Eq. 19): 3 n1 −1= 3 n1 − 2 = 2 h I1 = f ( x0 ) + 4 ∑ f ( xi ) + 2 ∑ f ( xi ) + f xn1 3 i =1,3,... i = 2,... 3.1429 I1 = {177.2667 + 4(256.5863 + 435.2749) + 2(342.3241) + 536.3909} 3 I1 = 4364.1197 ( ) 30 http://numericalmethods.eng.usf.edu For multiple segments (n2 = last 3 segments ) using Simpson 3/8 rule, one obtains (See Eq. 17): n2 − 2 =1 n2 −1= 2 n2 − 3 = 0 3h I 2 = f ( x0 ) + 3 ∑ f ( xi ) + 3 ∑ f ( xi ) + 2 ∑ f ( xi ) + f xn1 8 i =1,3,... i = 2,... i = 3/ , 6/ ,... 3 I 2 = × 3.1429 {177.2667 + 3(256.5863) + 3(342.3241) + (skip!) + 435.2749} 8 I 2 = 6697.2748 ( ) The mixed (combined) Simpson 1/3 and 3/8 rules give: I = I1 + I 2 = 4364.1197 + 6697.2748 I = 11,061.3946 31 http://numericalmethods.eng.usf.edu Remarks: (a) Comparing the truncated error of Simpson 1/3 rule ( b − a) =− 5 Et 2880 × f ′′′′(ζ ) (18) With Simple 3/8 rule (See Eq. 13), the latter seems to offer slightly more accurate answer than the former. However, the cost associated with Simpson 3/8 rule (using 3rd order polynomial function) is significant higher than the one associated with Simpson 1/3 rule (using 2nd order polynomial function). 32 http://numericalmethods.eng.usf.edu (b) The number of multiple segments that can be used in the conjunction with Simpson 1/3 rule is 2,4,6,8,.. (any even numbers). h I1 = { f ( x0 ) + 4 f ( x1 ) + f ( x2 ) + f ( x2 ) + 4 f ( x3 ) + f ( x4 ) + ..... + f ( xn − 2 ) + 4 f ( xn −1 ) + f ( xn ) 3 n −1 n−2 h I 2 = f ( x0 ) + 4 ∑ f ( xi ) + 2 ∑ f ( xi ) + f ( xn ) 3 i =1,3,... i = 2, 4, 6... 33 (19) http://numericalmethods.eng.usf.edu However, Simpson 3/8 rule can be used with the number of segments equal to 3,6,9,12,.. (can be either certain odd or even numbers). (c) If the user wishes to use, say 7 segments, then the mixed Simpson 1/3 rule (for the first 4 segments), and Simpson 3/8 rule (for the last 3 segments). 34 http://numericalmethods.eng.usf.edu 4. Computer Algorithm For Mixed Simpson 1/3 and 3/8 rule For Integration Based on the earlier discussions on (Single and Multiple segments) Simpson 1/3 and 3/8 rules, the following “pseudo” step-by-step mixed Simpson rules can be given as Step 1 User’s input information, such as Given function f ( x ), integral limits " a, b", n1= number of small, “h” segments, in conjunction with Simpson 1/3 rule. 35 http://numericalmethods.eng.usf.edu n2 = number of small, “h” segments, in conjunction with Simpson 3/8 rule. Notes: n1 = a multiple of 2 (any even numbers) n2 = a multiple of 3 (can be certain odd, or even numbers) 36 http://numericalmethods.eng.usf.edu Step 2 Compute n = n1 + n2 b−a h= n x0 = a x1 = a + 1h x2 = a + 2h . . xi = a + ih . . 37 xn = a + nh = b http://numericalmethods.eng.usf.edu Step 3 Compute “multiple segments” Simpson 1/3 rule (See Eq. 19) n1 −1 n1 − 2 h I1 = f ( x0 ) + 4 ∑ f ( xi ) + 2 ∑ f ( xi ) + f ( xn ) 3 i =1,3,... i = 2, 4, 6... (19, repeated) 38 http://numericalmethods.eng.usf.edu Step 4 Compute “multiple segments” Simpson 3/8 rule (See Eq. 17) n2 − 2 n2 −1 n2 − 3 3h I 2 = f ( x0 ) + 3 ∑ f ( xi ) + 3 ∑ f ( xi ) + 2 ∑ f ( xi ) + f xn2 8 i =1, 4, 7... i = 2,5,8... i = 3, 6,9,... ( ) (17, repeated) Step 5 (20) I = I1 + I 2 and print out the final approximated answer for I. 39 http://numericalmethods.eng.usf.edu THE END http://numericalmethods.eng.usf.edu Acknowledgement This instructional power point brought to you by Numerical Methods for STEM undergraduate http://numericalmethods.eng.usf.edu Committed to bringing numerical methods to the undergraduate For instructional videos on other topics, go to http://numericalmethods.eng.usf.edu/videos/ This material is based upon work supported by the National Science Foundation under Grant # 0717624. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation. The End - Really