Chapter 07.02 Trapezoidal Rule of Integration
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 07.02 Trapezoidal Rule of Integration After reading this chapter, you should be able to: 1. derive the trapezoidal rule of integration, 2. use the trapezoidal rule of integration to solve problems, 3. derive the multiple-segment trapezoidal rule of integration, 4. use the multiple-segment trapezoidal rule of integration to solve problems, and 5. derive the formula for the true error in the multiple-segment trapezoidal rule of integration. What is integration? Integration is the process of measuring the area under a function plotted on a graph. Why would we want to integrate a function? Among the most common examples are finding the velocity of a body from an acceleration function, and displacement of a body from a velocity function. Throughout many engineering fields, there are (what sometimes seems like) countless applications for integral calculus. You can read about some of these applications in Chapters 07.00A-07.00G. Sometimes, the evaluation of expressions involving these integrals can become daunting, if not indeterminate. For this reason, a wide variety of numerical methods has been developed to simplify the integral. Here, we will discuss the trapezoidal rule of approximating integrals of the form b I = ∫ f (x)dx a where f (x) is called the integrand, a = lower limit of integration b = upper limit of integration What is the trapezoidal rule? The trapezoidal rule is based on the Newton-Cotes formula that if one approximates the integrand by an n th order polynomial, then the integral of the function is approximated by 07.02.1 07.02.2 Chapter 07.02 the integral of that n th order polynomial. Integrating polynomials is simple and is based on the calculus formula. Figure 1 Integration of a function b n+1 n+1 n b − a ∫ x dx = , n ≠ −1 (1) a n +1 So if we want to approximate the integral b I = ∫ f (x)dx (2) a to find the value of the above integral, one assumes f (x) ≈ f n (x) (3) where n−1 n f n (x) = a0 + a1 x + ... + an−1 x + an x . (4) th where f n (x) is a n order polynomial. The trapezoidal rule assumes n = 1, that is, approximating the integral by a linear polynomial (straight line), b b ≈ ∫ f (x)dx ∫ f1 (x)dx a a Derivation of the Trapezoidal Rule Method 1: Derived from Calculus b b ≈ ∫ f (x)dx ∫ f1 (x)dx a a b = + ∫ (a0 a1 x)dx a b 2 − a 2 = − + a0 (b a) a1 (5) 2 Trapezoidal Rule 07.02.3 But what is a0 and a1 ? Now if one chooses, (a, f (a)) and (b, f (b)) as the two points to approximate f (x) by a straight line from a to b , f (a) = f1 (a) = a0 + a1a (6) f (b) = f1 (b) = a0 + a1b (7) Solving the above two equations for a1 and a0 , f (b) − f (a) a = 1 b − a f (a)b − f (b)a a = (8a) 0 b − a Hence from Equation (5), b f (a)b − f (b)a f (b) − f (a) b 2 − a 2 ∫ f (x)dx ≈ (b − a) + (8b) a b − a b − a 2 f (a) + f (b) = (b − a) (9) 2 Method 2: Also Derived from Calculus f1 (x) can also be approximated by using Newton’s divided difference polynomial as f (b) − f (a) f (x) = f (a) + (x − a) (10) 1 b − a Hence b b ≈ ∫ f (x)dx ∫ f1 (x)dx a a b f (b) − f (a) = ∫ f (a) + (x − a)dx a b − a b f (b) − f (a) x 2 = f (a)x + − ax b − a 2 a 2 2 f (b) − f (a) b a 2 = f (a)b − f (a)a + − ab − + a b − a 2 2 f (b) − f (a) b 2 a 2 = f (a)b − f (a)a + − ab + b − a 2 2 f (b) − f (a) 1 2 = f (a)b − f (a)a + (b − a) b − a 2 1 = f (a)b − f (a)a + ( f (b) − f (a))(b − a) 2 07.02.4 Chapter 07.02 1 1 1 1 =fab()() − faa + fbb() − fba() − fab() + faa() 2 2 2 2 1 1 1 1 =fab() − faa() + fbb() − fba() 2 2 2 2 f()() a+ f b =()b − a (11) 2 This gives the same result as Equation (10) because they are just different forms of writing the same polynomial. Method 3: Derived from Geometry The trapezoidal rule can also be derived from geometry. Look at Figure 2. The area under the curve f1 () x is the area of a trapezoid. The integral b ∫ f() x dx ≈ Area of trapezoid a 1 = (Sum of length of parallel sides)(Perpendicular distance between parallel sides) 2 1 =()f()()() b + f a b − a 2 f()() a+ f b =()b − a (12) 2 Figure 2 Geometric representation of trapezoidal rule. Method 4: Derived from Method of Coefficients The trapezoidal rule can also be derived by the method of coefficients. The formula b b− a b− a ∫ f() x dx ≈ f() a + f() b (13) a 2 2 2 = ∑ci f() x i i=1 where b− a c1 = 2 Trapezoidal Rule 07.02.5 b − a c2 = 2 = x1 a = x2 b Figure 3 Area by method of coefficients. The interpretation is that f (x) is evaluated at points a and b , and each function evaluation b − a is given a weight of . Geometrically, Equation (12) is looked at as the area of a 2 trapezoid, while Equation (13) is viewed as the sum of the area of two rectangles, as shown in Figure 3. How can one derive the trapezoidal rule by the method of coefficients? Assume b = + ∫ f (x)dx c1 f (a) c2 f (b) (14) a b b Let the right hand side be an exact expression for integrals of ∫1dx and ∫ xdx , that is, the a a formula will then also be exact for linear combinations of f (x) = 1 and f (x) = x , that is, for f (x) = a0 (1) + a1 (x) . b = − = + ∫1dx b a c1 c2 (15) a b b 2 − a 2 = = + ∫ xdx c1a c2b (16) a 2 Solving the above two equations gives b − a c = 1 2 b − a c = (17) 2 2 Hence 07.02.6 Chapter 07.02 b b − a b − a ∫ f (x)dx ≈ f (a) + f (b) (18) a 2 2 Method 5: Another approach on the Method of Coefficients The trapezoidal rule can also be derived by the method of coefficients by another approach b b − a b − a ∫ f (x)dx ≈ f (a) + f (b) a 2 2 Assume b = + ∫ f (x)dx c1 f (a) c2 f (b) (19) a Let the right hand side be exact for integrals of the form b + ∫ (a0 a1 x)dx a So b b x 2 + = + ∫ (a0 a1 x)dx a0 x a1 a 2 a b 2 − a 2 = − + a0 (b a) a1 (20) 2 But we want b + = + ∫ (a0 a1 x)dx c1 f (a) c2 f (b) (21) a to give the same result as Equation (20) for f (x) = a0 + a1 x . b + = + + + ∫ (a0 a1 x)dx c1 (a0 a1a) c2 (a0 a1b) a = a0 (c1 + c2 )+ a1 (c1a + c2b) (22) Hence from Equations (20) and (22), b 2 − a 2 − + = + + + a0 (b a) a1 a0 (c1 c2 ) a1 (c1a c2b) 2 Since a0 and a1 are arbitrary for a general straight line c1 + c2 = b − a b 2 − a 2 c a + c b = (23) 1 2 2 Again, solving the above two equations (23) gives b − a c = 1 2 b − a c = (24) 2 2 Trapezoidal Rule 07.02.7 Therefore b ≈ + ∫ f (x)dx c1 f (a) c2 f (b) a b − a b − a = f (a) + f (b) (25) 2 2 Example 1 The vertical distance covered by a rocket from t = 8 to t = 30 seconds is given by 30 140000 x = ∫2000ln − 9.8t dt 8 140000 − 2100t a) Use the single segment trapezoidal rule to find the distance covered for t = 8 to t = 30 seconds. b) Find the true error, Et for part (a). c) Find the absolute relative true error for part (a). Solution f (a) + f (b) a) I ≈ (b − a) , where 2 a = 8 b = 30 140000 f (t) = 2000ln − 9.8t 140000 − 2100t 140000 f (8) = 2000ln − 9.8(8) 140000 − 2100(8) = 177.27 m/s 140000 f (30) = 2000ln − 9.8(30) 140000 − 2100(30) = 901.67 m/s 177.27 + 901.67 I ≈ (30 − 8) 2 = 11868 m b) The exact value of the above integral is 30 140000 x = ∫2000ln − 9.8t dt 8 140000 − 2100t = 11061 m so the true error is Et = True Value – Approximate Value = 11061−11868 = −807 m 07.02.8 Chapter 07.02 c) The absolute relative true error, ∈t , would then be True Error ∈ = ×100 t True Value 11061−11868 = ×100 11061 = 7.2958% Multiple-Segment Trapezoidal Rule In Example 1, the true error using a single segment trapezoidal rule was large. We can divide the interval [8,30] into [8,19] and [19,30] intervals and apply the trapezoidal rule over each segment. 140000 f (t) = 2000ln − 9.8t 140000 − 2100t 30 19 30 ∫ f (t)dt = ∫ f (t)dt + ∫ f (t)dt 8 8 19 f (8) + f (19) f (19) + f (30) ≈ (19 − 8) + (30 −19) 2 2 f (8) = 177.27 m/s 140000 f (19) = 2000ln − 9.8(19) = 484.75 m/s 140000 − 2100(19) f (30) = 901.67 m/s Hence 30 177.27 + 484.75 484.75 + 901.67 ∫ f (t)dt ≈ (19 − 8) + (30 −19) 8 2 2 = 11266 m The true error, Et is Et = 11061−11266 = −205 m The true error now is reduced from 807 m to 205 m.