Solution to HW7 - Solution to HW#7 EGM6341 Spring 2009 pp....

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Solution to HW#7 EGM6341 Spring 2009 pp. 323-329 #1 Write a program to evaluate ( ) b a I f x dx = using the trapezoidal rule with n subdivisions, calling the result I n . Use the program to calculate the following integrals with n=2,4,8,16,,512 a) dx x I ) exp( 2 1- = n I n Error Rn 2 0.731370251828563 0.015453881 4 0.742984097800381 0.003840035 8 0.745865614845695 0.000958518 4.030462 16 0.746584596788222 0.000239536 4.007774 32 0.746764254652294 5.98782E-05 4.001951 64 0.746809163637828 1.49692E-05 4.000488 128 0.746820390541618 3.74227E-06 4.000122 256 0.746823197246153 9.35566E-07 4.000031 512 0.746823898920948 2.33891E-07 4.000008 1024 0.746824074339563 5.84729E-08 4.000002 I_extrap 0.746824132812397 2.95319E-14 Note: Error is calculated using |I exact-I n |; I exact = 0.746824132812427 based on 4-point Gauss-Legendre quadrature with 1024 intervals. Rn = (I n-1-I n-2 )/(I n-I n-1 ) I_extrap = (R(n)*I n-I n-1 )/(R(n)-1) = 0.746824132812397 for n=1024 Observation: * R(n) ~ 4 is close to theoretical estimate for a 2 nd order convergence * Error_extrap(n=1024) <<Error(n=1024) extrapolation is very powerful b) dx x I 5 . 2 1 = n I n Error Rn 2 0.338388347648318 0.052674062 4 0.298791496231346 0.013077211 8 0.288974739670143 0.003260454 4.033598 16 0.286528567896037 0.000814282 4.013110 32 0.285917779698734 0.000203494 4.004943 64 0.285765152250462 5.08665E-05 4.001824 128 0.285727001721098 1.2716E-05 4.000664 256 0.285717464659795 3.17895E-06 4.000240 512 0.285715080445649 7.94731E-07 4.000086 1024 0.285714484396680 1.98682E-07 4.000031 I_extrap 0.285714285715720 1.43469E-12 Note: Error is calculated using |I exact-I(n)|; I exact =1/3.5=0.285714285714285714285714 Rn = (I n-1-I n-2 )/(I n-I n-1 ) I_extrap = (R(n)*I n-I n-1 )/(R(n)-1)= 0.285714285715720 for n=1024 Observation: * R(n) ~ 4 is close to theoretical estimate for a 2 nd order convergence * Error_extrap(n=1024) <<Error(n=1024) extrapolation is very powerful * Is there a Singularity at x=0? T.E. = - 2 12 1 h [ f ' (b)- f ' (a)] Or T.E. = - 2 12 1 h ( b- a ) f " ( ), 5 . 1 ~ ) ( ' x x f , 5 . ~ ) ( " x x f are both continuous near x=0. Thus, for trapezoidal rule, 5 . 2 ) ( x x f = is NOT singular. Thus, R(n) = 4 as predicted for continuous integrand. c) dx x I 2 4 4 1 1 + =- n I n Error Rn 2 4.23529411764706 1.58365879 4 2.91764705882353 0.266011731 8 2.65882352941177 0.007188202 5.090909 16 2.65050680499416 0.001128522 31.12085 32 2.65134716346583 0.000288164-9.89664 64 2.65156325136377 7.2076E-05 3.888966 128 2.65161730615210 1.80212E-05 3.997572 256 2.65163082190308 4.50543E-06 3.999392 512 2.65163420096925 1.12637E-06 3.999848 1024 2.65163504574383 2.81592E-07 3.999962 I_extrap 2.65163532733893 2.86349E-12 Note: Error is calculated using |I exact-I(n)|; I exact = 2tan-1 (4)= 2.65163532733607 Rn = (I n-1-I n-2 )/(I n-I n-1 ) I_extrap = (R(n)*I n-I n-1 )/(R(n)-1)= 2.65163532733893 for n=1024 Observation: * R(n) ~ 4 is close to theoretical estimate for a 2...
View Full Document

Page1 / 16

Solution to HW7 - Solution to HW#7 EGM6341 Spring 2009 pp....

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online