Chpter 5. Numericl Integrtion These re just summries of the lecture notes, nd few detils re included. Most of wht we include here is to be found in more detil in Anton. 5. Remrk. There re two topics with similr nmes: Reverse of differentition Indefinite integrl f(x) dx = most generl ntiderivtive for f(x) Definite integrl This is relted to summtion (it is limit of sums of certin kind). The integrl sign ws originlly invented s modified S (for sum). There is no reson to expect connection between these two different things, but there is. See course S, the book by Anton or the ppendix for more detils. Wht we need is the ide of Riemnn sum. 5.2 The Definite Integrl. b b number nd does not involve x. Nottion is convenient. Grphicl interprettion: grph y = f(x), the x-xis nd the verticl lines x =, x = b. f(x) dx (red integrl from to b of the function f). Answer is f(x) dx is the re of the region in the plne bounded by the
2 2006 07 Mthemtics S3 (Timoney) (picture good for cse f(x) 0) Problems: need wy to compute the re of such shpe. More fundmentlly, need definition of wht you men by the re. 5.3 Nottion. We need nottion to write down formule for these pictures. Deling with b f(x) dx n subdivisions of intervl [, b] Number division point = x 0 < x < x 2 < < x n = b Heights of rectngles y j = f(x j), x j x j x j ny point. Are of jth rectngle = width height = (x j x j )y j Totl re = sum of these = y (x x 0 ) + y 2 (x 2 x ) + + y n (x n x n ) = f(x )(x x 0 ) + f(x 2)(x 2 x ) + + f(x n)(x n x n ) (clled Riemnn sums for the integrl)
Numericl Integrtion 3 5.4 Definition. b f(x) dx = limit of these Riemnn sums s n nd mx width 0. 5.5 Theorem (Importnt Theorem). This limit mkes sense if f is continuous on the finite closed intervl [, b] (including end points). Proof of this is too hrd for us. 5.6 Nottion. We cn use Sigm nottion for sums to mke the formule look shorter. For numbers u, u 2,..., u n 5.7 Exmples. u i mens u + u 2 + + u n i= 5 j 2 = 2 + 2 2 + 3 2 + 4 2 + 5 2 = + 4 + 9 + 6 + 25 = 55 j= 25 k= 2k 2 + k = (2 + ) + (2 2 2 + 2) + + (2(25) 2 + 25) 5.8 Remrk. Usul choice for Riemnn sums: ll n subintervls eqully wide. Common width is then h = b n Then x j = + jh for 0 j n Riemnn sum becomes f(x j)(x j x j ) = j= f(x j)h = h f(x j) j= j= Limit of these is the integrl. Limit hrd to find directly s rule, but computer cn find the sum for lrge n. 5.9 Trpezoidl Rule. The trpezoidl rule is technique for finding definite integrls b f(x) dx numericlly. It is one step more clever thn using Riemnn sums. In Riemnn sums, wht we essentilly do is pproximte the grph y = f(x) by step grph nd integrte the step grph. In the Trpezoidl rule, we pproximte y = f(x) by continuous grph mde up of bits of lines.
4 2006 07 Mthemtics S3 (Timoney) Use n equl divisions. h = b n. x i = + ih. Let y i = f(x i ) (for 0 i n). The trpezoidl rule formul cn be written b ( f(x) dx = h 2 y 0 + y + y 2 + y n + ) 2 y n. Proof (of this formul) uses re of ith trpezoid = h 2 (y i + y i ) 5.0 Exmple. Find 3 e x2 dx pproximtely using the Trpezoidl rule with n = 0. Solution: i x i y i Weight Weight y i 0.0 2.7828 /2.2 4.2207 2.4 7.0993 3.6 2.9358 4.8 25.5337 5 2.0 54.5982 6 2.2 26.469 7 2.4 37.348 8 2.6 862.642 9 2.8 2540.2 0 3.0 803.08 /2 Sum 8003.95 Sum times h is 600.79 5. Remrk. A nturl question to sk t this point is: how ccurte is the Trpezoidl rule?
Numericl Integrtion 5 Theoreticlly we know tht s n, the trpezoidl rule pproximtion b f(x) dx, but tht does not help us to know how close we re to the limit if we use n = 00 or n = 000. The following theorem gives worst cse scenrio. 5.2 Theorem. Let T n denote the result of using the trpezoidl rule formul with n steps to pproximte b f(x) dx. Then b f(x) dx T n b 2 h2 M 2 where M 2 is the lrgest vlue of f (2) (x) = f (x) for x b. Note: Cn rewrite this in terms of n using h = (b )/n. We won t prove this, or sy nything bout how to show it is true. 5.3 Exmple. (i) In 3 ex2 dx with n = 0 how fr off cn the trpezoidl rule be? Solution: For this we need to know M 2 nd tht involves f (x) with f(x) = e x2. f (x) = 2xe x2 f (x) = 2e x2 + 2x(2x)e x2 = (2 + 4x 2 )e x2 It is firly cler then tht (in this cse) f (x) > 0 lwys (so tht f (x) = f (x)) nd the lrgest vlue for 0 x 3 is M 2 = f (3) = 38e 9 = 30797. The theorem tells us then tht the pproximtion T 0 differs from the ctul integrl by t most (or t worst) 3 e x2 dx T 0 b 2 h2 M 2 = 3 2 h2 (30797). The vlue of h is h = b n (0.04)30797 = 2052.78. 6 = 3 0 = 0.2 nd so the error could be s lrge s (ii) How lrge should we chose n so tht the trpezoidl rule pproximtion T n to the sme integrl is certinly within 0.5 of the right vlue? Solution: It will certinly be enough to choose n so tht b 2 h2 M 2 = 3 ( ) 2 3 M 2 < 0.5 2 n Rerrnging this, it sys we re sfe if n > So n = 64 will certinly do. 6 (4)M 2/0.5 = 4 30797 = 640 3
6 2006 07 Mthemtics S3 (Timoney) 5.4 Simpsons Rule. Simpsons Rule is the next most sophisticted method fter the trpezoidl rule. With Riemnn sums we used pproximtion by step grphs (bits of constnt grphs one fter the other), with the trpezoidl rule we used bits of stright lines, nd now we use bits of qudrtic grphs y = x 2 + bx + c. The first problem is tht, while 2 points determine line, we need 3 points to pin down qudrtic grph. Then we lso need formul ( for the re under qudrtic grph (or the integrl of it) nlogous to the formul h 2 y 0 + ) 2 y we used for the re of trpezoid. 5.5 Lemm. If we hve 3 points in the plne with different x-coordintes, then there is exctly one qudrtic grph pssing through them. Proof. (just n ide of how it works) If the points re (x 0, y 0 ), (x, y ) nd (x 2, y 2 ) then one wy to find the qudrtic is to write it down vi the Lgrnge interpoltion formul q(x) = (x x )(x x 2 ) (x 0 x )(x 0 x 2 ) y 0 + (x x 2)(x x 0 ) (x x 2 )(x x 0 ) y + (x x 0)(x x ) (x 2 x 0 )(x 2 x ) y 2 Another pproch is to strt with generl q(x) = x 2 +bx+c nd use the 3 equtions q(x 0 ) = y 0, q(x ) = y, q(x 2 ) = y 2 to find, b, c. 5.6 Lemm. For 3 points eqully spced horizontlly (x 0, y 0 ) = (x h, y 0 ), (x, y ) nd (x 2, y 2 ) = (x + h, y 2 ) nd y = q(x) the qudrtic grph through the 3 points x +h ( q(x) dx = h 3 y 0 + 4 3 y + ) 3 y 2 x h Proof. We ll skip it. You cn find it in Anton. It is just bit messy, not relly complicted. It turns out to mke life lot esier if you ssume x = 0 nd this you cn ssume by shifting the y-xis. 5.7 Simpsons Rule. Ide: For b f(x) dx, choose n even nd preferbly lrge. Divide the intervl [, b] into n equl sections ech of width h = b n, division points x i = + ih (0 i n), corresponding vlues y i = f(x i ). Pir off intervls nd pproximte y = f(x) on ech pir by qudrtic grph. b f(x) dx = sum of integrls of these qudrtics. The formul we get out of this is b ( f(x) dx = h 3 y 0 + 4 3 y + 2 3 y 2 + 4 3 y 3 + + 2 3 y n 2 + 4 3 y n + ) 3 y n 5.8 Exmple. Find Solution: 3 e x2 dx pproximtely using Simpsons rule with n = 0.
Numericl Integrtion 7 i x i y i Weight Weight y i 0.0 2.7828 /3.2 4.2207 4/3 2.4 7.0993 2/3 3.6 2.9358 4/3 4.8 25.5337 2/3 5 2.0 54.5982 4/3 6 2.2 26.469 2/3 7 2.4 37.348 4/3 8 2.6 862.642 2/3 9 2.8 2540.2 4/3 0 3.0 803.08 /3 Sum 7288.84 Sum times h is 457.7 (nd this is the pproximte vlue for the integrl given by Simpson s rule). 5.9 Remrk. Now we sk bout the ccurcy of this method. Is it ny better fter the somewht greter compliction? 5.20 Theorem. Let S n denote the result of using Simpsons rule formul with n steps to pproximte b f(x) dx. Then b f(x) dx S n b 80 h4 M 4 where M 4 is the lrgest vlue of f (4) (x) for x b. Note: Cn rewrite this in terms of n using h = (b )/n. 5.2 Exmple. (i) In 3 ex2 dx with n = 0 how fr off cn Simpsons rule be? Solution: (detils not ll here) You cn find tht for f(x) = e x2, the fourth derivtive is f (4) (x) = (6x 4 + 48x 2 + 2)e x2 nd M 4 = 740e 9 =.40994 0 7. The theorem tells us then tht the pproximtion S 0 differs from the ctul integrl by t most (or t worst) 3 e x2 dx S 0 b 80 h4 M 4 = 3 80 h4 (.40994 0 7 ) The vlue of h is h = b = 3 n 0 90 (0.2)4 (.40994 0 7 ) = 250.655 = 0.2 nd so the error could be s lrge s (ii) How lrge should we chose n so tht Simpsons rule pproximtion S n to the bove integrl is certinly within 0.5 of the right vlue? Solution: It will certinly be enough to choose n so tht b 80 h4 M 4 = 3 ( ) 4 3 M 4 < 0.5 80 n
8 2006 07 Mthemtics S3 (Timoney) Rerrnging this, sys we re sfe if n > ( ) /4 90 (6)M 4/0.5 = 47.38 So n = 48 will certinly do. (Note how much smller this is thn 64 (needed for the trpezoidl rule in the sme sitution.) 5.22 Remrk. The methods we hve discussed were bout finding definite integrls numericlly. We will look lter t methods for finding ntiderivtives in firly systemtic wy. By the fundmentl theorem, if we cn find ntiderivtives we cn find definite integrls b f(x) dx nlyticlly (tht mens we cn come up with n exct formul for the vlue s opposed to numericl pproximte vlue). Our exmple 3 ex2 dx is one tht we will not ever be ble to do nlyticlly. 5.23 Remrk. In the trpezoidl rule, one rrely uses Theorem 5.2 to gurntee the desired ccurcy of the estimte T n. A more prgmtic pproch is to work with T 2, T 2 2 = T 4, etc until we get to vlue of T 2 k which hs stbilised nd where 2 k is resonbly big. There is wy to void mking the sme clcultions over nd over gin nd still to follow this strtegy. The point is tht if we did this for the exmple 3 f(x) dx (sy with the f(x) = ex2 bove), we would be clculting T = 3 2 ( 2 f() + ) 2 f(3) T 2 = 3 2 ( 2 2 f() + f(2) + ) 2 f(3) T 4 = 3 2 ( 4 2 f() + f(.5) + f(2) + f(2.5) + ) 2 f(3) Since we hve to reuse f() nd f(3) ech time, we might be tempted to remember the nswers. Then we need f(2) every time fter T 2 nd so we might like to keep record of the nswer to tht, nd so on. This involves lot of recording (uses up computer memory if we do it on computer) nd there is wy to void so much storge. It turns out tht T 2 = 2 T + 3 2 2 f(2) T 4 = 2 T 2 + 3 2 (f(.5) + f(2.5)) 4 Thus we cn clculte T 4 using only T 2 nd vlues of f(x) tht were not needed for T 2. This bit is not in the book by Anton, I think.
Numericl Integrtion 9 In generl, T 2n = 2 T n + b 2n f i= ( + i ( )) b nd we cn keep finding T, T 2, T 4 = T 2 2, T 8 = T 2 3,... without ny mssive storge requirement (nd without reclculting ny vlues of f(x) we hd to clculte previously). This gives n efficient prgmtic strtegy: Compute T, T 2, T 4 = T 2 2, T 8,... until we get to T n with some resonbly lrge n nd the vlue of T n is roughly equl to the vlue of T n/2. The chnces re tht both re then close to the true vlue of the integrl b f(x) dx. This is n experimentl pproch nd not quite method tht is gurnteed to be 00% right. 5.24 Remrk. As for the trpezoidl rule, one rrely uses Theorem 5.20 to gurntee the desired ccurcy of the estimte S n. A more prgmtic pproch is to work with S 2, S 2 2 = S 4, etc until we get to vlue of S 2 k which hs stbilised nd where 2 k is resonbly big. It turns out tht we cn mke use of the erlier efficient method of working out T, T 2, T 2 2 = T 4, etc together with the formul 2 2n This formul is esy to check. For exmple S 2n = 4 3 T 2n 3 T n T = b ( 2 f() + ) 2 f(b) T 2 = b ( ( 2 2 f() + f + b ) + 2 ) 2 f(b) S 2 = b ( 2 3 f() + 4 ( 3 f + b ) + 3 ) 2 f(b) 4 3 T 2 3 T = b ( 2 2 = S 2 3 f() + 4 3 f ( 3 f() + 3 f(b) 5.25 Exmple. Try out strtegy for our exmple 3 ex2 dx. 2 This bit is not in the book by Anton, I think. ( + b 2 )) ) + 2 3 f(b)
0 2006 07 Mthemtics S3 (Timoney) Appendix 5A.26 The Indefinite Integrl. We will explin the ide of n indefinite integrl by first giving n exmple. Every time you differentite something you know the ntiderivtive for the result. For exmple d dx (2x4 + 2x 3 7x 2 + x 7) = 8x 3 + 6x 2 4x + nd so if we hppen to wnt to know something tht hs derivtive 8x 3 + 6x 2 4x + we know tht 2x 4 + 2x 3 7x 2 + x 7 is such function. We cll it n n ntiderivtive of 8x 3 +6x 2 4x+ something which when differentited gives us 8x 3 + 6x 2 4x +. Now wht bout other possible ntiderivtives for the sme thing? We cn spot quite esily tht the constnt 7 is not very importnt. Any constnt there insted of 7 would still hve derivtive 0 nd so we relise tht nything of the form 2x 4 + 2x 3 7x 2 + x + C is lso n ntiderivtive for 8x 3 + 6x 2 4x +. In fct this is ll becuse if two functions f(x) nd g(x) hve the sme derivtive, in this cse if f (x) = g (x) = 8x 3 + 6x 2 4x + then d (f(x) g(x)) = 0 dx for ll x. The only functions tht re defined on n intervl nd hve derivtive 0 re constnt functions. So f(x) g(x) = C = constnt nd so f(x) = g(x) + C. This mens tht if we find one ntiderivtive (in our exmple 2x 4 + 2x 3 7x 2 + x 7) for the given function (in our exmple 8x 3 + 6x 2 4x + ) then the most generl one is of the form 2x 4 + 2x 3 7x 2 + x 7 + C. Since C 7 is nother constnt we cn write 8x 3 + 6x 2 4x + dx = 2x 4 + 2x 3 7x 2 + x + C. We cn go bout things bit more systemticlly, by strting with the simplest rules for differentition nd turning them into rules for finding ntiderivtives. (i) We know d dx xn = nx n nd so nx n dx = x n + C. For exmple, 4x 3 dx = x 4 + C. We cn use little ingenuity to find tht n ntiderivtive for x n is n xn (s long s n 0) nd we cn tidy this up to get the rule x n dx = n + xn+ + C (n ) It is perhps interesting to see tht we cn t immeditely write down x dx = /x dx. In fct the ntiderivtive for /x involves the nturl logrithm function ln nd is therefore much more complicted thing tht /x. We will leve this for lter.
Numericl Integrtion A detil we should mention, is tht when n < 0, x n is not well-behved t x = 0. So the domin is not n intervl but two intervls x < 0 nd x > 0. So, techniclly, the +C is not dequte in these cses to describe the most generl ntiderivtive. We could switch from one vlue of C to nother s we pss x = 0 nd still hve vlid ntiderivtive (when n < 0). However, people rrely go into this nd probbly you lmost never should encounter this in prctice. Becuse things blow up t x = 0 there should not relly be prcticl problem where x > 0 nd x < 0 re both vlid (when deling with x n nd n < 0). (ii) We know the derivtive of sum is the sum of the derivtives d du (u + v) = dx we cn see tht n ntiderivtive of sum is the sum of the ntiderivtives. Similrly for constnt multiples. + dv dx dx nd so Using these rules, we cn integrte ll polynomils. For exmple ( ) ( ) ( ) ( ) 5x 3 x 2 + 3x + 2 dx = 5 4 x4 3 x3 + 3 2 x2 + 2 x + C = 5 4 x4 3 x3 + 3 2 x2 + 2x + C (iii) From the rules for differentiting trigonometric functions d dx sin x = cos x, d dx cos x = sin x, d dx tn x = sec2 x we cn write down rules for integrting some cos x dx = sin x + C, sin x dx = cos x + C, sec 2 x dx = tn x + C With little guesswork we cn figure out some relted integrls like cos 3x dx We might think of sin 3x s possible ntiderivtive but d sin 3x = 3 cos 3x dx is 3 times wht we wnt. Since 3 is constnt, we cn divide cross by it nd we get cos 3x dx = sin 3x + C 3 However, there is no esy wy to do sec x dx (we will see wht the nswer to this is bit lter). We cn write sec x dx = cos x dx
2 2006 07 Mthemtics S3 (Timoney) nd we know how to integrte cos x but tht does not help. The is no good quotient rule for ntiderivtives. Unlike differentition, where we cn lern smll number of rules tht re enough to differentite lmost ny function we cn esily write down, there re esylooking functions where ntiderivtives re quite hrd to find. We hve seen /x dx, more recently sec x dx nd the exmple cos(x 2 ) dx is one tht is essentilly impossible. It is not tht there is no nswer. There is n ntiderivtive but it is known tht there is no wy to write finite formul for the ntiderivtive of cos(x 2 ) using the fmilir functions (powers, roots, frctions, trig functions, ln, e x ). 5A.27 Exmple. There re very few exmples which cn be worked out directly from the limit of Riemnn sums definition. This is one exmple 4 2 x + 2 dx Solution: Tke n lrge, n eqully wide subintervls of [, b] = [2, 4] with widths h = (b )/n = (4 2)/n = 2/n. This gives subdivision points x i = + ih = 2 + 2i for i = 0,, 2,..., n. To n mke life esy for ourselves we tke x i = x i = 2 + (2i)/n. The Riemnn sum is then ( ) 2i 2 f(x i )(x i x i ) = n + 2 n i= i= ( ) = 2 2i n n + 2 i= i= ( ) ( ) = 4 i + 2 2 n 2 n i= i= = 4 ( ) n(n + ) + 2 n 2 2 n (2n) ( = 2 + ) + 4 n 6 s n Here we used the fct tht i = + 2 + 3 + + n i= turns out to be n(n+) 2. This cn be discovered by writing the sum down bckwrds nd dding the two formule verticlly: s = + 2 + 3 + + n s = n + n + n 2 + + 2s = (n + ) + (n + ) + (n + ) + + (n + ) = n(n + )
Numericl Integrtion 3 In most exmples, we will not be ble to write the Riemnn sum s short formul in the wy we did here nd so we would not find the limit. 5A.28 Remrk. There is n mzing connection between definite integrls nd differentition, which we will now stte. It comes bout by considering not just one definite integrl b f(x) dx but whole infinite number of them. Not just 2 f(x) dx but x f(t) dt for 0 x 2. 0 0 5A.29 Theorem (Fundmentl Theorem of Integrl Clculus). Assume tht y = f(x) is continuous for x b. Consider A(x) = x f(t) dt for x b. (A(x) is new function, built from f nd definite integrtion.) Then A(x) is n ntiderivtive for f (tht is A (x) = f(x) for x b). In summry: ( d x ) f(t) dt = f(x) ( x b, if f continuous) dx This is one prt of the Fundmentl theorem, or one wy to stte it. 5A.30 Corollry. There is n ntiderivtive for every continuous function f. 5A.3 Exmple. Find d ( x ( ) ) t 3 cos dt dx t 8 + Solution: By the theorem ( d x ( ) ) t 3 x 3 cos dt = cos dx t 8 + x 8 + 5A.32 Theorem (Other prt of fundmentl theorem). Assume tht y = f(x) is continuous for x b nd suppose g(x) is n ntiderivtive for f(x) (tht is g (x) = f(x) for x b). Then b f(x) dx = g(b) g()= [g(x)] b x=
4 2006 07 Mthemtics S3 (Timoney) 5A.33 Exmple. Find 4 2 2x + dx Solution: Antiderivtive g(x) = x 2 + x (since g (x) = 2x + ) nd so 4 2 2x + dx = [g(x)] 4 x=2 = [x 2 + x] 4 x=2 = (4 2 + 4) (2 2 + 2) = 4 Proof. (of A (x) = f(x) prt of Fund. Thm.) Use first principles x+h x A (x) = lim h 0 A(x + h) A(x) h f(t) dt = f(x)h for h smll. Thus limit is f(x). = lim h 0 Proof. (of b f(x) dx = g(b) g() prt) We know A(x) = x f(t) dt is n ntiderivtive. Hence x+h x f(t) dt h d (A(x) g(x)) = f(x) f(x) = 0. dx Thus A(x) g(x) = c = const. Use x = to find constnt: A() g() = c. But A() = f(t) dt = 0. Thus g() = c nd A(x) g(x) = c = g() for ll x [, b]. Use this for x = b to get A(b) g(b) = g(), A(b) = g(b) g(), tht is b f(t) dt = g(b) g(). 5A.34 Correction. Correction to (or refinement of) grphicl interprettion of definite integrls. b f(x) dx = re under grph is good when f(x) 0 lwys. When f(x) < 0, tht prt of the re is counted with minus sign. Consider negtive terms in Riemnn sum f(x i )(x i x i ) if f(x i ) < 0. i=
Numericl Integrtion 5 b f(x) dx = (sum of res where f(x) > 0) (sum where f(x) < 0) 5A.35 Nottion. There is one more thing we hve skimmed over. When > b, there is convention tht llows us to write b f(x) dx (for exmple 2 x dx) even though the limits re upside down. By convention, the mening for this is b f(x) dx = b f(x) dx if > b 3 x2 + This convention comes up in the proof of the fundmentl theorem (the prt where A(x + h) A(x) = x+h f(t) dt, where we hve to be ble to del with h < 0 s well s h > 0). x In fct the fundmentl theorem in the form ( d x ) f(t) dt = f(x) dx is lso vlid for x < s long s f is continuous on n intervl tht includes both nd x. (The importnt thing is to hve ll points in between s well s nd x.) The convention lso fits with the other form of the fundmentl theorem. If g (x) = f(x), then remins true when > b. b 5A.36 Exmples. (i) Find d dx Solution: ( d 0 dx x f(x) dx = [g(x)] b x= = g(b) g() ( 0 x ) t t 6 + dt ) t t 6 + dt = d ( x dx 0 using the bove convention nd the Fundmentl theorem. ) t t 6 + dt = x x 6 +
6 2006 07 Mthemtics S3 (Timoney) ( ) (ii) Find d x 3 +x cos(t 2 + 4) dt dx Solution: Tke y = x 3 +x cos(t 2 + 4) dt = Chin rule dy dx = dy du nd by the Fundmentl theorem u cos(t 2 + 4) dt where u = x 3 + x. By the du dx = dy du (3x2 + ) dy du = cos(u2 + 4) = cos((x 3 + x) 2 + 4) Putting these together, we get ( ) d x 3 +x cos(t 2 + 4) dt = (3x 2 + ) cos((x 3 + x) 2 + 4) dx ( ) Notice tht the nswer would hve been the sme for d x 3 +x cos(t 2 + 4) dt, s the dx 25 vlue of the lower limit of the integrl does not come into the nswer (s long s it is constnt nd s long s the integrnd is continuous wherever we go). Richrd M. Timoney Mrch 7, 2007