حلول سكشن 4.3.pdf

3
MATH 3132 — Numerical Analysis — Winter 2008 Solutions to Assignment 6 1. [4.3.1] Approximate the following integrals using the Trapezoidal Rule. Also find the exact answer and the approximation error. (a) 1 0.5 x 4 dx; (b) 0.5 0 2 x-4 dx; (d) 1 0 x 2 e -x dx. Answer. Table contains answer to Q.3i. Abbreviations: AE=Abs.error, RE=Rel.error, T=Trapezoidal, S=Simpson. Exact Trapezoid Simpson AE T AE S RE T RE S (a) 0.19375 0.265625 0.1940104 7.2 · 10 -2 2.6 · 10 -4 37% 0.13% (b) -0.267062786 -0.26786 -0.2670635 7.9 · 10 -4 7.1 · 10 -7 0.3% 2.6 · 10 -4 % (d) 0.1606027941 0.18394 0.1624017 2.3 · 10 -2 1.8 · 10 -3 14% 1.1% Remark: the exact values of the integrals can be using the Fundamental Theorem of Calculus; integration is very easy in (a) and (b), while (d) requires integration by parts. The antiderivatives and exact values are: (a) 1 5 x 5 1 0.5 = 31/160; (b) [2 ln(4 - x)] 0.5 0 = 2(ln 3.5 - ln 4) = 2 ln(7/8); (d) (-2 - 2x - x 2 )e -x 1 0 =2 - 5e -1 . 2. [4.3.3] Find the theoretical bound for approximation error in Ex. 1 and compare it to the actual error. Solution. The theoretical error bound for Trapezoidal Rule is |E(f )|≤ M 2 12 (b - a) 3 , M 2 = max [a,b] |f (x)|. (a) f (x) = 12x 2 , M 2 = max [0.5,1] (12x 2 ) = 12. Hence |E(f )|≤ 0.5 3 =0.125. The actual error, 0.072, differs from this by less than two times. (b) f (x) = 4(x - 4) -3 , M 2 = max [0,0.5] 4|x - 4| -3 =4|0.5 - 4| -3 0.0933. (Note: as x becomes closer to 4, |x - 4| becomes smaller and |x - 4| -3 becomes larger. This argument shows why the maximum is attained at the endpoint x =0.5.) Hence |E(f )|≤ 0.0933/12 · 0.5 3 9.7 · 10 -4 . The actual error, 7.9 · 10 -4 , is just slightly less.

Transcript of حلول سكشن 4.3.pdf

  • MATH 3132 Numerical Analysis Winter 2008

    Solutions to Assignment 6

    1. [4.3.1] Approximate the following integrals using the Trapezoidal Rule. Also find theexact answer and the approximation error.

    (a) 10.5

    x4 dx;

    (b) 0.50

    2x4 dx;

    (d) 10x2 ex dx.

    Answer. Table contains answer to Q.3i. Abbreviations: AE=Abs.error, RE=Rel.error,T=Trapezoidal, S=Simpson.

    Exact Trapezoid Simpson AET AES RET RES(a) 0.19375 0.265625 0.1940104 7.2 102 2.6 104 37% 0.13%(b) 0.267062786 0.26786 0.2670635 7.9 104 7.1 107 0.3% 2.6 104%(d) 0.1606027941 0.18394 0.1624017 2.3 102 1.8 103 14% 1.1%Remark: the exact values of the integrals can be using the Fundamental Theorem ofCalculus; integration is very easy in (a) and (b), while (d) requires integration by parts.The antiderivatives and exact values are:

    (a)

    [1

    5x5]10.5

    = 31/160;

    (b) [2 ln(4 x)]0.50 = 2(ln 3.5 ln 4) = 2 ln(7/8);

    (d)[(2 2x x2)ex]1

    0= 2 5e1.

    2. [4.3.3] Find the theoretical bound for approximation error in Ex. 1 and compare it tothe actual error.

    Solution. The theoretical error bound for Trapezoidal Rule is

    |E(f)| M212

    (b a)3, M2 = max[a,b]

    |f (x)|.

    (a) f (x) = 12x2, M2 = max[0.5,1](12x2) = 12. Hence |E(f)| 0.53 = 0.125. The actualerror, 0.072, differs from this by less than two times.

    (b) f (x) = 4(x 4)3, M2 = max[0,0.5] 4|x 4|3 = 4|0.5 4|3 0.0933. (Note: as xbecomes closer to 4, |x4| becomes smaller and |x4|3 becomes larger. This argumentshows why the maximum is attained at the endpoint x = 0.5.)

    Hence |E(f)| 0.0933/12 0.53 9.7 104. The actual error, 7.9 104, is just slightlyless.

  • (d) f (x) = (2x x2)ex, f (x) = (2 4x+ x2)ex, M2 = max[0,1] |(2 4x+ x2)ex|.To find the maximum analytically (alternative: maximize numerically or sketch a

    graph), differentiate once again:

    [(2 4x+ x2)ex] = (6 + 6x x2)ex.Equating this derivative to 0, we obtain the equation x2 6x + 6 = 0. Its two roots arex = 3 3, both are > 1. We conclude that [(2 4x + x2)ex] < 0 on [0, 1]. ThusM2 must equal to the value of |(2 4x + x2)ex| at one of the endpoints, x = 0 or 1.Comparing the values, we find |f (0)| = 2, |f (1)| = e1 < 2. Conclusion: M2 = 2.

    Hence |E(f)| 2/12 13 = 1/6 0.17. The actual error, 0.023, is about 7 timesbetter.

    3. [4.3.5,7] (i) Repeat question 1 using Simpsons rule.

    (ii) Repeat question 2 using Simpsons rule.

    Solution. (i) See Q.1(ii) The theoretical error bound for Simpsons Rule is

    |E(f)| M490

    (b a2

    )5, M4 = max

    [a,b]|f (4)(x)|.

    To calculate f (4)(x) we can use the already calculated f (x) (Question 2).

    (a) f (4)(x) = (12x2) = 24 (a constant), M4 = 24. Hence |E(f)| = (24/90)(0.25)5 2.6 104. The theoretical bound and the actual error are the same in this example, dueto f (4) being constant.

    (b) f (4)(x) = (4(x4)3) = 48(x4)5, M4 = 48(3.5)5. Hence |E(f)| = (48/90)(3.5)5(0.25)5 9.9 107. The actual error, 7.1 107, is just slightly better.(d) f (4)(x) = ((x24x+2)ex) = (x28x+12)ex. To check whether there might be anextremum inside the interval, differentiate once again; the result is (x2 10x+ 20)ex.Solving the quadratic x210x+20 = 0 we get x = 55; both roots are > 1. Hence theextrema are attained at the endpoints. Comparing |f (4)(0)| = 12 and |f (4)(1)| = 5e1