Numericl integrtion Recll tht Lgrnge interpoltion of f b f (x) = n f (x i )L n,i (x) i=0 }{{} Lgrnge polnomil P n (x) + f (n+1) (ξ(x)) (n + 1)! n (x x i ) i=0 So we cn tke integrl on both sides: f (x) dx = = n f (x i ) L n,i (x) dx + i=0 n i f (x i ) + E(f ) f (n+1) (ξ(x)) (n + 1)! n (x x i ) dx i=0 i=0 where for i = 0,..., n, i = L n,i (x) dx nd E(f ) = 1 (n + 1)! f (n+1) (ξ(x)) (n + 1)! n (x x i ) dx i=0 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 150
Trpezoidl rule Suppose we know f t x 0 = nd x 1 = b, then P 1 (x) = (x x 1) (x 0 x 1 ) f (x 0) + (x x 0) (x 1 x 0 ) f (x 1) Then tking integrl of f ields f (x) dx = x1 x 0 + 1 [ (x x1 ) (x 0 x 1 ) f (x 0) + (x x ] 0) (x 1 x 0 ) f (x 1) dx x1 x 0 f (ξ(x)) (x x 0 ) (x x 1 ) dx Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 151
Trpezoidl rule Integrl of the first term on the right is strightforwrd. Note tht the second term on the right is x1 x 0 = f (ξ) = f (ξ) f (ξ(x)) (x x 0 ) (x x 1 ) dx x1 [ x 0 x 3 = h3 6 f (ξ) (x x 0 ) (x x 1 ) dx 3 (x 1 + x 0 ) where ξ (x 0, x 1 ) b MVT for integrls nd x + x 0 x 1 x ] x1 x 0 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 15
Trpezoidl rule Therefore, we obtin [ b (x x 1 ) f (x)dx = (x 0 x 1 ) f (x 0) + (x x 0) (x 1 x 0 ) f (x 1) = (x 1 x 0 ) Trpezoidl rule: [ f (x0 ) + f (x 1 ) ] h3 1 f (ξ) ] x1 x 0 h3 1 f (ξ) f (x) dx = h [ f (x0 ) + f (x 1 ) ] h3 1 f (ξ) Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 153
Trpezoidl rule 0 1 his is clled the Trpezoidl rule becuse when f is function with positive vlues b f(x) dx is pproximted b the re in trpezoid, s shown in Figure 4.3. Illustrtion of Trpezoidl rule: f (x) P 1 (x) 1 x 0 x 1 b x ed. M not be copied, scnned, or duplicted, in whole or in prt. Due to electronic rights, some third prt content m be suppressed from the ebook nd/or echpter(s). oes not mterill ffect the overll lerning experience. Cengge Lerning reserves the right to remove dditionl content t n time if subsequent rights restrictions require Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 154
Simpson s rule If we hve vlues of f t x 0 =, x 1 = +b, nd x = b. Then f (x) dx = x x 0 [ (x x1 ) (x x ) (x 0 x 1 ) (x 0 x ) f (x 0) + (x x 0) (x x ) (x 1 x 0 ) (x 1 x ) f (x 1) + (x x 0) (x x 1 ) (x x 0 ) (x x 1 ) f (x )] dx + x (x x 0 ) (x x 1 ) (x x ) x 0 6 f (3) (ξ(x)) dx Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 155
Simpson s Rule Simpson s rule Simpson s rule results from integrting over [, b] the second Lgrnge polnomil with equll-spced With similr nodeside, x 0 = we, cn x = derive b, nd the x 1 Simpson s = + h, where rule: h = (b )/. (See Figure 4.4.) x f (x)dx = h [ f (x0 ) + 4f (x 1 ) + f (x ) ] h5 x 0 3 90 f (4) (ξ) f (x) P (x) x 0 x 1 x b x Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 156
Exmple Exmple (Trpezoidl nd Simpson s rules for integrtion) Compre Trpezoidl nd Simpson s rules on 0 () x (b) x 4 (c) (x + 1) 1 (d) 1 + x (e) sin x (f) e x f (x) dx where f is Solution. Appl the the formuls respectivel to get: Problem () (b) (c) (d) (e) (f) f (x) x x 4 (x + 1) 1 1 + x sin x e x Exct vlue.667 6.400 1.099.958 1.416 6.389 Trpezoidl 4.000 16.000 1.333 3.36 0.909 8.389 Simpson s.667 6.667 1.111.964 1.45 6.41 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 157
Newton-Cotes formul We cn follow the sme ide to get higher-order pproximtions, clled the Netwon-Cotes formuls. For n = 3 where ξ (x 0, x 3 ): x3 x 0 f (x) dx = 3h 8 [ f (x0 ) + 3f (x 1 ) + 3f (x ) + f (x 3 ) ] 3h5 80 f (4) (ξ) For n = 4 where ξ (x 0, x 4 ): x4 x 0 f (x) dx = h 45 [ 7f (x0 ) + 3f (x 1 ) + 1f (x ) + 3f (x 3 ) + 7f (x 4 ) ] 8h7 945 f (6) (ξ) Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 158
Closed Newton-Cotes Formuls Composite numericl integrtion Figure 4.5 The (n+ 1)-point closed Newton-Cotes formuluses nodes x i = x 0 + ih, for i = 0, 1,..., n, where x 0 =, x n = b nd h = (b )/n. (See Figure 4.5.) It is clled closed becuse the endpoints of the closed intervl [, b] re included s nodes. Problem with Newton-Cotes rule for high degree is oscilltions. = f (x) = P n (x) x 0 x 1 x x n 1 x n b x Insted, we cn pproximte the integrl piecewisel. The formul ssumes the form f(x) dx n i f(x i ), Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte i= 0 Universit 159
Composite midpoint rule Let x 1 =, x 0, x 1 x, 0.. x 1., x n, x n+1 = x j 1 b bex j uniform x n 1 b prtition x n xof [, b] with h = b n+. Then we obtin the composite midpoint rule: Figure 4.9 n/ For the Composite Midpoint rule, n must gin be even. (See Figure 4.9.) f (x) dx = h j=0 f ( ) b x j + 6 h f (µ) f (x) x 1 x 0 x 1 x j 1 x j x j 1 x n 1 x n b x n 1 x Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 160
Composite trpezoidl rule Figure 4.8 Let x 0 =, x 1,..., x n = b be uniform prtition of [, b] with h = b n. Then we obtin the composite Trpezoidl rule: f (x) dx = h n 1 f () + f ( ) x j + f (b) b 1 h f (µ) j=1 4.4 Composite Numericl Integrtion 07 f (x) x 0 x 1 x j 1 x j x n 1 b x n x Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 161
Composite Simpson s 1 rule Let x 0, x 1,..., x n (n even) be uniform prtition of [, b]. Then The error for this pproximtion hs been reduced to 0.01807. ppl Simpson s rule on [x 0, x ], [x, x 4 ],..., totl of n such intervls. Then we obtin the composite Simpson s b rule: f (x)dx = h 3 + 6 e + 4e + e + 6 e + 4e + e ( = e 0 + 4e 1/ + e + 4e 3/ + e + 4e 5/ + e 3 + 4e 7/ + e 4) 6 = 53.616. To generlize this procedure for n rbitrr integrl integer n. Subdivide the intervl (n/) 1 [, b] into n subintervls, n/ nd ppl Simpson s rule on Figure 4.7 f () + ech consecutive pir of subintervls. (See Figure 4.7.) f (x j ) + 4 f (x j 1 ) + f (b) b 180 h4 f (4) (µ) j=1 j=1 f(x) dx, choose n even f (x) x 0 x x j x j 1 x j b x n x ngge Lerning. All Rights Numericl Reserved. M Anlsis not be copied, I scnned, Xiojing or duplicted, Ye, in Mth whole or in & prt. Stt, Due to Georgi electronic rights, Stte some Universit third prt content m be suppressed from the ebook nd/or echpter(s). 16
Guss qudrture f (x) f (x) f (x) 4.7 Gussin Qudrture 9 Previousl we chose points (nodes) with fixed gps. Wht if we re llowed to to Figure x 1 choose 4.15 x bpoints x x 0, x 1..., x n x nd b x evlute x 1 f there? x b x f (x) The Trpezoidl rule pproximtes the integrl of the function b integrting the liner f (x) function tht joins the endpoints off (x) the grph of the function. But this is not likel the best line for pproximting the integrl. Lines such s those shown in Figure 4.16 would likel give much better pproximtions in most cses. Figure 4.16 x 1 x b x x 1 x b x x 1 x b x f (x) The Trpezoidl rule pproximtes the integrl of the function f b (x) integrting the liner function tht joins the endpoints of f (x) the grph of the function. But this is not likel the best line for pproximting the integrl. Lines such s those shown in Figure 4.16 would likel give much better pproximtions in most cses. Figure x 1 4.16 x b x x 1 x b x x 1 b x x f (x) Gussin qudrture chooses the points for evlution in n optiml, rther thn equllspced, w. The nodes x 1, x,..., x n in the intervl [, b] nd coefficients f (x) c 1, c,..., c n, re Numericl Guss demonstrted Anlsis I his method Xiojingchosen Ye, Mth to minimize & Stt, the Georgi expected Stte error f (x) Universit obtined in the pproximtion 163
Guss qudrture Guss qudrture tries to determine x 1,..., x n nd c 1,..., c n s.t. f (x) dx n c i f (x i ) i=1 Conceptull, since we hve n prmeters, i.e., c i, x i for i = 1,..., n, we expect to get = if f (x) is polnomil of degree n 1. Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 164
Guss qudrture Let s first tr the cse with intervl [ 1, 1] nd two points x 1, x [ 1, 1]. Then we need to find x 1, x, c 1, c such tht 1 1 f (x)dx c 1 f (x 1 ) + c f (x ) nd = holds for ll polnomils of degree 3. Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 165
Guss qudrture We first note ( 0 + 1 x + x + 3 x 3) dx = 0 1 dx+ 1 x dx+ x dx+ 3 x 3 dx Then we need x 1, x, c 1, c s.t. 1 1 f (x) dx = c 1f (x 1 ) + c f (x ) for f (x) = 1, x, x, nd x 3 : c 1 1 + c 1 = c 1 x 1 + c x = c 1 x1 + c x = c 1 x1 3 + c x 3 = 1 1 1 1 1 1 1 1 1 dx =, x dx = 0 x dx = 3, x 3 dx = 0 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 166
Guss qudrture Solve the sstem of four equtions to obtin x 1, x, c 1, c : c 1 = 1, c = 1, x 1 = So the pproximtion is 1 1 f (x) dx f ( 3 3, nd x = 3 3 ) + f ( ) 3 3 3 3 which is exct for ll polnomils of degree 3. This point nd weight selection is clled Guss qudrture. Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 167
Legendre polnomils To obtin Guss qudrture for lrger n, we need Legendre polnomils {P n : n = 0, 1,... }: 1. All P n re monic (leding coefficient =1). 1 1 P(x)P n (x) dx = 0 for ll polnomil P of degree less thn n. Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 168
Legendre polnomils The first five Legendre polnomils: P 0 (x) = 1 P 1 (x) = x P (x) = x 1 3 P 3 (x) = x 3 3 5 x P 4 (x) = x 4 6 7 x + 3 35 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 169
Guss qudrture nd Legendre polnomil Theorem (Obtin Guss qudrture b Legendre pol.) Suppose x 1,..., x n re the roots of the nth Legendre polnomil P n (x), nd define c i = 1 1 n j=1 j i x x j x i x j dx If P(x) is n polnomil of degree less thn n, then 1 1 P(x)dx = n c i P (x i ) i=1 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 170
Guss qudrture n Roots r n,i Coefficients c n,i 0.57735069 1.0000000000-0.57735069 1.0000000000 3 0.774596669 0.5555555556 0.0000000000 0.8888888889-0.774596669 0.5555555556 4 0.8611363116 0.3478548451 0.3399810436 0.651451549-0.3399810436 0.651451549-0.8611363116 0.3478548451 5 0.9061798459 0.36968850 0.5384693101 0.478686705 0.0000000000 0.5688888889-0.5384693101 0.478686705-0.9061798459 0.36968850 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 171
Exmple Exmple (Guss qudrture) Approximte 1 1 ex cos x dx using Guss qudrture with n = 3. Solution. We need to use the roots of Legendre polnomil nd coefficient vlues for n = 3: n Roots r n,i Coefficients c n,i 3 0.774596669 0.5555555556 0.0000000000 0.8888888889-0.774596669 0.5555555556 1 1 e x cos x dx 0.5e 0.7745969 cos(0.77459669) + 0.8 cos(0) + 0.5e 0.7745969 cos( 0.77459669) =1.9333904 True vlue is 1 1 ex cos x dx = 1.933414. Our error is 3. 10 5. Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 17
Guss qudrture on rbitrr intervl So fr the Guss qudrture is onl considered on [ 1, 1]. To find Guss qudrture on rbitrr x [, b], just do chnge of vrible: t = x b b x = 1 [(b )t + + b] Then t [ 1, 1] nd the integrl is f (x) dx = 1 1 f ( ) (b )t + (b + ) (b ) dt Then ppl Guss qudrture to the right side. Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 173
The techniques discussed in the previous sections cn be modified for use in the pproximtion of multiple integrls. Consider the double integrl f(x, ) da, Multiple integrls Now we consider multiple integrl where R = {(x, ) x b, b c d d }, for some constnts, b, c, nd d, is rectngulr region in the plne. (See Figure 4.18.) c Figure 4.18 R f (x, ) d dx z z f (x, ) c d x b R Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 174
This pproximtion is of order O (b )(d c) (b ) + (d c). Figure 4.19 shows grid with the number of functionl evlutions t ech of the nodes used in the pproximtion. Multiple integrls.19 First consider grid on the domin [, b] [c, d]: 1 d (c d) c 1 1 4 1 1 1 ( b) b x Here k = d c nd h = b. ll Rights Reserved. M not be copied, scnned, or duplicted, in whole or in prt. Due to electronic rights, some third prt content m be suppressed from the ebook nd/or echpter(s). ressed content does not mterill ffect the overll lerning experience. Cengge Lerning reserves the right to remove dditionl content t n time if subsequent rights restrictions require it. Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 175
Multiple integrls We first pproximte the inner integrl using composite Trpezoidl rule: d c f (x, ) d = c+k c f (x, ) d + d c+k f (x, ) d k (f (x, c) + f (x, c + k)) + k (f (x, c + k) + f (x, d)) = k (f (x, c) + f (x, c + k) + f (x, d)) =: g(x) Then pproximte the outer integrl: g(x) dx = h (g() + g( + h) + g(b)) Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 176
Copright 010 Cengge Lerning. Numericl All Rights Reserved. Anlsis M not I be copied, Xiojing scnned, or Ye, duplicted, Mth in whole & or in Stt, prt. Due Georgi to electronic rights, Stte some third Universit prt content m be suppressed from the ebook nd/or echpter(s). 177 ditoril review hs deemed tht n suppressed content does not mterill ffect the overll lerning experience. Cengge Lerning reserves the right to remove dditionl content t n time if subsequent rights restrictions require it. Multiple integrls + Combine the two to obtin: ( d Figure 4.19 c = + f(b, c) + f b, + f(b, d) 4 4 [ (b )(d c) f(, c) + f(, d) + f(b, c) + f(b, d) 16 ( ( ) ( ) ( + b + b f, c + f, d + f, c + d ) ( )) ( )] + b ) { (b+ f )(d b, c + d c) + 4f f (x, ) d dx = f (, c) +, c + d f (, d) + f (b, c) + f (b, d) 16 [ ( ) ( ) ( + b + b + f, c + f, d + f, c + d ) ( + f b, c + d ) ] ( + b + 4f, c + d ) } This pproximtion is of order O ( (b )(d c) [ (b ) + (d c) ]). Figure 4.19 shows grid with the number of functionl evlutions t ech of the nodes used in the pproximtion. d 1 (c d) c 1 1 4 1 1 1 ( b) b x
the nodes (x i, j ), where i = 0, 1,, 3, 4 nd j = 0, 1,. It lso shows the coefficients w i,j of f(x Multiple i, i ) = ln(xintegrls i + i ) the sum tht gives the Composite Simpson s rule pproximtion to the integrl. We cn lso consider 4 grid on the domin [, b] [c, d]: 1.50 1 4 4 1 1.5 4 16 8 16 4 1.00 1 4 4 1 1.40 1.55 1.70 1.85.00 x Here k = d c 4 nd h = b The pproximtion is..0 1.5 (0.15)(0.5) 4 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 178
Guss qudrture for non-rectngulr region We cn lso use Guss qudrture for non-rectngulr region: d(x) Figure 4.1 c(x) c(x) we will use the bsic Simpson s rule to integrte with respect to both vribles. The step size for the vrible x is h = (b )/, but the step size for vries with x (see Figure 4.1) nd is written k(x) = f (x, ) d dx d(x) c(x). z z f (x, ) d() d(b) d(x) A(x) k() c(b) c() k( h) c(x) h b k(b) x x b c(x) R d(x) () Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 179 (b)
Composite Simpson s rule on non-rectngulr region Now we consider multiple integrls on non-rectngulr regions: d(x) c(x) f (x, ) d dx For ech integrl set k(x) = d(x) c(x), then d(x) c(x) k(x) f (x, ) d dx [f (x, c(x)) + 4f (x, c(x) + k(x)) + f (x, d(x))] dx 3 h { k() [f (, c()) + 4f (, c() + k()) + f (, d())] 3 3 4k( + h) + [f ( + h, c( + h)) + 4f ( + h, c( + h) 3 + k( + h)) + f ( + h, d( + h))] + k(b) [ ]} f (b, c(b)) + 4f (b, c(b) + k(b)) + f (b, d(b)) 3 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 180
Guss qudrture for non-rectngulr region We cn lso use Guss qudrture for non-rectngulr region: d(x) c(x) f (x, ) d dx For ech x [, b], trnsform [c(x), d(x)] into vrible t in [ 1, 1]: ( ) (d(x) c(x))t + d(x) + c(x) f (x, ) = f x, d(x) c(x) d = dt Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 181
Guss qudrture for non-rectngulr region So the inner integrl cn be pproximted b Guss qudrture: d(x) c(x) f (x, ) d = d(x) c(x) d(x) c(x) =: g(x) 1 1 f ( x, n c n,j f j=1 ) (d(x) c(x))t + d(x) + c(x) dt ( x, (d(x) c(x))r n,j + d(x) + c(x) Then we ppl Guss qudrture to the outer integrl: ) d(x) c(x) f (x, ) d dx g(x) dx = ( ) (b )t + (b + ) (b ) g dt 1 m ( ) (b )rm,i + (b + ) (b ) c m,i g 1 i=1 Numericl Anlsis I Xiojing Ye, Mth & Stt, Georgi Stte Universit 18