Chpter 3 Qudrture Formuls There re severl different methods for obtining the re under n unknown curve f(x) bsed on just vlues of tht function t given points. During our investigtions in this clss we will look t the following min ctegories for numericl integrtion:. Newton-Cotes formuls In this cse, we obtin methods for numericl integrtion which cn be derived from the Lgrnge interpolting method. Alterntively the formuls cn lso be derived from Tylor expnsion. The ide is similr to the wy we obtin numericl differentition schemes. We cn esily derive not just integrtion formuls but lso their errors using this technique. The schemes which we develop here will be bsed on the ssumption of equidistnt points.. Composite, Newton - Cotes formuls (open nd closed) These methods re composite since they repetedly pply the simple formuls derived previously to cover longer intervls. This ide llows for piecewise estimtes of the integrl thus improving the error of our integrtion. (we will lso ssume equidistnt nodes in our presenttion). 3. Romberg Integrtion This method llows us to improve the error of our integrtion methods by doing miniml extr work. The ide is relly bsed on the Richrdson extrpoltion which we sw erlier in the numericl differentition section. 4. Adptive Integrtion Here we re free to choose the points over which we clculte the numericl integrl of f(x) so s to minimize our error. Adptive integrtion does not therefore require equidistnt nodes. Thus if the function is not very smooth t some intervl the step size h of the numericl integrtion method decreses to mke sure we do not ccumulte too much error in our clcultion. 5. Gussin Integrtion We explore methods which cn chieve optiml error reduction provided we plce the nodes t specific loctions. Computing the best weights for our numericl qudrtures gurntees optiml pproximtion of our integrl. 36
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 37 3. Simple Newton-Cotes methods Following the ides developed erlier on numericl differentition, we use once gin Lgrnge interpolting polynomils s strting point in obtining numericl integrtion methods. In fct in this section we lern how to derive the well-known Trpezoidl, midpoint, nd Simpson formuls mong others, which you hve seen before in clculus clsses. As usul we strt with the Lgrnge interpolting formul including the error term, P n (x) = n i=0 f(x i )L i (x) + f (n+) (ξ) (n + )! n (x x i ) Simply integrting the bove will produce vriety of numericl integrtion methods bsed on the number of nodes used. Let us look t simple exmple of how exctly we cn obtin our first simple formul for integrtion. 3.. Trpezoidl Rule For this rule ll we need is to strt with the Lgrnge interpolting polynomil for just two points, = nd b = x. Thus the corresponding Lgrnge interpolting polynomil with trunction error is, P (x) = f( ) x x + f(x ) x + f () (ξ) (x )(x x ) x x where s usul ξ (, b). Integrting the bove between = nd x = b we obtin, P (x) dx = f( ) x x b dx + f(x ) x i=0 x dx + f () (ξ x! (x )(x x ) dx Note here tht the integrl pplies only on the x-vribles while we bring outside ll known vlues such s f( ), f(x ), f () (ξ) etc... Let us now integrte ech piece on the right hnd side, [f( ) (x x ) ( x ) + f(x ) (x ) (x ) + f ( () (ξ) x 3 3 (x )] x=x + ) + x x (3.) x= We cn in fct write the error term bove in simpler form, ( f () (ξ) x 3 3 (x )] x + ) + x x = f () (ξ) h3 6 ssuming first tht h = x nd lso using weighted version of the men vlue theorem for integrls. Therefore evluting expression (3.) t both end points we obtin our first formul for numericl integrtion for the unknown function f(x), x f(x) dx = x (f( ) + f(x )) h3 6 f () (ξ) = h (f() + f(x )) h3 6 f () (ξ) (3.) This is the well-known Trpezoidl rule for numericl integrtion. Note tht we hve n exct description of the error for this pproximtion. When will there be zero error involved in numericlly obtining the integrl of f(x)? Tht would be possible if the f () would be zero. Tht implies
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 38 Figure 3.: Trpezoidl rule. The integrl is found by estimting the re under the curve f(x) using the trpezoidl rule. Assuming tht h = x then A = h (f(b) + f()). tht we hve no error if we pproximte the integrl of functions which re of degree or smller. Remember tht this is the fmous trpezoidl rule. In other words it clcultes the derivtive bsed on the re of the trpezoid with heights f( nd f(x. It is cler, geometriclly t lest bsed on Figure 3., tht if the function is liner then clerly there would be no error involved in using this rule. 3.. Simpson s Rule Similrly we cn derive higher order integrtion scheme bsed on three points, x nd x of the Lgrnge interpolting polynomil. Tht will be the well-known Simpson rule. However, we will insted present more ccurte method for obtining Simpson s rule bsed on Tylor expnsion round the middle point x written with the error term up to forth order, f(x) = f(x ) + f (x )(x x ) + f (x ) (x x ) + f (3) (x ) (x x ) 3 + f (4) (ξ) (x x 4 ) 4 3! 4! Thus strting with the bove nd integrting from to x we obtin, x =b = f(x) dx = f(x ) x + f (3) (x ) 6 dx + f(x ) x x (x x ) 3 dx + f (4) (ξ) 4 x x dx + f (x ) x x (x x ) 4 dx (x x ) dx where gin using the weighted men vlue theorem for integrls nd h = x x = x = (b )/ we obtin, x f(x) dx = hf(x ) + h3 3 f (x ) + f (4) (ξ) h 5 60 Note however tht we hve n pproximtion for the second derivtive f (x ) = f() f(x ) + f(x ) h h f (4) (ξ ) bsed on the numericl differentition section. Thus putting this together our Simpson rule emerges: x ( ) f(x) dx = hf(x ) + h3 f(x0 ) f(x ) + f(x ) h 3 h f (4) (ξ ) + f (4) (ξ) h 5 60 = h ( 3 [f() + 4f(x ) + f(x )] h5 3 f (4) (ξ ) ) 5 f (4) (ξ)
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 39 In fct it cn be shown (using lternte techniques) tht the bove formul for Simpson s rule cn be improved in terms of writing down more concise error term s follows, x where ξ (, x ) s usul. f(x) dx = h 3 [f() + 4f(x ) + f(x )] h5 90 f (4) (ξ) Figure 3.: Simpson rule. The integrl is found by estimting the re under the curve f(x) using the Simpson rule. To do this we use three different points =, x nd x = b nd define h = x x = x. Then A = h 3 (f() + 4f(x ) + f(x )). Exmple Apply both trpezoidl nd Simpson s rule in order to pproximte the re of the function f(x) = x between x.30. Also obtin estimtes of the error you re committing from using either pproximtion. Solution Strting with the trpezoidl rule, A trp =.3 x dx h (.3 + ) where h =.3. Thus the re using the trpezoidl is, A trp =.3 (.3 + ) =.3063 Using Simpson s rule on the other hnd implies tht we use three points =, x =.5 nd x =.3 nd the following formultion A Simpson =.3 Note tht in fct the true re is, x dx =.5 3 ( 4.5 +.3) =.34847 A =.5 x dx =.349 To obtin the error due to the trpezoidl rule we first need to find n upper bound for the second derivtive of f in the intervl [,.3] s follows, f () (ξ) = 4 ξ 3 4 3 = 4
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 40 Therefore the error due to trpezoidl rule is found by obtining n upper bound, in bsolute vlue, for the following term h 3 6 f () (ξ).33 6 4 =.005. Thus the error in our trpezoidl pproximtions is t most.00 which grees with our findings since the difference from the true re nd the pproximte re is.3063.349 =.000443. Thus the error we relly mde ws.00044 insted of the mximum we could hve mde of.00. Similrly to find the error using Simpson s formul we first need to pproximte the forth derivtive f (4) (ξ) 5 6 ξ = 5 7 6 = 5 7 6 Therefore the error of our pproximtion is h5 90 f (4) (ξ).55 5 90 6 =.00000079 Note tht indeed our true error.34847.349 =.0000 is less thn the possible mximum error we could hve mde of.0000008. 3. Some theoreticl results Let us now look s usul t error formuls for generl integrtion formuls. We will refer from now on to integrtion formuls s qudrtures. The formuls presented thus fr re clled closed Newton-Cotes qudrtures. They re closed becuse the end points of the intervl of integrtion re included in the formul. Otherwise, if the end points re not included in the formul then we hve n open Newton-Cotes qudrture. Before exmining the generl error for our qudrture formuls we give definition which will help in understnding the ccurcy of our methods: Definition 3... The lgebric degree of ccurcy of qudrture formul is given by the power of the polynomil P n (x) for which the qudrture is exct. Tht is hs no error t ll. Note for exmple tht if we integrte the polynomil f(x) = 3 x in the intervl [, ] using the trpezoidl rule we obtin the following pproximtion, Note tht in fct the true integrl is, 3 x dx = [3x x 3 x dx h (f() + f()) = ( + ) = 3 ] = (6 ) (3 /) = 4.5 = 3/ Note tht in fct the trpezoidl rule seems to be exct for the polynomil f(x) = 3 x! This is true in generl for ny liner function nd the trpezoidl rule. It is exct for ll liner functions. If we try to do the sme thing for qudrtic function however we will soon discover tht the trpezoidl rule is not exct in tht cse. Therefore for the trpezoidl rule hs degree of ccurcy. See if you cn find out wht is the degree of ccurcy for Simpson s rule.
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 4 Let us now disply the error formuls for generl Newton-Cotes qudrture without proof. Theorem 3... Suppose the following qudrture formul for n + points xn n f(x) dx i f(x i ) Then the error involved is given by: For n even: i=0 Closed Newton-Cotes : error = h(n+3) f (n+) (ξ) (n + )! Open Newton-Cotes : error = h(n+3) f (n+) (ξ) (n + )! n 0 n+ t (t )... (t n) dt t (t )... (t n) dt For n odd: Closed Newton-Cotes : error = h(n+) f (n+) (ξ) (n + )! Open Newton-Cotes : error = h(n+) f (n+) (ξ) (n + )! n 0 n+ t(t )... (t n) dt t(t )... (t n) dt where ξ (, x n ) s usul. Here for closed qudrtures we use h = (x n )/n while for open we use h = (x n+ x )/(n + ). All in ll we present here few of the most commonly used Newton - Cotes formuls. Note tht some re closed while others re open: Midpoint: Trpezoidl: Simpson s: Simpson s 3/8 rule: x3 Higher order rule: x4 x x x f(x) dx = hf( ) + h3 x 3 f (ξ) f(x) dx h (f() + f(x )) h3 f (ξ) f(x) dx = h 3 (f() + 4f(x ) + f(x )) h5 90 (ξ) f(x) dx = 3h 8 (f() + 3f(x ) + 3f(x ) + f(x 3 )) 3h5 80 (ξ) x f(x) dx = 5h 4 (f() + f(x ) + f(x ) + f(x 3 )) + 95h5 44 f (4) (ξ)
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 4 3.3 Composite Qudrtures The problem of the Newton-Cotes type qudrtures is similr to the problem which we encountered with Lgrnge polynomils over lrge intervls or severl nodes. Lgrnge polynomils tend to disply high vrition under these conditions. Insted we used piecewise method to counter this problem (the piecewise spline interpoltion). Similrly here the Newton-Cotes formuls, which re essentilly derived from Lgrnge polynomils, re not suitble for lrge intervls or severl nodes. Insted we cn try piecewise pproch in order to reduce our errors. In essence we will still pply the sme Newton-Cotes qudrtures but over severl smller intervls insted of lrge one. Since finding the integrl of function is equivlent to dding the res over severl smller intervls then this procedure should work. Composite Trpezoidl Rule Let us strt by pplying the trpezoidl rule in ech of those subintervls. We cn prove the following results, Composite Trpezoidl Rule Theorem 3.3.. Suppose f C [, b]. Then the composite trpezoidl rule for n + points, =, x,..., x n = b is given by, [ ] b f(x) dx = h n (b )h f() + f(x j ) + f(b) f (ξ) j= where h = (b )/n, x j = + jh nd ξ (, b) s usul. Proof: Strting from the integrl we will split it into n subintervls, n f(x) dx = xj+ x j f(x) dx Now using the trpezoidl rule in the subintervl (x j, x j+ ) we cn replce the integrtion, n xj+ n [ (xj+ x j )( f(x) dx = f(xj ) + f(x j+ ) ) (x ] j+ x j ) 3 f (ξ) x j Let us first define h = x j+ x j nd then strt summing up this expression, collecting like terms when pplicble, n [ (xj+ x j )( f(xj ) + f(x j+ ) ) (x ] j+ x j ) 3 f (ξ) [ ] = h n n f( ) + f(x j ) + f(x n ) h 3 f (ξ) [ ] = h n f() + f(x j ) + f(b) h 3 n f (ξ) [ ] = h n f() + f(x j ) + f(b) (b )h f (ξ)
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 43 Using similr methods we cn prove the following two theorems: Composite Midpoint Rule: Theorem 3.3.. Suppose f C [, b]. Then the composite Simpson s rule for n + points, =, x,..., x n = b is given by, n/ f(x) dx = h f(x j ) (b )h f (ξ) 6 where h = (b )/(n + ), x j = + (j + )h for j =, 0,..., n, n + nd ξ (, b) s usul. Composite Simpson s Rule Theorem 3.3.3. Suppose f C 4 [, b]. Then the composite Simpson s rule for n + points, =, x,..., x n = b is given by, f(x) dx = h n/ n/ f() + f(x j ) + 4 f(x j ) + f(b) (b )h4 f (4) (ξ) 3 80 j= j= where h = (b )/n, x j = + jh nd ξ (, b) s usul. A simple exmple is in order here.
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 44 Exmple Find the re under the curve f(x) = cos(x) between 0 nd π/ using the midpoint rule with n error not to exceed.00. Solution Bsed on the midpoint rule, where = 0, x n = π/ nd π/ 0 n/ f(x) dx = h f(x j ) + x n h f (ξ) (3.3) 6 h = x n n + = π/ 0 n + The rel question here is how big should we tke n so tht our error will be less thn.00. Note tht the error using the midpoint rule is ( ) ( ) π/ 0 π/ 0 Error = f (ξ) 6 n + (π/ 0)3 6(n + ) M where M denotes the mximum vlue of, As result we need the error to be less thn.00 Solving the bove for n we obtin, f (ξ) = cos(ξ) M for ξ (0, π/) (π/) 3 6(n + ) = π 3 48(n + ).00 n π 3 48.00 = 3.4 Since n must be n integer we tke it to be n = 4. Let us check whether this is relly correct by evluting the numericl integrl from formul (3.3) with this vlue of n nd compring it with the exct vlue of the integrl. [ π/ cos(x) dx π ] cos(x j ) 0 = π[cos( ) + cos(x ) + cos(x 4 ) + + cos(x 0 ) + cos(x )] =.0006 Note tht the exct vlue of the integrl is π/ 0 cos(x) dx = Thus the ctul error we re committing is.0006.0 =.0006. This is indeed less thn.00 s we wished! Just to emphsize how ccurte this is let us lso clculte the midpoint pproximte
FMN050 Spring 04. Clus Führer nd Alexndros Sopskis pge 45 integrl for n = 3 which is one less thn wht we should use! In tht cse we find using the midpoint formul tht the pproximte integrl is.99868. This gives n error of.99868.0 =.00. Which is not enough to put us in the rnge of.00 mximum error. Thus indeed n = 4 ws just right in order to produce n error less thn.00. Pseudo-code The most common composite integrtion rule used in prctice is ctully Simpson s. We therefore presented below the pseudo-code for composite Simpson s rule on n subintervls: Suppose tht we wish to pproximte the following integrl. Let h = (b )/n. Initilize the following vribles: f(x) dx I 0 = f() + f(b) I = 0 I = 0 3. For i =,..., n do the following Let X = + ih If i is even then I = I + f(x) If i is odd then I = I + f(x) 4. Let I = h 3 (I 0 + I + I ) 5. Qudrture is finished. Result is I.