Chapter 4 Numerical Integration Numerical integration is a primary tool used by engineers and scientists to obtain approximate answers for definite integrals that cannot be solved analytically. In the area of statistical thermodynamics, the Debye model for calculating the heat capacity of a solid involves the following function 更(x) Since there is no analytic expression for D(r), numerical integration must be used to obtain approximate values. For example, the value d(5)is the area under the curve Figure 4.1 The area under the curve y=f(t)for 0<t<5
Chapter 4 Numerical Integration Numerical integration is a primary tool used by engineers and scientists to obtain approximate answers for definite integrals that cannot be solved analytically. In the area of statistical thermodynamics, the Debye model for calculating the heat capacity of a solid involves the following function; Φ(x) = Z x 0 t 3 e t − 1 dt. Since there is no analytic expression for Φ(x), numerical integration must be used to obtain approximate values. For example, the value Φ(5) is the area under the curve 0 1 2 3 4 5 6 7 0 0.5 1 1.5 Figure 2.1 y=f(t) Figure 4.1 The area under the curve y = f(t) for 0 ≤ t ≤ 5. 4
Figure 4.1 Values of (a) 1.00.2248052 2.01.1763426 3025522185 4.03.8770542 504899892 6.055858554 7.06.0031690 8.06.2396238 9.06.3665739 1006.4319219 y=f(t=t/(e-1)for 0<t<5(see Figure 4.1). The numerical approximation for 9()2=a=1≈48892 Each additional value of (a)must be determined by another numerical integration Table 4. 1 lists several of these approximations over the interval [1,10 ti. The purpose of this chapter is to develop the basic principles of numerical integra- tion. In Chapter 9, numerical integration formulas are used to derive the predictor corrector methods for solving differential equations 4.1 Introduction to Quadrature We now approach the subject of numerical integration. The goal is to approximate the definite integral of f(a) over the interval a, b by evaluating f()at a finite number of ample point Definition 4.1 Suppose that a= to <1<...<M=b. A formula of the form QU]=∑mkf(xk)=tof(xo)+mf(x1)+…+Mf(xM) with the property that f(a d x=QU]+Elf (4.2)
Figure 4.1 Values of Φ(x) x Φ(x) 1.0 0.2248052 2.0 1.1763426 3.0 2.5522185 4.0 3.8770542 5.0 4.8998922 6.0 5.5858554 7.0 6.0031690 8.0 6.2396238 9.0 6.3665739 10.0 6.4319219 y = f(t) = t 3/(e t − 1) for 0 ≤ t ≤ 5 (see Figure 4.1). The numerical approximation for Φ(5) is Φ(5) = Z 5 0 t 3 e t − 1 dt ≈ 4.8998922. Each additional value of Φ(x) must be determined by another numerical integration. Table 4.1 lists several of these approximations over the interval [1, 10]. The purpose of this chapter is to develop the basic principles of numerical integration. In Chapter 9, numerical integration formulas are used to derive the predictorcorrector methods for solving differential equations. 4.1 Introduction to Quadrature We now approach the subject of numerical integration. The goal is to approximate the definite integral of f(x) over the interval [a, b] by evaluating f(x) at a finite number of sample points. Definition 4.1 Suppose that a = x0 < x1 < · · · < xM = b. A formula of the form Q[f] = X M k=0 wkf(xk) = w0f(x0) + w1f(x1) + · · · + wMf(xM) (4.1) with the property that Z b a f(x)dx = Q[f] + E[f] (4.2) 5
is called a numerical integration or quadrature formula. The term E() is called the truncation error for integration. The values ak k-o are called the quadrature nodes, and wk ko are called the weights taa epending on the application, the nodes ck) are chosen in various ways. For the pezoidal rule, Simpsons rule, and Boole's rule, the nodes are chosen to be equally spaced. For Gauss-Legendre quadrature, the nodes are chosen to be zeros of certain Legendre polynomials. When the integration formula is used to develop a predictor formula for differential equations, all the nodes are chosen less than b. For all applica- tion, it is necessary to know something about the accuracy of the numerical solution Definition 4.2. The degree of precision of a quadrature formula is the positive integer n such that E[P]=0 for all polynomials Pi(a) of degree i<n, but for which E[P+1 +0 for some polynomial Pn+1()of degree n+1 The form of E[Pl can be anticipated by studying what happens when f(a) polynomial. Consider the arbitrary polynomial ying P(x)=a1x2+x1-1x2-1+ +al.+ ao of degree i If< n, then Pin+()=0 for all x, and P(n+ ()=(n+1)lan-1 for all Thus it is not surprising that the general form for the truncation error term is Eff]=Kf(n+(c) where K is a suitably chosen constant and n is the degree of precision. The proof of this general result can be found in advanced books on numerical integration The derivation of quadrature formulas is sometimes based on polynomial interpo- lation. Recall that there exists a unique polynomial PM(a) of degree M passing through the M+l equally spaced points i(ck, yk)lMo. When this polynomial is used to approximate f(a), over a, bl, and then the integral of f(a)is approximated by the integral of PM(), the resulting formula is called a Newton-Cotes quadrature formula(see Figure 2.2). When the sample points o= a and M= b are used, it alled a closed Newton-Cotes formula. The next result gives the formulas when approximating polynomials of degree M= 1, 2, 3, and 4 are used Theorem 4.1(Closed Newton-Cotes Quadrature Formula). Assume that k o+ kh are equally spaced nodes and f&=f(Ck). The first four closed Newton-Cotes
is called a numerical integration or quadrature formula. The term E(f) is called the truncation error for integration. The values {xk} M k=0 are called the quadrature nodes, and {wk} M k=0 are called the weights. Depending on the application, the nodes {xk} are chosen in various ways. For the trapezoidal rule, Simpson’s rule, and Boole’s rule, the nodes are chosen to be equally spaced. For Gauss-Legendre quadrature, the nodes are chosen to be zeros of certain Legendre polynomials. When the integration formula is used to develop a predictor formula for differential equations, all the nodes are chosen less than b. For all application, it is necessary to know something about the accuracy of the numerical solution. Definition 4.2. The degree of precision of a quadrature formula is the positive integer n such that E[Pi ] = 0 for all polynomials Pi(x) of degree i ≤ n, but for which E[Pn+1] 6= 0 for some polynomial Pn+1(x) of degree n + 1. The form of E[Pi ] can be anticipated by studying what happens when f(x) is a polynomial. Consider the arbitrary polynomial Pi(x) = aix i + xi−1x i−1 + · · · + a1x + a0 of degree i. If i ≤ n, then P (n+1) i (x) ≡ 0 for all x, and P (n+1) n+1 (x) = (n + 1)!an−1 for all x. Thus it is not surprising that the general form for the truncation error term is E[f] = Kf(n+1)(c), (4.3) where K is a suitably chosen constant and n is the degree of precision. The proof of this general result can be found in advanced books on numerical integration. The derivation of quadrature formulas is sometimes based on polynomial interpolation. Recall that there exists a unique polynomial PM(x) of degree ≤ M passing through the M + 1 equally spaced points {(xk, yk)} M k=0. When this polynomial is used to approximate f(x), over [a, b], and then the integral of f(x) is approximated by the integral of PM(x), the resulting formula is called a Newton-Cotes quadrature formula (see Figure 2.2). When the sample points x0 = a and xM = b are used,it is called a closed Newton-Cotes formula. The next result gives the formulas when approximating polynomials of degree M = 1, 2, 3, and 4 are used. Theorem 4.1 (Closed Newton-Cotes Quadrature Formula). Assume that xk = x0 + kh are equally spaced nodes and fk = f(xk). The first four closed Newton-Cotes 6
quadrature formulas are ()d≈=2(6+/)( (the trapezoidal r f(x)dx≈n(后+4f1+f2)( Simpson' s rule), f(a)dr s o(o+3f1+3f2+f3)(Simpsons rule), 层f()≈(7+32h+125+32)5+7)( Boole's rule 4. Figure 2.2(a) The trapezoidal rule integrates( b) Simpson's rule integrates(c)Simp son's rule integrates(d)Boole's rule integrates Corollary 4.1(Newton-Cotes Precision). Assume that f(a)is sufficiently dif- ferentiable; then EU for Newton-Cotes quadrature involves an appropriate higher derivative. The trapezoidal rule has degree of precision n=1. If f E Ca, bl,then h3r(2(c) f(adr=o+f1)-iofo
quadrature formulas are Z x1 x0 f(x)dx ≈ h 2 (f0 + f1) (the traezoidal rule), (4.4) Z x2 x0 f(x)dx ≈ h 3 (f0 + 4f1 + f2) (Simpson’s rule), (4.5) Z x3 x0 f(x)dx ≈ 3h 8 (f0 + 3f1 + 3f2 + f3) (Simpson’s 3 8 rule), (4.6) Z x4 x0 f(x)dx ≈ 2h 45 (7f0 + 32f1 + 12f2 + 32f3 + 7f4) (Boole’s rule). (4.7) Figure 2.2 (a) The trapezoidal rule integrates (b) Simpson’s rule integrates (c) Simpson’s rule integrates (d) Boole’s rule integrates Corollary 4.1 (Newton-Cotes Precision). Assume that f(x) is sufficiently differentiable; then E[f] for Newton-Cotes quadrature involves an appropriate higher derivative. The trapezoidal rule has degree of precision n = 1. If f ∈ C 2 [a, b], then Z x1 x0 f(x)dx = h 2 (f0 + f1) − h 3 12 f (2)(c). (4.8) 7
Simpson's rule has degree of precision n=3. If f E C4a, b],then f(c)h f o +4f1 +f2)-oaf(c) (4.9) Simpson's& rule has degree of precision =3. If f E C [a,b],then ∫(x)d (f0+3f1+3f2+f3)-f4(c) Boole's rule has degree of precision n= 5, If f E C a, b],then 2h 8h ∫(x)d (7f0+32f1+12/2+32/3+7f4) 945(c) 4.11 Proof of Theorem 4. 1. Start with the Lagrange polynomial PM(ar)based on ro, T1,.,M that can be used to approximate f(a) f(x)≈PMr(x)=∑LMAk(x) (4.12) where f&=f(ak)for k=0, 1,..., M. An approximation for the integral is obtained by replacing the integrand f(a) with the polynomial PM(a). This is the general method for obtaining a Newton-Cotes integration formula ∫(x) fR.k(a)d (4.13) k(a)d rfK U The details for the general computations of coefficients of wk in(4.13)are tedious. We shall give a sample proof of Simpsons rule, which is the case M= 2. This case involves the approximating polynomial a-1(r-ar P2(x)=f0 2)c(x-xo)(x-x2),( +f1 x-x0)(x-x1) 2 (x-x0)(x-x2)12(x2-x0(2-)(414)
Simpson’s rule has degree of precision n = 3. If f ∈ C 4 [a, b], then Z x2 x0 f(x) = h 3 (f0 + 4f1 + f2) − h 5 90 f (4)(c). (4.9) Simpson’s 3 8 rule has degree of precisionn = 3. If f ∈ C 4 [a, b], then Z x3 x0 f(x)dx = 3h 8 (f0 + 3f1 + 3f2 + f3) − 3h 5 80 f (4)(c). (4.10) Boole’s rule has degree of precision n = 5, If f ∈ C 6 [a, b], then Z x4 x0 f(x)dx = 2h 45 (7f0 + 32f1 + 12f2 + 32f3 + 7f4) − 8h 7 945 f (6)(c). (4.11) Proof of Theorem 4.1. Start with the Lagrange polynomial PM(x) based on x0, x1, . . . , xM that can be used to approximate f(x): f(x) ≈ PM(x) = X M k=0 fkLM,k(x), (4.12) where fk = f(xk) for k = 0, 1, . . . , M. An approximation for the integral is obtained by replacing the integrand f(x) with the polynomial PM(x). This is the general method for obtaining a Newton-Cotes integration formula: Z xM x0 f(x) ≈ Z xM x0 PM(x)dx = Z xM x0 ÃX M k=0 fkLM,k(x) ! dx = X M k=0 µZ xM x0 fkLM,k(x)dx¶ (4.13) = X M k=0 µZ xM x0 LM,k(x)dx¶ fk = X M k=0 wkfk. The details for the general computations of coefficients of wk in (4.13) are tedious. We shall give a sample proof of Simpson’s rule, which is the case M = 2. This case involves the approximating polynomial P2(x) = f0 (x − x1)(x − x2) (x0 − x1)(x0 − x2) + f1 (x − x0)(x − x2) (x − x0)(x − x2) + f2 (x − x0)(x − x1) (x2 − x0)(x2 − x1) . (4.14) 8
Since fo, fi, and f2 are constants with respect to integration, the relations in(4.13) lead to C八)h≈后= )(x-x2) 1)( (4.15) da f2 2-x0)(2-x1 We introduce the change of variable a = ro ht with dx hdt to assist with the evaluation of the integrals in(4.15). The new limits of integration are from t=0 to t=2. qual spacing of the nodes ak =To+ kh leads to Tk-T,=(k-j)h and (t-k), which are used to simplify(4.15) and get f(x)dx≈fo r2h(t-1)h(t-2) (一h)(-2h) hdt +fi ht-0)h(t-2) (h)(-h) hdt (4.16 +m0 hdt (2-3+2)d-fh/(2-)2a/(2-t) h/t 3t2 =o/ih/43 h +f2 32 h2(3)-质b(3)+h2(3) o+4/f1+f2) and the proof is complete. We postpone a sample proof of Corollary 4.1 until Section Example 2.1. Consider the function f(a)=l+- sin(4.), the equally spaced spaced quadrature nodes o =0.0, 11=0.5, 2=1.0, 3=1.5, and 4= 2.0, and the corre- sponding function values fo=100000, f2=0. 72159, f3=0.93765, and f 4=1. 13390 Apply the various quadrature formulas(2.4)through(2.7)
Since f0, f1, and f2 are constants with respect to integration, the relations in (4.13) lead to Z x2 x0 f(x)dx ≈ f0 Z x2 x0 (x − x1)(x − x2) (x0 − x1)(x0 − x2) dx (4.15) +f1 Z x2 x0 (x − x0)(x − x2) (x1 − x0)(x1 − x2) dx + f2 Z x2 x0 (x − x0)(x − x1) (x2 − x0)(x2 − x1) dx We introduce the change of variable x = x0 + ht with dx = hdt to assist with the evaluation of the integrals in (4.15). The new limits of integration are from t = 0 to t = 2. The equal spacing of the nodes xk = x0 + kh leads to xk − xj = (k − j)h and x − xk = h(t − k), which are used to simplify (4.15) and get Z x2 x0 f(x)dx ≈ f0 Z 2 0 h(t − 1)h(t − 2) (−h)(−2h) hdt + f1 Z 2 0 h(t − 0)h(t − 2) (h)(−h) hdt (4.16) +f2 Z 2 0 h(t − 0)h(t − 1) (2h)(h) hdt = f0 h 2 Z 2 0 (t 2 − 3t + 2)dt − f1h Z 2 0 (t 2 − 2t)dt + f2 h 2 Z 2 0 (t 2 − t)dt = f0 h 2 à t 3 3 − 3t 2 2 + 2t ! ¯ ¯ ¯ t=2 t=0 − f1h à t 3 3 − t 2 ! ¯ ¯ ¯ t=2 t=0 +f2 h 2 à t 3 3 − t 2 2 ! ¯ ¯ ¯ t=2 t=0 = f0 h 2 µ 2 3 ¶ − f1h µ−4 3 ¶ + f2 h 2 µ 2 3 ¶ = h 3 (f0 + 4f1 + f2). and the proof is complete. We postpone a sample proof of Corollary 4.1 until Section 4.2. Example 2.1. Consider the function f(x) = 1+e −x sin(4x), the equally spaced spaced quadrature nodes x0 = 0.0, x1 = 0.5, x2 = 1.0, x3 = 1.5, and x4 = 2.0, and the corresponding function values f0 = 1.00000, f2 = 0.72159, f3 = 0.93765, and f4 = 1.13390. Apply the various quadrature formulas (2.4) through (2.7). 9
The step size is h=0.5, and the computations are 0.5 f()dx≈n(1.0000+1.5152)=063788 (x)d≈05 1.00000+4(1 +0.72159)=1.32128 1.5 3(0.5) f(x)dr"8(1.0000131.5152)+3(0.72159)+0.93765) =1.64193 2.0 ∫(a)d45(7(0000245152+12072159 +32(0.93765)+7(1.13390)=1.29444 It is important to realize that the quadrature formulas(4. 4)through(4.7) applied in he above illustration give approximations for definite integrals over different intervals The graph of the curve y= f(ar) and the areas under the Lagrange polynomials y Pi(),y= P2(a),y= P3(a), and P4(a)are shown in Figure 4.2(a)through(d) respectively. In Example 4.1 we applied the quadrature rules with h=0.5. If the endpoints of the interval a, b are held fixed, the step size must be adjusted for each rule. The step sizes are h= b-a,h=(b-a)/2, h=(b-a)/ 3, and h=(b-a)/4 for the trapezoidal rule, Simpson' s rule, Simpsons rule, and Boole's rule, respectively. The next example illustrates this point Example 2.2 Consider the integration of the function f()=l+e-r sin(4. r)over the fixed interval a, b=[0, 1. Apply the various formulas(4. 4)through(4.7) or the trapezoidal rule, h= l and f(x)dt≈2(f(o)+f(1) (1.00000+0.72159)=0.86079 For Simpsons rule, h= 1/2, we get f(a)d≈-2(f(0)+4f(1/2)+f() (1.00000+4(1.55152)+0.72159)=1.32128 For Simpson's a rule,h=1/3, and we obtain /)b≈8 8(0+3f()+3f(5)+f(1)
The step size is h = 0.5, and the computations are Z 0.5 0 f(x)dx ≈ 0.5 2 (1.00000 + 1.55152) = 0.63788 Z 1.0 0 f(x)dx ≈ 0.5 3 (1.00000 + 4(1.55152) + 0.72159) = 1.32128 Z 1.5 0 f(x)dx ≈ 3(0.5) 8 (1.00000 + 3(1.55152) + 3(0.72159) + 0.93765) = 1.64193 Z 2.0 0 f(x)dx ≈ 2(0.5) 45 (7(1.00000) + 32(1.55152) + 12(0.72159) +32(0.93765) + 7(1.13390)) = 1.29444. It is important to realize that the quadrature formulas (4.4) through (4.7) applied in the above illustration give approximations for definite integrals over different intervals. The graph of the curve y = f(x) and the areas under the Lagrange polynomials y = P1(x), y = P2(x), y = P3(x), and P4(x) are shown in Figure 4.2 (a) through (d), respectively. In Example 4.1 we applied the quadrature rules with h = 0.5. If the endpoints of the interval [a, b] are held fixed, the step size must be adjusted for each rule. The step sizes are h = b − a, h = (b − a)/2, h = (b − a)/3, and h = (b − a)/4 for the trapezoidal rule, Simpson’s rule, Simpson’s 3 8 rule, and Boole’s rule, respectively. The next example illustrates this point. Example 2.2 Consider the integration of the function f(x) = 1 + e −x sin(4x) over the fixed interval [a, b] = [0, 1]. Apply the various formulas (4.4) through (4.7). For the trapezoidal rule, h = 1 and Z 1 0 f(x)dx ≈ 1 2 (f(0) + f(1)) = 1 2 (1.00000 + 0.72159) = 0.86079. For Simpson’s rule, h = 1/2, we get Z 1 0 f(x)dx ≈ 1/2 3 (f(0) + 4f(1/2) + f(1)) = 1 6 (1.00000 + 4(1.55152) + 0.72159) = 1.32128. For Simpson’s 3 8 rule, h = 1/3, and we obtain Z 1 0 f(x)dx ≈ 3(1/3) 8 (f(0) + 3f( 1 3 ) + 3f( 2 3 ) + f(1)) 10
(1.00000+3(1.69642)+3(1.23447)+0.72159)=1.31440 For Boole's rule, h=1/4, and the result is (1/4 f() (7∫(0)+32f(7)+12f(5)+32f()+7f(1) 7(1.0+32(1.65534)+12(1.55152) +32(1.066+7(0.72159)=1.30859 The true value of the definite integral is f(a)dr le-4 cos(4)-sin(4) =1.3082506046426 17e and the approximation 1.30859 from Boole's rule is best, the area under each of the Lagrange polynomials P1(), P2(r), P3(ar), and P4(a) is shown in Figure 2.3(a) through Figure 2.3(a) the trapezoidal rule used over [0, 1 yields the approximation 0.86079 (b)simpson's rule used over 0, 1 yields the approximation 1. 32128.(c) simpson's rule used over [ 0, 1] yields the approximation 1.31440. d boole's rule used over 0, 1] yields the approximation 1. 30859 To make a fair comparison of quadrature methods, we must use the same number of function evaluations in each method. Our final example is concerned with comparing integration over a fixed interval [a, b] using exactly five function evaluations f&= f(ak) for k=0, 1, ., 4 for each method. When the trapezoidal rule is applied on the four subintervals o, 1,[1, T21, 2, T3, and [c3, r4, it is called a composite trapezoidal f(ar)d.c f(a)dx+/f(x)dx+/f(x)dx+/f(x)dr 2(o+6)+2(+2)+2(2+3)+2(8+A (f0+2f1+2f2+2f3+f4) Simpson's rule can also be used in this manner. When Simpson's rule is applied on the two subintervals [=o, a2] and [c2, c4, it is called a composite Simpson s rule f(ar)d f(a)dx+/f(r)d (fo+4+f2)+a(/2+48+f4) (4.18)
= 1 8 (1.00000 + 3(1.69642) + 3(1.23447) + 0.72159) = 1.31440. For Boole’s rule, h = 1/4, and the result is Z 1 0 f(x)dx ≈ 2(1/4) 45 (7f(0) + 32f( 1 4 ) + 12f( 1 2 ) + 32f( 3 4 ) + 7f(1)) = 1 90 ³ 7(1.00000) + 32(1.65534) + 12(1.55152) +32(1.06666) + 7(0.72159)´ = 1.30859. The true value of the definite integral is Z 1 0 f(x)dx = 21e − 4 cos(4) − sin(4) 17e = 1.3082506046426 . . . , and the approximation 1.30859 from Boole’s rule is best, the area under each of the Lagrange polynomials P1(x), P2(x), P3(x), and P4(x) is shown in Figure 2.3(a) through (d), respectively. Figure 2.3 (a) the trapezoidal rule used over [0,1] yields the approximation 0.86079 (b) simpson’s rule used over [0,1] yields the approximation 1.32128. (c) simpson’s rule used over [0,1] yields the approximation 1.31440. [d] boole’s rule used over [0,1] yields the approximation 1.30859. To make a fair comparison of quadrature methods, we must use the same number of function evaluations in each method. Our final example is concerned with comparing integration over a fixed interval [a, b] using exactly five function evaluations fk = f(xk), for k = 0, 1, . . . , 4 for each method. When the trapezoidal rule is applied on the four subintervals [x0, x1], [x1, x2], x2, x3], and [x3, x4], it is called a composite trapezoidal rule: Z x4 x0 f(x)dx = Z x1 x0 f(x)dx + Z x2 x1 f(x)dx + Z x3 x2 f(x)dx + Z x4 x3 f(x)dx ≈ h 2 (f0 + f1) + h 2 (f1 + f2) + h 2 (f2 + f3) + h 2 (f3 + f4) (4.17) = h 2 (f0 + 2f1 + 2f2 + 2f3 + f4). Simpson’s rule can also be used in this manner. When Simpson’s rule is applied on the two subintervals [x0, x2] and [x2, x4], it is called a composite Simpson’s rule: Z x4 x0 f(x)dx = Z x2 x0 f(x)dx + Z x4 x2 f(x)dx ≈ h 3 (f0 + 4f1 + f2) + h 3 (f2 + 4f3 + f4) (4.18) 11
h (fo+4f1+2/2+4f3+f4) The next example compares the values obtained with(2.17),(2. 18), and(2.7) Example 2.3. Consider the integration of the function f(a)=1+e-tsin(4.r)over a, b=0, 1. Use exactly five function evaluations and compare the results from the composite trapezoidal rule, composite Simpson rule, and Boole's rule The uniform step size is h= 1/4. The composite trapezoidal rule(2.17)produces f(x)dx≈(f(0)+2f(7)+2f()+2f(7)+f(1) (1.0000+2(1.65534)+2(1.55152)+2(1.066+0.72159) Using the composite Simpson's rule(2. 18), we get f()≈2(0)+(2)+)+4()+/() 1.00000+4(1.65534)+2(1.55152)+4(1.0666+0.72159) 1.30938 We have already seen the result of Boole's rule in Example 7.2 f(x)dx≈ 2(1/4) (7∫(0)+32f(7)+12f()+32f()+7f(1) 1.30859. Figure 2. 4(a) the composite trapezoidal rule yields the approximation 1. 28358.(b) the composite simpson rule yields the approximation 1.30938 The true value of the integral is 2le cos SIn f(ad =1.30825046426 17e and the approximation 1.30938 from Simpson s rule is much better than the value 1.28358 obtained from the trapezoidal rule. Again, the approximation 1.30859 from Boole's rule is closest. Graphs for the areas under the trapezoids and parabolas are shown in Figure 2. 4(a)and(b), respectively Example 2.4 determine the degree of precision of Simpsons a rule
= h 3 (f0 + 4f1 + 2f2 + 4f3 + f4) The next example compares the values obtained with (2.17), (2.18), and(2.7). Example 2.3. Consider the integration of the function f(x) = 1 + e −x sin(4x) over [a, b] = [0, 1]. Use exactly five function evaluations and compare the results from the composite trapezoidal rule, composite Simpson rule, and Boole’s rule. The uniform step size is h = 1/4. The composite trapezoidal rule (2.17) produces Z 1 0 f(x)dx ≈ 1/4 2 (f(0) + 2f( 1 4 ) + 2f( 1 2 ) + 2f( 3 4 ) + f(1)) = 1 8 (1.00000 + 2(1.65534) + 2(1.55152) + 2(1.06666) + 0.72159) = 1.28358 Using the composite Simpson’s rule (2.18), we get Z 1 0 f(x)dx ≈ 1/4 3 (f(0) + 4f( 1 4 ) + 2f( 1 2 ) + 4f( 3 4 ) + f(1)) = 1 12 (1.00000 + 4(1.65534) + 2(1.55152) + 4(1.06666) + 0.72159) = 1.30938 We have already seen the result of Boole’s rule in Example 7.2: Z 1 0 f(x)dx ≈ 2(1/4) 45 (7f(0) + 32f( 1 4 ) + 12f( 1 2 ) + 32f( 3 4 ) + 7f(1)) = 1.30859. Figure 2.4 (a) the composite trapezoidal rule yields the approximation 1.28358. (b) the composite simpson rule yields the approximation 1.30938. The true value of the integral is Z 1 0 f(x)dx = 21e − 4 cos(4) − sin(4) 17e = 1.30825046426 . . . , and the approximation 1.30938 from Simpson’s rule is much better than the value 1.28358 obtained from the trapezoidal rule. Again, the approximation 1.30859 from Boole’s rule is closest. Graphs for the areas under the trapezoids and parabolas are shown in Figure 2.4(a) and (b), respectively. Example 2.4 determine the degree of precision of Simpson’s 3 8 rule. 12
It will suffice to apply Simpson's rule over the interval [ 0, 3 with the five test functions f(r)=l, r2, r3 and a4. For the first four functions, Simpson's8 rule is exact 3 (1+3(1)+3(1)+1) (0+3(1)+3(2)+3) (0+3(1)+3(4)+9) (0+3(1)+3(8)+27) The function f(a)=r is the lowest power of x for which the rule is not exact 243993 (0+3(1)+3(16)+81) Therefore, the degree of precision of Simpson's rule is n=3 4.1.1 Exercises for introduction to quadrature 1. Consider integration of f(a) over the fixed interval a, 6=0, 1. Apply the various quadrature formulas(4)through(7). The step sizes are h= l, h=5,h=3,and h=i for the trapezoidal rule, Simpson's rule, Simpson's 3 rule, and Boole's rule respectively (a) f(ar)= sin( r) (b)f(a)=1+e- cos(4. r) (c)f(x)=sin(√ Remark. The true values of the definite integrals are(a 2/T=0.636619772367 (b)18e-cos(4)+4sin(4)/(17e)=-1.007459631397..,and(c)2(sin(1)-cos(1)= 0.602337357879.... Graphs of the functions are shown in Figures 2.5(a) through(c) respectively 2. Consider integration of over the fixed interval a, b=[0, 1. Apply the various quadra- ture formulas; the composite trapezoidal rule(2. 17), the composite Simpson rule(2. 18) and Boole's rule(2.7). Use five function evaluations at equally spaced nodes. The uni form step size is h= (a)f(x)=sin(丌x) (b )f(a)=1+e- cos(4. r) (c)f(a)=sin(v r 3. Consider a general interval [ a, b. Show that Simpson's rule produces exact result for the functions f(r)=x2 and f(a)=., that is
It will suffice to apply Simpson’s 3 8 rule over the interval [0, 3] with the five test functions f(x) = 1, x, x2 , x3 and x 4 . For the first four functions, Simpson’s 3 8 rule is exact. Z 3 0 1dx = 3 = 3 8 (1 + 3(1) + 3(1) + 1) Z 3 0 xdx = 9 2 = 3 8 (0 + 3(1) + 3(2) + 3) Z 3 0 x 2 dx = 9 = 3 8 (0 + 3(1) + 3(4) + 9) Z 3 0 x 3 dx = 81 4 = 3 8 (0 + 3(1) + 3(8) + 27). The function f(x) = x 4 is the lowest power of x for which the rule is not exact. Z 3 0 x 4 dx = 243 5 ≈ 99 2 = 3 8 (0 + 3(1) + 3(16) + 81). Therefore, the degree of precision of Simpson’s 3 8 rule is n = 3. 4.1.1 Exercises for introduction to quadrature 1. Consider integration of f(x) over the fixed interval [a, b] = [0, 1]. Apply the various quadrature formulas (4) through (7). The step sizes are h = 1, h = 1 2 , h = 1 3 , and h = 1 4 for the trapezoidal rule, Simpson’s rule, Simpson’s 3 8 rule, and Boole’s rule, respectively. (a) f(x) = sin(πx) (b) f(x) = 1 + e −x cos(4x) (c) f(x) = sin(√ x) Remark. The true values of the definite integrals are (a)2/π = 0.636619772367 . . ., (b) 18e − cos(4) + 4 sin(4))/(17e) = −1.007459631397 . . ., and (c) 2(sin(1) − cos(1)) = 0.602337357879 . . .. Graphs of the functions are shown in Figures 2.5(a) through (c), respectively. 2. Consider integration of over the fixed interval [a, b]=[0, 1]. Apply the various quadrature formulas; the composite trapezoidal rule (2.17), the composite Simpson rule (2.18), and Boole’s rule (2.7). Use five function evaluations at equally spaced nodes. The uniform step size is h = 1 4 . (a) f(x) = sin(πx) (b) f(x) = 1 + e −x cos(4x) (c) f(x) = sin(√ x) 3. Consider a general interval [a, b]. Show that Simpson’s rule produces exact results for the functions f(x) = x 2 and f(x) = x 3 ; that is, 13