You are on page 1of 5

Homework # 8: due on April 10, 2019

(1) Use all applicable two-point formulas to determine each missing entry in the following
table
x f (x) f 0 (x)
1.0 0.5403023059
1.3 0.2674988286
1.5 0.0707372017

The given data are taken from function f (x) = cos x. Compute the actual errors and
find error bounds using the error formula.
Solution: Via the forward-difference formula, we have
f (1.0 + 0.3) − f (1.0) f (1.3) − f (1)
f 0 (1.0) ≈ =
0.3 0.3
0.2674988286 − 0.5403023059
= = −0.9093449243,
0.3
f (1.3 + 0.2) − f (1.3) f (1.5) − f (1.3)
f 0 (1.3) ≈ =
0.2 0.2
0.0707372017 − 0.2674988286
= = −0.9838081345.
0.2
Using the backward-difference formula, we have
f (1.3 − 0.3) − f (1.3) f (1) − f (1.3)
f 0 (1.3) ≈ =
−0.3 −0.3
0.5403023059 − 0.2674988286
= = −0.9093449243,
−0.3
f (1.5 − 0.2) − f (1.5) f (1.3) − f (1.5)
f 0 (1.5) ≈ =
−0.2 −0.2
0.2674988286 − 0.0707372017
= = −0.9838081345.
−0.2
Therefore, the missing entries are f 0 (1) = −0.9093449243, f 0 (1.3) = −0.9093449243 or
−0.9838081345, and f 0 (1.5) = −0.9838081345.

When computing the approximated value of f 0 (x0 ), we have


f (x0 + h) − f (x0 ) h 00
f 0 (x0 ) = − f (c),
h 2
for some c between x0 and x0 + h. Then the error bound is
h 00 |h|
|f (c)| ≤ M,
2 2
where M is the maximum of |f 00 (x)| = | − cos x| for x between x0 and x0 + h.
Using the error formula, we obtain the following table

1
x0 approximate f 0 (x0 ) actual error error bound
1 -0.9093449243 0.0678739395 | 0.3
2
· f 00 (1)| = 0.08104534588 (use nodes x = 1, 1.3)
−0.3
1.3 -0.9093449243 0.0542132611 | 2 · f 00 (1)| = 0.08104534588 (use nodes x = 1, 1.3)
1.3 -0.9838081345 0.0202499491 | 0.2
2
· f 00 (1.3)| = 0.02674988286 (use nodes x = 1.3, 1.5)
−0.2
1.5 -0.9838081345 0.0136868521 | 2 · f 00 (1.3)|= 0.02674988286 (use nodes x = 1.3, 1.5)

(2) Use the indicated three-point formula to determine each missing entry in the following
table
x f (x) f 0 (x)
1.1 0.453596121425577 use formula (4.4)
1.2 0.362357754476674 use formula (4.5)
1.3 0.267498828624587 Do not compute
1.4 0.169967142900241 use formula (4.6)

The three-point formulas are the following


1 h2
f 0 (x0 ) = [−3f (x0 ) + 4f (x0 + h) − f (x0 + 2h)] + f (3) (c0 ), (4.4)
2h 3
1 h2
f 0 (x1 ) = [f (x1 + h) − f (x1 − h)] − f (3) (c1 ), (4.5)
2h 6
1 h2
f 0 (x2 ) = [f (x2 − 2h) − 4f (x2 − h) + 3f (x2 )] + f (3) (c2 ), (4.6)
2h 3
for h > 0 and where c0 is in [x0 , x0 +2h], c1 is in [x1 −h, x1 +h], and c2 is in [x2 −2h, x2 ].
The given data are taken from f (x) = cos x. Compute the actual errors, and find error
bounds using the error formula.

Solution: By above (4.4), (4.5) and (4.6) and h = 1.1 − 1 = 1.2 − 1.1 = 1.3 − 1.2 =
1.4 − 1.3 = 0.1, we have
1
f 0 (1.1) ≈ [−3f (1.1) + 4f (1.2) − f (1.3)] = −0.894280874973124,
0.2
1
f 0 (1.2) ≈ [f (1.3) − f (1.1)] = −0.930486464004950,
0.2
1
f 0 (1.4) ≈ [f (1.2) − 4f (1.3) + 3f (1.4)] = −0.988680656604763.
0.2

For the formulas (4.4) and (4.6), the error bound can be compute using following
2 2
f (c)) 6 |h| M,
h (3)
3 3
where M is the maximum of |f (3) (x)| = | sin x| for x between x0 and x0 + 2h. For the
formula (4.5), the error bound can be compute using following
2 2
− f (c)) 6 |h| M,
h (3)
6 6

2
where M is the maximum of |f (3) (x)| = | sin x| for x between x0 − h and x0 + h.
Then we obtain the following table

x̂ approximate f 0 (x̂) actual error error bound


2
1.1 -0.894280874973 0.003073514911 (0.1)3
sin(1.3)=0.003211860618 (use nodes x=1.1, 1.2, 1.3)
(0.1)2
1.2 -0.930486464004 0.001552621962 6
sin(1.3)=0.001605930309 (use nodes x=1.1, 1.3)
(0.1)2
1.4 -0.988680656604 0.003230926616 3
sin(1.4)=0.003284832433 (use nodes x=1.2, 1.3, 1.4)

(3) Approximate the following integral using the Trapezoidal rule


Z 2
(5x4 + 3x2 ) dx.
1

Find a bound for the error of the numerical result obtained in problem 1 using the
error formula, and compare this to the actual error.

Solution: Applying the Trapezoidal rule for x0 = 1, x1 = 2 and f (x) = 5x4 + 3x2 , we
obtain the approximate value
Z 2
2−1
(5x4 + 3x2 )dx ≈ [f (1) + f (2)] = 0.5 · (8 + 92) = 50.
1 2

Since f 00 (x) = 60x2 + 6 and h = x1 − x0 = 2 − 1 = 1, the error bound is


3
h 00 13 00

f (c) ≤ |f (2)| = 1 · 246 = 20.5,
12 12 12
Z 2
for 0 < c < 2. For (5x4 + 3x2 ) dx = 38, the actual error is
1

|38 − 50| = 18 < 20.5 = the error bound.

(4) Approximate the following integral using the Simpson’s rule


Z 2
(5x4 + 3x2 ) dx.
1

Find a bound for the error of the numerical result using the error formula, and compare
this to the actual error.
x2 − x0
Solution: Applying the Simpson’s rule for x0 = 1, x1 = 1.5, x2 = 2, h = = 0.5
2
and f (x) = 5x4 + 3x2 , we obtain the approximate value
Z 2
h
(5x4 + 3x2 ) dx ≈ [f (1) + 4f (1.5) + f (2)]
1 3
0.5
= [(5 + 3) + 4(25.3125 + 6.75) + (80 + 12)] = 38.0416̄.
3
3
Since f (4) (x) = 120 and h = 0.5, the error bound is
5
h (4) (0.5)5 (4) (0.5)5

1
f (c) =
90 |f (c)| = × 120 = = 0.0416̄.
90 90 24
Z 2
for 1 < c < 2. For (5x4 + 3x2 ) dx = 38, the actual error is
0

|38 − 38.0416̄| = 0.0416̄ = the error bound.

(5) Use the definition to find the degree of precision of the quadrature formula
Z 2 √ ! √ !
−2 3 2 3
f (x) dx = 2 f +2 f .
−2 3 3

Solution: By the definition of accuracy,let’s consider f (x) = xk , for k = 0, 1, 2, · · ·


until we find a k such that
Z 2 √ ! √ !
−2 3 2 3
f (x)dx 6= 2 f +2 f .
−2 3 3

Let f (x) = x0 = 1 on [−2, 2], we have


Z 2 Z 2
2

f (x) dx = 1 dx = x = 4,
−2 −2 −2

and the quadrature formula gives


√ ! √ !
−2 3 2 3
2f +2 f = 2 + 2 = 4,
3 3

which is exactly the value of the direct integration.


Let f (x) = x on [−2, 2], we have
Z 2 Z 2 2
x2
f (x) dx = x dx = = 0,
−2 −2 2 −2

and the quadrature formula gives


√ ! √ ! √ √
−2 3 2 3 −4 3 4 3
2f +2 f = + = 0,
3 3 3 3

which is exactly the value of the direct integration.


Let f (x) = x2 on [−2, 2], we have
Z 2 Z 2 3 2

x 16
f (x) dx = x2 dx = = ,
−2 −2 3 −2 3

4
and the quadrature formula gives
√ ! √ ! √ !2 √ !2
−2 3 2 3 −2 3 2 3 8 8 16
2f +2 f =2 +2 = + = ,
3 3 3 3 3 3 3

which is exactly the value of the direct integration.


Let f (x) = x3 on [−2, 2], we have
2 2
2
x4
Z Z
3
f (x) dx = x dx = = 0,
−2 −2 4 −2

and the quadrature formula gives


√ ! √ ! √ !3 √ !3
−2 3 2 3 −2 3 2 3
2f +2 f =2 +2 = 0,
3 3 3 3

which is exactly the value of the direct integration.


Let f (x) = x4 on [−2, 2], we have
2 2
2
x5
Z Z
4 64
f (x) dx = x dx = = ,
−2 −2 5 −2 5

and the quadrature formula gives


√ ! √ ! √ !4 √ !4
−2 3 2 3 −2 3 2 3 32 32 64 64
2f +2 f =2 +2 = + = 6= ,
3 3 3 3 9 9 9 5

which is not the value of direct integration. So this given quadrature formula is exact
for polynomial of degree at most 3.

You might also like