nd Simpson s
Mthemticl question we re interested in numericlly nswering How to we evlute I = f (x) dx? Clculus tells us tht if F(x) is the ntiderivtive of function f (x) on the intervl [, b], then I = f (x) dx = F (x) b = F (b) F (). Prcticlly, most integrls cnnot be evluted using this pproch. For exmple, 1 dx 1 + x 5 hs complicted ntiderivtive nd it esier to dopt numericl method to pproximte this integrl.
Integrtion: A Generl Frmework If you cnnot solve problem, then replce it with ner-by problem tht you cn solve! Our problem: Evlute I = f (x) dx. To do so, mny of the numericl schemes re bsed on replcing f (x) with some pproximte function f (x) so tht I f (x) dx = Ĩ. Exmple: f (x) could be n esy to integrte function pproximting f (x).
Integrtion: A Generl Frmework Then, the pproximtion error in this cse is E = I Ĩ = ( ) f (x) f (x) dx (b ) mx x b f (x) f (x) The inequlity bove tells us tht the pproximtion error E depends on: 1 the mximum error in the pproximting f (x) tht is mx x b f (x) f (x), nd 2 (b ), the width of the intervl. Next Gol: How to choose f (x)?
Polynomil Approximtions to f (x) Gol Choose n pproximtion f (x) to f (x) tht is esily integrble nd good pproximtion to f (x). Two nturl cndidtes: 1 Tylor polynomils pproximting f (x). One cvet: We need f (x) to hve derivtives t to exist of higher order to improve the pproximtion! 2 Interpolting polynomils pproximting f (x).
Exmple Exmple Consider evluting I = 1 e x2 dx Use the Tylor expnsion to pproximte f (x) = e x2. Tht is, f (x) = 1 + t + t2 2! + + tn n! + t n+1 (n + 1)! ec, t = x 2, }{{} reminder term R n(x) where c is n unknown number between nd t = x 2.
Solution Solution: I = + 1 1 Tking n = 3, we hve (1 + x 2 + x 4 x 2(n+1) (n + 1)! ec dx. 2! + + x 2n n! ) dx I = 1 + 1 3 + 1 1 + 1 + E = 1.4571 + E, 42 where E = 1 x 2(n+1) (n+1)! ec dx nd we need bound on this reminder term. < E e 24 1 x 8 dx = e 216 =.126.
Using Interpolting Polynomils In spite of the simplicity of the bove exmple, it is generlly more difficult to do numericl integrtion by constructing Tylor polynomil pproximtions thn by constructing polynomil interpoltes. Thus, we construct the function f (x) s the polynomil interpolting f (x) such tht f (x) dx f (x) dx. Cse I: Use liner interpolting polynomil p 1 (x) pproximting f (x) t two points. We pick nd b.
Using Liner Interpolting Polynomils f (x) = p 1 (x) where Thus, p 1 (x) = (b x)f () + (x )f (b). b f (x) dx p 1 (x) dx (b x)f () + (x )f (b) dx b [ ] f () + f (b) T 1 (f ) = b 2
Definition ( ) The integrtion rule f (x) dx b [ ] f () + f (b) = T 1 (f ) 2 is clled the trpezoidl rule.
Exmple using Exmple Evlute π/2 sin x dx using the trpezoidl rule. π/2 sin x dx π 4 [ ] sin + sin(π/2) = π/4.785. Since we know the true vlue I = π/2 sin x dx = cos(π/2) + cos() = 1, π/2 sin x dx T 1 (f ) = 1.785 =.215.
How to improve the ccurcy of the integrtion rule? An intuitive solution is to improve the ccurcy of f (x) by pplying the rule on smller subintervls of [, b] insted of pplying it to the originl intervl [, b] tht is pply it to integrls of f (x) on smller subintervls. For exmple, let c = +b 2 then, f (x) dx = c c 2 = h 2 f (x) dx + c [ f () + f (c) f (x) dx [ f () + 2f (c) + f (b) ] + b c 2 ] T 2 (f ), [ ] f (c) + f (b) where h = b 2.
Testing on the previous exmple Exmple Evlute I = π/2 sin x dx using the three point trpezoidl rule. Compute the pproximtion error I T 2 (f ). Plese use the Fundmentl theorem of clculus to directly clculte I. π/2 π/2 sin x dx π 8 [ ] sin + 2 sin(π/4) + sin(π/2).9481. sin x dx T 2 (f ) 1.9481 =.519.
Generl T n (f ) 1 We sw the trpezoidl rule T 1 (f ) for 2 points nd b. 2 The rule T 2 (f ) for 3 points involves three equidistnt points:, +b 2 nd b. 3 We observed the improvement in the ccurcy of T 2 (f ) over T 1 (f ) so inspired by this, we would like to pply this rule to n + 1 eqully spced points = x < x 1 < x 2 x n = b with the spce between ny two points being denoted by h tht is h = x i+1 x i, i =,, n.
Generl T n (f ) Definition [ 1 I h 2 f () + f (x 1) + f (x n 1 ) + f (b) ] T n (f ) 2 1 The subscript n refers to the number of subintervls being used; 2 the points x, x 1, x n re clled the numericl integrtion node points.
Performnce of T n (f ) f (x) = sin x we wnt to pproximte I = π/2 f (x) dx using the trpezoidl rule T n (f ) n T n (f ) I T n (f ) Rtio 1.785 2.15e-1 2.948 5.18e-2 4.13 4.987 1.29e-2 4.3 8.997 3.21e-3 4.1 16.999 8.3e-4 4. Note tht the errors re decresing by constnt fctor of 4. Why do we lwys double n?
How to improve the ccurcy of the integrtion rule? An intuitive solution is to improve the ccurcy of f (x) by using better interpolting polynomil sy qudrtic polynomil p 2 (x) insted. Let c = +b 2 nd h = b 2 then, the qudrtic polynomil is (x c)(x b) (x )(x b) p 2 (x) = f () + ( c)( b) (c )(c b) f (c) (x )(x c) + (b )(b c) f (b). f (x) dx = h 3 This is clled Simpson s rule. p 2 (x) dx [ ] f () + 4f (c) + f (b) S 2 (f ).
Simpson s rule pplied to the previous exmple Exmple Evlute π/2 sin x dx using the Simpson s rule. π/2 sin x dx π/2 [ ] sin + 4 sin(π/4) + sin(π/2) 3 1.227 π/2 sin x dx S 2 (f ) =.228.
Generl Simpson s S n (f ) Definition I h [ (f () + 4f (x1 ) + 2f (x 2 ) ) + 4f (x 3 ) + 2f (x 4 ) + 4f (x 5 ) 3 ] 4f (x n 1 ) + f (b) S n (f )
Performnce of S n (f ) For f (x) = sin x we wnt to pproximte I = π/2 f (x) dx using the Simpson s rule S n (f ) n S n (f ) I S n (f ) Rtio 2 1.227-2.28e-3 4 1.13-1.35e-4 16.94 8 1. -8.3e-6 16.22 16 1. -5.17e-7 16.6
Error Formuls: Theorem Let f (x) hve two continuous derivtives on [, b]. Then, E T n (f ) = f (x) dx T n (f ) = h2 (b ) f (c n ), 12 where c n lies in [, b]. The error decys in mnner proportionl to h 2. Thus doubling n (nd hlving h) should cuse the error to decrese by fctor of pproximtely 4. This is wht we observed with pst exmple.
Exmple Exmple Consider the tsk of evluting I = 2 dx 1 + x 2 using the trpezoidl rule T n (f ). How lrge should n be chosen in order to ensure tht E T n (f ) 5 1 6?
Exmple Proof. We begin by clculting the derivtives involved: f (x) = it is esy to check tht 2x (1 + x 2 ) 2, f 2 + 6x 2 (x) = (1 + x 2 ) 3, mx f (x) = 2 x 2 thus, En T (f ) = h2 (b ) f (c n ) 12 2h2 12 2 = h2 3. We bound f (c n ) since we do not know the exct vlue of c n nd hence, we must ssume the worst possible vlue of c n tht mkes the error formul the lrgest.
Proof Proof. When do we hve E T n (f ) 5 1 6? We need to choose h so smll tht h 2 3 5 1 6 which is possible if h.3873 (verify!). This is equivlent to choosing n = b h = 2 h 516.4. Thus, n 517 will mke the error smller thn 5 1 6.
Error Formuls: Simpson s Theorem Let f (x) hve four continuous derivtives on [, b]. Then, E S n (f ) = f (x) dx S n (f ) = h4 (b ) f (4) (c n ), 18 where c n lies in [, b]. The error decys in mnner proportionl to h 4. Thus doubling n should cuse the error to decrese by fctor of pproximtely 16. This is wht we observed with pst exmple.
Exmple Exmple Consider the tsk of evluting I = 2 dx 1 + x 2 using the Simpson s rule T n (f ). How lrge should n be chosen in order to ensure tht E S n (f ) 5 1 6?
Proof Proof. We compute the fourth derivtive f (4) (x) = 24 5x 4 1x 2 + 1 (1 + x 2 ) 5 mx f (4) (x) = f (4) () = 24. x 1 Thus, En S (f ) = h4 (b ) f (4) (c n ) 18 h4 2 4h4 24 = 18 15 5 1 6 provided h.658 or n 3.39, thus choosing n 32 will give the desired error bound. Compre with the trpezoidl rule: n 517!
One more exmple Consider the ppliction of trpezoidl rule to pproximte 1 x dx n En T (f ) Rtio En S (f ) Rtio 2 6.311e-2 2.86e-2 4 2.338e-2 2.7 1.12e-2 2.82 8 8.536e-3 2.77 3.587e-3 2.83 16 3.85e-3 2.78 1.268e-4 2.83 32 1.18e-3 2.8 4.485e-4 2.83 Observe tht the rte of convergence is slower since f (x) = x is not sufficiently differentible on [, 1]. Both converge t rte proportionl to h 1.5.