You are on page 1of 5

MATH3806*/COMP3806*

Assignment 6
Due Nov. 28 2007
1. Let h = b − a/3, x 0 = a, x 1 = a + h, x 2 = b. Find the degree of precision of the quadrature formula
∫ a f x dx = 94 hf x 1  + 34 hf x 2 .
b

∫ a fxdx =
b
9 hf a + h + 3 hf a + 3h
4 4

∫a
a+3h
dx = x a+3h
a = 3h & [ 2 marks]
9 h + 3 h = 3h
4 4

∫a
a+3h
xdx = 3ah + 9 h 2 & [3 marks]
2
9 ha + h + 3 h a + 3h = 3ah + 9 h 2
4 4 2

∫a
a+3h
x 2 dx = 3a 2 h + 9ah 2 + 9h 3 & [4 marks]
9 ha + h 2 + 3 h a + 3h 2 = 3a 2 h + 9ah 2 + 9h 3
4 4
∫a
a+3h
x 3 dx = 3a 3 h + 27 a 2 h 2 + 27ah 3 + 81 h 4 & [ 5 marks]
2 4
9 ha + h 3 + 3 h a + 3h 3 = 3a 3 h + 27 a 2 h 2 + 27ah 3 + 45 h 4
4 4 2 2
Degree 2. [1 mark]

1
2. The quadrature formula ∫ f x dx = c 0 f−1 + c 1 f 0 + c 2 f 1 is exact for all polynomials of degree
−1
less than or equal to 2. Determine c 0 , c 1, and c 2 .
[10 marks]

∫ −1 f xdx = c 0 f−1 + c 1 f0 + c 2 f1


1

∫ −1 1dx = 2 = c 0 + c 1 + c 2
1

∫ −1 xdx = 0 = −c 0 + 0 + c 2
1

∫ −1 x 2 dx =
1
2 = c0 + 0 + c2
3
From the last 2 we have c 2 = 1
3
and c 0 = 1
3
. so from the first c 1 = 4
3
.

1
3. The Midpoint rule for approximating ∫ f x dx gives the value 12, the Composite Midpoint rule with
−1
n = 2 gives 5, and the Composite Simpson.s rule gives 6. Use the fact that f−1 = f1 and
f −0.5 = f 0.5 to determine f−1, f−0.5, f0, f0.5, and f1
[10 marks]
Midpoint with h = 1 2hf 0 = 2f 0 = 12 so f 0 = 6
Composite midpoint h = 1/2 2hf −.5 + f 0.5 = 2f 0.5 = 5 or f .5 = 5/2 and f −0.5 = 5/2
Composite Simpson’s rule with h = 1/2
3 f−1
h
+ 4f−0.5 + 2f0 + 4f0.5 + f1 = 16 2f 1 + 20 + 12 = 16 2f 1 + 22 = 6 so f 1 = 2
1
4. Determine the values of n and h required to approximate
π
∫ 0 x 2 cos x dx
to within 10 −4 .
a) Use the Composite Trapezoidal rule.
[4 marks for the derivatives]
π
∫ x 2 cos x dx
0
fx = x 2 cos x
dx 2 cos x
= 2x cos x − x 2 sin x
dx
d 2 x 2 cos x
= 2 cos x − 4x sin x − x 2 cos x
dx 2
d 3 x 2 cos x
= −6 sin x − 6x cos x + x 2 sin x
dx 3
d 4 x 2 cos x
= −12 cos x + 8x sin x + x 2 cos x
dx 4
a) [8 marks] for Trap.

0 0.5 1 1.5 2 2.5 3


x
-2

-4

-6

2 cos x − 4x sin x − x 2 cos x


Max. error at x = π
f ′′ π ≤ −2 + π 2 = 7.8696044
b − a 2 ′′
h f ξ < π h 2 7.87 < 0.0001
12 12
h< 0.0012 = 6. 966 719 4 × 10 −3
7.87π
n> π = 450. 942 9
6. 966 719 4 × 10 −3
n ≥ 451

2
b) Use the Composite Simpson’s rule.
[10 marks] for Simps.

15

10

0 0.5 1 1.5 2 2.5 3


x
-5

-10

− 12 cos x + 8x sin x + x 2 cos x


We need to find the maximum of the 4th derivative - i.e. a zero of the 5th derivative
d 5 x 2 cos x
= lx = 20 sin x + 10x cos x − x 2 sin x
dx 5
lx = 20 sin x + 10x cos x − x 2 sin x
l2 = 6. 225 86 l2.2 = − 0.69022
l2.1 = 2. 855 65
l2.15 = 1. 101 23
l2.175 = 0.209 7
l2.18 = 0.0 303 4
Max. is near x = 2.18 and −12 cos 2.18 + 82.18 sin 2.18 + 2.18 cos x = 18. 449 795
2

Take f ′′′′ 2.18 ≤ 18.5 (or any number at least 18.5)


b − a 4 ′′′′
h f ξ < π h 4 18.5 < 0.0001
180 180
h< 0.018 = 0.132 659 31
4
π ∗ 18.5
n> π = 23. 681 659
0.132 659 316
n ≥ 24 (must be even)
c) Use the Composite Midpoint rule.
[8 marks] for Midpoint
b − a 2 ′′
h f ξ < π h 2 7.8696044 < 0.0001
6 6
h< .0006 = 4. 926 338 4 × 10 −3
π7.8696044
n> π = 637. 713 53
4. 926 338 4 × 10 −3
n ≥ 638

3
5. a) Compute the Simpson’s rule approximations Sa, b, Sa, a + b/2, and Sa + b/2, b for
1
∫ x 2 e −x dx, and verify the estimate given in the approximation formula.
0

[25 marks]
1
∫ 0 x 2 e −x dx = 0.160 602 79
x 0 0.25 .5 .75 1 Sum S
fx 0 0.048675049 0 .15163266 0.26570618 0.36787944
h
1 4 1
0.5
0 0.60653064 0.36787944 0.97441008 S0, 1 = 0.97441008 .5
3

= 0.162401 68
h
0.25
1 4 1
0 0.1947002 0.15163266 0.34633286 S0, .5 = 0.34633286 .25
3

= 0.028861072
1 4 1
0.5163266 1.0628247 0.36787944 1.5823368 S.5, 1 = 1.5823368 .25
3

= 0.1318614
S0, .5, 1 = 0.16072247
Correct Value 0.16060279
Sa, a + b/2 + Sa + b/2, b − Sa, b = 0.16072247 − 0.16240168 = −.00167921
Sa, a + b/2 + Sa + b/2, b - Correct 0.16072247 − 0.16060279 = .00011968
Ratio .00167921/.00011968 = 14.030832
Sa, a + b/2 + Sa + b/2, b agrees with the correct value 14.03 times better than with Sa, b
1
5. a) Use adaptive quadrature (without the computer) to find approximations to within 10 −3 for ∫ x 2 e −x dx.
0

[5 marks]
From the above S0, 1/2 + S1/2, 1 − S0, 1 = −0.00167 921 < 15 ∗ 0.001 = 0.0 15
0. 160 722 47 is accepted (can be seen from correct value)

4
1
6. Approximate the integral ∫ x 2 e −x dx by using Gaussian quadrature with n = 2. Compare with the exact
0
value of the integral.

b − at + b + a
x= = t+1
2 2
2 −
t+1
∫ 0 x 2 e −x dx = ∫ −1
1 1
1 1 t + 1 e 2 dt
2 2
∫ −1 t + 1 2 exp ∫ −1 ftdt
1 1
= 1 − t+1 dt =
8 2
[9 marks]

∫ 0 x 2 e −x dx = f
1
− 1 +f 1
3 3
2 − 1 +1 2
1 +1
1 3 3
= − 1 +1 exp − + 1 +1 exp −
8 3 2 3 2

= 1 0.1786328 ∗ 0.8095111 + 2.488033 ∗ 0.4544464


8
= 0.159 410 5

∫ 0 x 2 e −x dx = 0.1606028
1

Relerr = 0.159 410 5 − 0.1606028 = 0.0074 [1 mark]


0.1606028

1
7. Approximate the integral ∫ x 2 e −x dx by using Gaussian quadrature with n = 3. Compare with the exact
0
value of the integral.

.[9 marks] The transformation is the same as for 7


∫ 0 x 2 e −x dx = 0.555556 f
1
− 3/5 + 0.8888889 f 0 + 0.555556 f 3/5

1 2 − 3/5 + 1
= 0.555556 − 3/5 + 1 exp −
8 2
3/5 + 1
+0.88888890 + 1 exp − 0 + 1
2
+ 0.555556 3/5 + 1 exp −
2 2

= 1 0.555556 ∗ 0.05080669 ∗ 0.8934171


8
+0.8888889 ∗ 1 ∗ 0.6065307 + 0.555556 ∗ 3.149195 ∗ 0.4117667
= 1 0.006304 39 + 0.1347846 + 0.180102 
2
= 0.1605955

∫ 0 x 2 e −x dx = 0.1606028
1

Relerr = 0.1605955 − 0.1606028 = 0.000045 [1 mark]


0.1606028

You might also like