You are on page 1of 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.
R1
(a) 0.5 x4 dx;
R 0.5 2
(b) 0 x4
dx;
R1
(d) 0 x2 ex dx.
Answer. Table contains answer to Q.3i. Abbreviations: AE=Abs.error, RE=Rel.error,
T=Trapezoidal, S=Simpson.
Exact
Trapezoid
(a)
0.19375
0.265625
(b) 0.267062786 0.26786
(d) 0.1606027941
0.18394

Simpson
AET
0.1940104 7.2 102
0.2670635 7.9 104
0.1624017 2.3 102

AES
2.6 104
7.1 107
1.8 103

RET
RES
37%
0.13%
0.3% 2.6 104 %
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:

1
1 5
x
(a)
= 31/160;
5
0.5
(b) [2 ln(4 x)]0.5
0 = 2(ln 3.5 ln 4) = 2 ln(7/8);

1
(d) (2 2x x2 )ex 0 = 2 5e1 .
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 )|

M2
(b a)3 ,
12

M2 = max |f 00 (x)|.
[a,b]

(a) f 00 (x) = 12x2 , M2 = max[0.5,1] (12x2 ) = 12. Hence |E(f )| 0.53 = 0.125. The actual
error, 0.072, differs from this by less than two times.
(b) f 00 (x) = 4(x 4)3 , M2 = 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.53 9.7 104 . The actual error, 7.9 104 , is just slightly
less.

(d) f 0 (x) = (2x x2 )ex , f 00 (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 ]0 = (6 + 6x x2 )ex .
Equating
this derivative to 0, we obtain the equation x2 6x + 6 = 0. Its two roots are
x = 3 3, both are > 1. We conclude that [(2 4x + x2 )ex ]0 < 0 on [0, 1]. Thus
M2 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 00 (0)| = 2, |f 00 (1)| = e1 < 2. Conclusion: M2 = 2.
Hence |E(f )| 2/12 13 = 1/6 0.17. The actual error, 0.023, is about 7 times
better.
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

5
M4 b a
|E(f )|
,
M4 = max |f (4) (x)|.
[a,b]
90
2
To calculate f (4) (x) we can use the already calculated f 00 (x) (Question 2).
(a) f (4) (x) = (12x2 )00 = 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, due
to f (4) being constant.
(b) f (4) (x) = (4(x4)3 )00 = 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) = ((x2 4x + 2)ex )00 = (x2 8x + 12)ex . To check whether there might be an
extremum inside the interval, differentiate once again;
the result is (x2 10x + 20)ex .
2
Solving the quadratic x 10x + 20 = 0 we get x = 5 5; both roots are > 1. Hence the
extrema are attained at the endpoints. Comparing |f (4) (0)| = 12 and |f (4) (1)| = 5e1 <
12, we conclude that M4 = 12.
Hence |E(f )| = (12/90)((0.5)5 4.2 103 . The actual error, 1.8 103 , is about 2.5
times better.
R2
4. [4.3.13] The Trapezoidal rule applied to 0 f (x) dx gives the value 4, and Simpsons
rule gives the value 2. What is f (1)?
Solution. If T and S are the approximations by Trapezoidal, resp. Simpsons, rule, then
T = f (0) + f (2),

1
1
S = (f (0) + 4f (1) + f (2)) = (T + 4f (1)).
3
3

Hence 3S = T + 4f (1), f (1) = (3S T )/4 = (6 4)/4 = 1/2 .

5. [4.4.1(a),2(d)] Use the Composite Trapezoidal rule with indicated values of n to approximate the following integrals:
Z 2
Z e+2
dx
(a)
x ln x dx, n = 4,
(b)
, n = 8.
x ln x
1
e
Solution. The main trick here is correct determination of the step h to use in the
formula.
(a) Here h = (2 1)/4 = 0.25; the approximation is
1
0.25 (f (1) + 2(f (1.25) + f (1.5) + f (1.75)) + f (2)) = 0.6399004777.
2
(Exact value is 0.6362943610, abs.error 3.6 103 .)
(a) Here h = ((e + 2) e)/8 = 0.25; the approximation is
7
X
1
0.25 (f (e) + 2
f (e + 0.25k) + f (2 + e)) = 0.4403450138.
2
k=1

(Exact value is 0.4391865704, abs.error 1.1 103 .)