You are on page 1of 18
4.4 Composite Numerical Integration The Newton-Cotes formulas are generally unsuitable for use over large integration inter- vals. High-degree formulas would be required, and the values of the coefficients in these formulas are difficult to obtain. Also, the Newton-Cotes formulas are based on interpola- tory polynomials that use equally-spaced nodes, a procedure that is inaccurate over large intervals because of the oscillatory nature of high-degree polynomials. In this section, we discuss a plecewise approach to numerical integration that uses the low-order Newton-Cotes formulas. These are the techniques most often applied. Example 1 Use Simpson's rule to approximate [* e* de and compare this to the results obtained by adding the Simpson's rule approximations for fe dv and /,' e* dx. Compare these approximations to the sum of Simpson's rule for fi) e* de, fj e* dx, [2 e* de, and J e* dx. Solution Simpson's rule on [0,4] uses = 2 and gives f de® feltse +4) = 56.76958. lo The exact answer in this ease is e* than we would normally accept. Applying Simpson’s rule on each of the intervals (0,2] and [2,4] uses lk = 1 and gives, “4 2 4 fewn Peas f de 1 1 x zl tdere)asle +4e? +4) 53.59815, and the error ~3.17143 is far larger 1 ade = (OHA tet +4 bet) = 53.86385. The error has been reduced to —0.26570, For the integrals on (0, 1],[1,2],{3,4], and [3,4] we use Simpson's rule four times with ea 2 giving 4 1 2 3 4 [ean fewsf cas f eas Pea | “6 h 2 1 3/24 on the +e) +o (et der? +e%) Lis paseeeyel(egarrge + Z(C +4 He) + T(E 4 He) 1 5 +4e'l? + 2e + de? + 2c? +4e%? + 208 + 4e7? + 4) = 53.6162. The error for this approximation has been reduced to —0.01807. & To generalize this procedure for an arbitrary integral f ‘f(x)de, choose an even integer n. Subdivide the interval [a,] into n subintervals, and apply Simpson's rule on each consecutive pair of subintervals. (See Figure 4.7.) Figure 47 Theorem 44 Let f € Ci{a,b].n be even, h = (b —a)/n, and x; = a+ jh for each j = 0,1,....0. There exists a 4. € (a,b) for which the Composite Simpson’s rule for subintervals can be written with its error term as =” ee a os 2 _ f faydr=f [rss > ren e4§soan94 10) — Feat pO). . Composite Simpson’s Rule To approximate the integral 1 =f? f(x) dx: INPUT endpoints a,); even positive integer n. OUTPUT approximation X7 to 7. Step1 Seth =(b—a)/n Step2 Set X10 = f(a) + f(b): xn (Summation of f (x2:-1).) XI2=0. (Summation of f (x2).) Step 3 For i =1,....»—1 do Steps 4 and 5. Step 4 Sex =a+ih. Step 5 If iis even then set X72 = X/2 + F(X) else set X71 = XI1 + f(X). Step 6 Set x1 = h(x10 +2-x12 +4. xi1)/3. Step 7 OUTPUT (x1); STOP. ‘The subdivision approach can be applied to any of the Newton-Cotes formulas. The extensions of the Trapezoidal (see Figure 4.8) and Midpoint rules are given without proof. ‘The Trape7oidal rule requires only one interval for each application, so the integer m can be either odd or even, Theorem 45 Let f ¢ C*[a,b], h = (b—a)/n, and x; = a+ jh, for each j = 0, 1,...,n. There exists apt € (a,b) for which the Composite Trapezoldal rule for m subintervals can be written with its crror term as - h = b-a,., f Sear= [so s2Bse0 + vo] Ser. . Figuro 48 ves For the Composite Midpoint rule, n must again be even. (See Figure 4.9.) Figure 49 va v=o) x, b= a=x1 my Xy-1ty Aye Theorem 46 Let f < Cab], n be even, h = (b ~a)/(n + 2), and x; = a + (+ I)h for each j = —1,0,....n + 1. There exists a 4 € (a,4) for which the Composite Midpoint rule for n + 2 subintervals can be written with its error term as nh » | F(x) de = HY flor) + = j= Scanned with CamScanner Scanned with CamScanner 45 Romberg Integration In this section we will illustrate how Richardson extrapolation applied to results from the Composite Trapezoidal rule can be used to obtain high accuracy approximations with little computational cost. In Section 4.4 we found that the Composite Trapezoidal rule has a truncation error of order O(H?). Specifically, we showed that for it = (b — a) /n and x, = a +h we have . get =a) fe [oat [roa rare ra Soop for some number j1 in (a,b. By an alternative method it can be shown (see [RRI, pp. 136-140), that if f € C*[a.b]. the Composite Trapezoidal rule can also be written with an error term in the form . = f fx) de = : [i #25) rane. + KP + KN + K+, (4.33) ‘Toapproximate the integral /-” f (x) dx weuse the results of the Composite Trapezoidal rule with n = 1,2,4,8,16,..., and denote the resulting approximations, respectively, by Ry Ray, Ra,,ete. We then apply extrapolation in the manner given in Section 4.2, that is, we obtain O(h*) approximations >>, R32, R42, €lc., by Rea = Rar + de Reis). fork=2.3.... Then O(4°) approximations Ry, Ry, Rs. ete, by fork =3,4,... 1 Ris = Reat 75 (Rea ~ Rita). In general, after the appropriate Rx.)1 approximations have been obtained, we determine the O(//) approximations from 1 Rig = Rega + (Rij Rega) fork =f J+... Example 1 Use the Composite Tropezoidal rule to find approximations to sin x dx with m = 1,2, 4, 8, and 16. Then perform Romberg extrapolation on the results The Composite Trapezoidal rule forthe various values of n gives the following approx- mations to the true valve 2. Sinn dn Compo cite We pegor deh whe ae i 405) * efor) 5 = “iy Scanned with CamScanner Scanned with CamScanner Scanned with CamScanner These results are shown in Table 4.9. . Table43 ¢ 1.57079633—2.09439511 189611890 2.00855976——_1,.99857073 197423160 -2.00020917——_—+1,99998313 1.99357034____2.00001659__1.99999975 r To obtain the Composite Trapezoidal rule approxi (b= a)/my = (b—a)/2-'. Then jy Ra=Z_V@+ fOl= ire) + fiby): and Rus = FUP + FO) +2fa+ hh By reexpressing this result for R2 we can incorporate the previously determined approxi- mation Ri.1 (b-a) (b-a) 1 Rat 7 [rosso +2f («+ z | = plRia +n fa tiny). Tn a similar manner we can write 1 Ria = 5 (Raa + hal fle + ha) + flat Says and, in general (sce Figure 4.10 on page 216), we have 2 a Rua [x nit ha Yo f@+ Qi- os] (434) foreach k = 2,3,...,n. (See Exercises 14 and 15.) Figure 4.10 Extrapolation then is used to produce O(/;’) approximations by 1 Rey = Rij + (Rij —Reayj-), fork=jjtl,... a as shown in Table 4.10. Table 410 Ott) Ol) Olt) ol) 1 > 3 Rss 4 Ras Ras Ran Example 2 Add an additional extrapolation row to Table 4.10 to approximate .* sin x dx. Solution To obtain the additional row we need the trapezoidal approximation a Ru = } [= + % sin asm 1.99830336. a 32 ‘The values in Table 4.10 give Rat Aas = Rs.) = 1.99839336 + ; 1,99830336 — 1.99357035) 2.00000103; Rox = Roa t has = Rs) = 2.00000103 + 2.00000103 — 2.00001659) 2.00000000; 1 Roa = Rea + G (Roa — Rss) = 2.00000000; 1 Ras = Roa + gg (Ros ~ Ras) = 2.00000000; and Roo = Ros + 7fb;(Ras ~ Rss) = 2.00000000. The new extrapolation table is shown in Table 4.11. . Table 411g 1.57079033_2,09439S11 189611890 2,00855976 —_1,99857073, 1,97423160 2,00020917 _1.99998313_2,00000535, 1.99357034 2.00001659 1.999975 2.000001. -—«1.9998959 199839336 2,00000103 2.000000 200000000 2.000000 2.000000 Romberg ‘Toapproximate the integral 7 = f f(x) dx, select an integer > 0. INPUT endpoints a,b: integer. QUTPUT an aray R. (Compute Ry rows; only the last 2 rows are saved in storage.) Step 1 Seth R 4 fla) + FO). Step 2 OUTPUT (R,,). Step 3 For! =2,....ndoSteps 4-8. Step 4 sera) [eur rato] (Approximation from Trapezpidal method.) Step 5 For) =2, Step 6 OUTPUT (Rs, forj = Step 7 Seth =h/2. Step B For) =1,2...siset Ry (Update row 1 ef) ‘Step 9 STOP. . 4.6 Adaptive Quadrature Methods The composite formulas are very effective in most situations, but they suffer occasionally because they require the use of equally-spaced nodes. Thisis inappropriate when integrating a function on an interval that contains both regions with large functional variationand regions with small functional variation. Illustration ‘The unique solution to the differential equation y” + 6y’ +25 = O that additionally satisfies 0) = 0 and y’Q) = 4 is yy) = e“* sind. Functions of this type are common in ‘mechanical engineering because they describe certain features of spring and shock absorber systems, and in electrical engineering because they are common solutions to elementary circuit problems. The graph of y(x) for x in the interval [0,4] is shown in Figure 4.11 Figure 4.11 V() =¢ “Sin 4x ‘The question we will consider in this section is: ‘* How can we determine what technique should be applied on various portions of the interval of integration, and how accurate can we expect the final approximation to be? Ifthe approximation error for an integral on a given interval is to be evenly distributed, smaller step size is needed forthe large-variation regions than for those with less variation. ‘Anetlicient technique for this type of problem should predict the amount of functional vari- ation and adapt the step size as necessary. These methods are called Adaptive quadrature methods. Adaptive methods are particularly popular for inclusion in professional software packages because, in addition to being efficient, they generally provide approximations that are within a given specified tolerance. Suppose that we want to approximate [” f (x) dx to within a specified tolerance ¢ > 0. The first step is to apply Simpson's rule with step size h = (b — a)/2. This produces (see Figure 4.12) » < [ f(x) dx = S(a,b) — a fO€), forsome & in (a,b), (4.35) where we denote the Simpson's rule approximation on [a, b] by S(a,b) = Aye) +4fath)+ FO). Figure 4.12 ‘The next step is to determine an accuracy approximation that does not require f(@). ‘Todo this, we apply the Composite Simpson's rule withn = 4.andstep size (b—a) /4 = h/2, giving s(“F"4) ~G[fermaar («+ 3) + fe]. Then Eq. (4.36) can be rewritten (see Figure 4.13) as, * b b 1 (ne 7 f foyde=s (0S )+5(520) 6 (5) FOR). (437) Figure 413, (a. #24) 5(224 a ath b * LS i 2 The error estimation is derived by assuming that € © E or, more precisely, that f? (E) = f@'&), and the success of the technique depends on the accuracy of this assumption. If it is accurate, then equating the integrals in Eqs. (4.35) and (4.37) gives atb ate ANGRY ities scarecey PF gt s(« 2 \+s(2) is () F (6) = Sab) — SE) Wave, w 16 _ a+b) (ath oof © ~ Fg [se s(a 3 ) s(4 »)] Using this estimate in Eq. (4.37) produces the error estimation ° a+b ath \| 1 (WP) oy [ sora-s(a ; ) -s( : |< 45 (G) sf (é) 1 atb ath =f ems (o + )-8( |: This implies that S(a, (a +b)/2) +S((a+b)/2.) approximates f. f (x) dx about 15 times betier than it agrees with the computed value (a,b). Thus, if at+b atb sian) s(0224) ~5 (@24) ‘we expect to have * a+b ath f posyas—s (a 25") —9(SA0) He) (9 < I5e, (4.38) <6 (4.39) is assumed to be a sufficiently accurate approximation to [” f(x) dx. Example 1 Check the accuracy of the error estimate given in (4.38) and (4.39) when applied to the [sora integral by comparing 1 = BOF Solaion We hve 7 mA a a 2) 74 sno + asin +n 2 Hev2 + = Lo02279878 and 7) 45(7,7)-78 7 gosin™ 4 dsin ™ s(07)+8(F 5) = [ 0+ 4sin 5 +2sin 7 +4sin = + si = 1000134585. So |s (0 3) -s (0. 9) -s G 5) = |1.002279878 — 1.000134585| = 0.002145293. ‘The estimate for the error obtained when using S(a, (a +5)) + $((a+b),b) to approximate Jf 7 dv is consequently ish @3)-$3)-8(-3)|- which closely approximates the actual error ,000143020, [2 f sinx dx — 000134585 = 0.000134585, lo even though D$ sin.x = sin.x varies significantly in the interval (0.7/2). When the approximations in 4.38) differ by more than 15e, we can apply the Simpson’s rule technique individually to the subintervals [a, (a + b)/2] and ((a + b)/2, 6]. Then we use the error estimation procedure to determine if the approximation to the integral on each subinterval is within a tolerance of €/2. If so, we sum the approximations to produce an approximation to f? f(x) dx within the tolerance e. Ifthe approximation on one of the subintervals fails to be within the tolerance ¢/2, then that subinterval is itself subdivided, and the procedure is reapplied to the two subintervals to determine if the approximation on each subinterval is accurate to within ¢/4. This halving procedure is continued until each portion is within the required tolerance. Adaptive Quadrature ‘To approximate the integral = f° f (x) ds to within a given tolerance: INPUT endpoints a, ; tolerance TOL: limit N to number of levels. QUTPUT approximation APP or message that 1 is exceeded. ! | i= / TOL, = 10 TOL: ! a =a; ! =~ a)/2: ! A= fa): | FC, = sath): 5, = hy(FA, +4FC, + FB)/3; (Approximation from Simpson's ‘method for entre interval.) uel Step 2 While i > 0do Steps 3-5. Step 3 Set rp = fla + h/2 (a, + 3h 2): SI = h(FA, + 4FD-+FC)/6; (Approximations from Simpson's ‘method for halves of subintervals) AFC +AFE+ FB) /6; (Save data at tis level.) Step4 Setimi—1. Delete the level) Step 5 MW jsi+s2—w] ™) then OUTPUT (LEVEL EXCEEDED’); (Procedure fails) ‘STOP. else (Add one level) =i+1: (Data for right half subinterval.) Step 6 OUTPUT (APP); (APP approximates Ito within TOL.) sToP.

You might also like