Mth B, lecture 4: Error bounds for numericl methods Nthn Pflueger 4 September 0 Introduction The five numericl methods descried in the previous lecture ll operte by the sme principle: they pproximte the integrl f(x)dx by dividing the intervl [, b] into n slices of equl width, nd pproximte the re under the curve in ech slice by ssuming tht the curve hs certin shpe (flt, liner, or qudrtic), nd pproximting the re by wht the re would be in this cse. Using ny of these numericl methods, it is necessry to understnd the error tht my result from these ssumptions. This lecture presents method for computing bounds on the error of ech numericl method. The objective of this topic is not tht you should remember these error bounds fter the course; in prctice, ny time you need to the vlue of n integrl, you will use mchine tht implements these methods (or even more sophisticted methods which we do not discuss). Rther, the objective is to fmilirize you with how these methods work, so tht you will be wre of the bsic qulittive spects of the methods tht mchines use. Furthermore, we wish to emphsize tht n pproximtion is useless without knowledge of its possible error, so tht you will lwys remember to demnd error bounds whenever you use pproximte methods. As secondry objective, we wish to use these methods nd their error bounds to illustrte how polynomils re, in some sense, the fundmentl functions in clculus; ech of these numericl methods hs the feture tht it is exct for polynomils of certin degree, nd its error cn be found by considering polynomils of higher degree. The bsic philosophy tht function cn be understood by mens of the polynomils it resembles is centrl feture of clculus, which will be mde especilly vivid by the development of Tylor series in couple weeks. The reding for tody is Gottlieb 6.. The homework is to do problems, 3, 4, 5 from 6., s well s Topic Outline. Summry of results We first recll the definitions of the five numericl methods discussed lst time. integrl: We re evluting the f(x)dx. In order to do this, divide the intervl [, b] on which the integrl is being computed into n pieces (where n cn be chosen to be nything), thus dividing the vlue of the integrl into n slices, with endpoints x 0, x,..., x n, s shown.
f(x)dx = = ( re under the curve in the k th slice ) k= xk k= x k f(x)dx Here we mke the following definitions. x 0 = x n = b x = (b )/n x k = + k x Thus [x 0, x ] is the intervl corresponding to the first slice, [x, x ] corresponds to the seconds slice, nd in generl [x k, x k ] corresponds to the k th slice. Using this nottion, the five numericl methods tht we consider cn be summrized s follows. Left pproximtion L n = Right pproximtion R n = Midpoint pproximtion M n = f(x k ) x k= f(x k ) x k= ( ) xk + x k f x k= Trpezoid pproximtion T n = (L n + R n ) = k= k= [f(x k ) + f(x k )] x Simpson s rule S n = 3 M n + 3 T n [ = f(x k + 4f 6 ( xk + x k ) ] + f(x k ) x Note tht both the trpezoid pproximtion nd Simpson s rule cn be defined either in terms of erlier pproximtions or directly in terms of vlues of the function f. Note lso tht ech pproximtion is sum of estimtes for individul slices, ech of which consists of the width of the slice times n estimte for the verge vlue of f on tht slice. The estimte for this verge vlue depends on the ssumed shpe of the function on the slice. The error bounds which we present will include constnt fctor determined by the size of some derivtive of f(x). We shll use the following nottion. The symbol M is clled Gothic M, or Germn M. It is frequently used by mthemticins in situtions where the ordinry letter M would be mbiguous, s it certinly would be here.
M = mx { f (x) : x in [, b]} M = mx { f (x) : x in [, b]} { } M 4 = mx f (4) (x) : x in [, b] Using this nottion, the error bounds tht we shll use re expressed by the following theorem (which will not be proved in clss). Theorem.. If the integrl f(x)dx is pproximted using the methods bove, then the following bounds hold. L n f(x)dx ( M (b ) /n = ) M ( x) n R n f(x)dx ( M (b ) /n = ) M ( x) n M n f(x)dx 4 M (b ) 3 /n (= ) 4 M ( x) 3 n T n f(x)dx M (b ) 3 /n (= ) M ( x) 3 n ( S n f(x)dx 80 M 4(b ) 5 /(n) 4 = ) 80 M 4( x/) 5 n The expressions in prentheses re included simply to show how much ech of the n slices contributes to the totl error of the pproximtion. The proof of the first two bounds is not difficult; we will sketch the rgument in section 4. The ltter three bounds re somewht more technicl, nd require the use of integrtion by prts. The prticulr forms of these bounds re not importnt (nd you will lmost certinly forget them fter the exm). However, the following fetures re importnt. The error terms hve constnt fctors coming from the mximum vlue of some derivtive of f(x). The better the pproximtion, the higher the derivtive which governs the error. The error bound shrinks s n grows. The better the pproximtion, the fster the error bound will shrink. Theorem., together with the qulittive descriptions discusses in the lst lecture, re summrized in the following tble. Remember tht the conditions under the columns overestimtes nd underestimtes must hold t ll points in the intervl [, b] in order to conclude whether the method gives n overestimte or underestimte. Method Overestimtes Underestimtes Error bound Left L n f (x) < 0 f (x) > 0 M (b ) /n Right R n f (x) > 0 f (x) < 0 M (b ) /n Midpoint M n f (x) < 0 f (x) > 0 4 M (b ) 3 /n Trpezoid T n f (x) > 0 f (x) < 0 M (b ) 3 /n Simpson S n f (4) (x) > 0 f (4) (x) < 0 80 M 4(b ) 5 /(n) 4 3
3 Exmples Exmple 3.. How ccurte will Simpson s rule be for n slices be in computing 0 x3 dx? The error bound is 80 M 4(b ) 5 /(n) 4. For this prticulr function, the fourth derivtive is 0, nd therefore M 4 = 0. Therefore the error bound is 0, no mtter which n is used. So Simpson s rule should be exctly correct for this integrl. This my seem too good to be true, so here is computtion, for n = (i.e. computtion of S ). By definition of Simpson s rule, S 4 = 6 (03 + 4 3 + 3 ) = (0 + 4 + 8) 6 = 4. Indeed, the stndrd clcultion shows tht 0 x3 dx = 4. Exmple 3.. Consider the integrl 0 e x dx. Determine sufficient number of slices for the midpoint pproximtion to be ccurte within 0.00. The error bound for M n is 4 M (b ) 3 /n. Since the length of the intervl is (b ) =, this is equl to 3 M /n in this cse. We need to select n n lrge enough tht this bound is no more tht 0.00, i.e. 000 3 M. So we simply need to find M. such tht 3 M /n 0.00. Equivlently, n 000 3 M, or n In fct, it is not necessry to find M exctly; n upper bound on M will do. To find such n upper bound, begin by computing derivtives of the function (detils of the computtion re omitted). f(x) = e x f (x) = ( x)e x f (x) = (4x )e x It would be hssle to ctully explicitly find the mximum of this second derivtive, so simply get n upper bound. For this purpose, observe tht for ll x, x 0, hence e x e 0 =. Therefore f (x) = (4x )e x 4x. Now, the function 4x is n incresing function on [0, ], with vlues rnging from to 4. Thus n upper bound on its size is 4. Tken together, this implies tht f (x) 4 on [0, ], nd thus M 4. Now, since this is n upper bound on M, if we cn ensure tht n 000 000 hve tht n 3 M, nd in turn tht the error of M n is less thn 0.00. Now 69 slices will be sufficient to ensure error of less thn 0.00 for the midpoint pproximtion. 3 4, then we will certinly 000 3 4 68.3. Thus Exmple 3.3. Consider the integrl dx x, whose exct vlue is equl to ln. Numericl methods give one wy to clculte this vlue to rbitrry ccurcy (better methods will come from the notion of Tylor series). How mny slices re needed in order to compute this integrl with error t most one millionth (tht is, 0 6 ), using the five numericl methods discussed? To begin, we need the mximum vlues M, M nd M 4, for which we need the derivtives of the function. 4
f(x) = /x f (x) = /x f (x) = /x 3 f (x) = 6/x 4 f (4) (x) = 4/x 5 Ech of these functions decrese in mgnitude s x increses, so ll of them hve mximum bsolute vlue t x =. From this we obtin the following vlues. M = M = M 4 = 4 From this, s well s the fct tht the length of the intervl is (b ) =, the following bounds for the error of ech pproximtion cn be found. L n ln M (b ) /n = n R n ln M (b ) /n = n M n ln 4 M (b ) 3 /n = n T n ln M (b ) 3 /n = 6n S n ln 80 M 4(b ) 5 /(n) 4 = 0n 4 Now, observe tht n 0 6 n 500, 000, thus 500, 000 slices will ensure tht L n nd R n re both within 0 6 of the true vlue. For the midpoint pproximtion, n 0 6 n 0 6 / n 0 6 / 88.7. So 89 slices will ensure tht M n is within 0 6 of the true vlue. For the trpezoid pproximtion, 6n 0 6 n 0 6 /6 n 0 6 /6 408.. So 409 slices will ensure tht T n is within 0 6 of the true vlue. For Simpson s rule, 0n 0 6 n 4 0 6 /0 n 4 0 6 /0 9.6. So 0 slices will ensure tht 4 S n is within 0 6 of the true vlue. As this result indictes, the error bounds gurntee much fster convergence for Simpson s rule thn the less sophisticted pproximtions. In fct, explicit computtion revels tht, in order to chieve error of less thn one millionth, only 7 slices re needed for Simpson (the bounds ensure tht 0 will work), 77 slices re needed for midpoint pproximtion (the bounds ensure tht 89 will work), nd 50 slices re needed for trpezoid pproximtion (the bounds ensure tht 409 will work). This illustrtes the fct tht the error bounds, while obviously not exct, give good rough ide for how mny slices re needed to chieve desired ccurcy of computtion. 5
4 Error of L n nd R n In order to understnd the error bound for left nd right pproximtion, we begin by considering the error of these pproximtions in the specil cse where f(x) is liner function, with slope m. Tht is, f (x) = m for ll x, where m is constnt. Then we cn see the error of the left pproximtion L n in the following picture. The left pproximtions L n undershoots the re of ech slice by precisely the re of one of the shdes tringles. Observe tht the bse of ech tringle is equl to the width of the slice, nmely x, nd the height must be equl to m x (where m is the slope of the function, i.e. the constnt vlue of its first derivtive). Therefore the re of ech shded tringle is ( x)(m x) = m( x). Since there re n such tringles, the totl error is precisely n m( x) = mn ( b n ) = m (b ) n. Becuse m is the vlue of f (x) t every point, m is equl to the vlue M, nd so in fct the error is precisely equl to the bound M (b ) n. Now suppose tht f(x) is ny function, not necessrily liner. Then lthough we cn no longer view the error s the res of right tringles, essentilly the sme technique will pply: since the function never grows t rte fster thn M, the error of pproximtion in ech slice is still bounded by the re of tringle with bse x nd height M x. A complete proof of the error bound cn be given by using the men vlue theorem; we omit the detils. The result is, s stted in section, b f(x)dx L n M (b ) /n. 5 Error of M n nd T n In this section, we give only rough sketch of the principles behind the error bounds for M n nd T n. To give complete detils would require somewht more technicl nottion thn seems pproprite t the moment. Consider the following imge, depicting the error of both the midpoint pproximtion nd trpezoid pproximtion on single slice. 6
Wht cn mke these errors s lrge s possible? First of ll, if f is liner in this slice, then both errors will be 0. So the error is governed by the second derivtive. The lrgest possible error will result when the function begins, t the lest end of the slice, by incresing (respectively, decresing) very quickly, turns round in the middle, nd then decreses (respectively, increses) rpidly to the other endpoint. Such behvior involves drmtic chnge in the first derivtive, i.e. lrge second derivtive. Upon formlizing this rough ide nd doing some (not entirely trivil) computtion, the following result cn be obtined. error in single slice for M n 4 M ( x) 3 error in single slice for T n M ( x) 3 Replcing x by (b )/n s usul, nd multiplying by n (since there re n slices, ech contributing some error) gives the error bounds from section. The get n ide for where the constnts 4 nd come from, you my evlute the error in the cse of qudrtic function, where these error bounds re exct. From this it follows (mong other things), the clssicl fct (known to the Greeks by much more elementry methods) tht the re of prbolic segment is equl to 3 of the bse times the height. 7