Partial Solution Set, Leon §7.1 7.1.1 Find the three

advertisement
Partial Solution Set, Leon §7.1
7.1.1 Find the three-digit decimal floating point representation of each of the following numbers:
(a) f l(2312) = 0.231 · 104
(b) f l(32.56) = 0.326 · 102
(c) f l(0.01277) = 0.128 · 10−1
(d) f l(82, 431) = 0.824 · 105
7.1.2 Find the absolute error and the relative error when each of the real numbers in Exercise
1 is approximated by a three-digit decimal floating-point number.
Recall that absolute error is f l(x) − x and the relative error is δ =
f l(x)−x
.
x
(a) absolute error: f l(2312) − 2312 = 0.231 · 10−3 − 2312 = −2, and relative error is
−2
δ = 2312
≈ −0.865 × 10−3 .
(b) 0.326 · 10−2 − 32.56 = .04, and relative error is δ =
.04
32.56
≈ 0.1229 × 10−2 .
(c) 0.128 · 101 − 0.01277 = 0.00003, and relative error is δ =
0.235 × 10−2 .
(d) 0.824 · 10−5 − 82, 431 = −31, and relative error is δ =
−31
82,431
0.00003
0.01277
≈ 0.00235 =
≈ −0.376 × 10−3 .
7.1.3 Represent each of the following as five-digit base 2 floating-point numbers:
(a) 21 = 24 + 0 · 23 + 22 + 0 · 21 + 1 · 20 = (0.10101)2 · 25 .
(b)
3
8
= (0 · 24 + 0 · 23 + 0 · 22 + 21 + 20 ) · 2−3 = (0.11000)2 · 2−1 .
(c) 9.872 = 23 +1.872 = 23 +0·22 +0·21 +20 +2−1 +lower-order terms ≈ (0.10011)2 ·24 .
(d)
−0.1 =
=
=
≈
−(0.0625 + 0.0375)
−(2−4 + 2−5 + 0.063)
−(2−4 + 2−5 + 0 · 2−6 + 0 · 2−7 + 2−8 ) + lower-order terms
(0.11001)2 · 2−3
7.1.4 Do each of the following using four-digit decimal floating-point arithmetic and calculate
the absolute and relative errors in your answers.
(a) 10420 + 0.0018
(b) 10424 − 10416
(c) 0.12347 − 0.12342
(d) (3626.6)(22.656)
Solution:
(a) The exact sum is 10420.0018, which becomes 10420 in 4-digit arithmetic. The
absolute error is ε = −0.0018, and the relative error is
δ=
ε
≈ 0.173 × 10−6 .
10420.0018
(b) The exact difference is 10424 − 10416 = 8. The computed difference is 10420 −
−8
10420 = 0. The absolute error is ε = −8, and the relative error is δ =
= −1.
8
(c) The exact difference is 0.12347 − 0.12342 = 0.00005. The computed difference is
0.1235 − 0.1234 = 0.0001. The absolute error is ε = .0001 − .00005 = .00005, and
.00005
= 1.
the relative error is
.00005
(d) The exact product (to four decimal places) is (3626.6)(22.656) = 82164.2496. The
computed product, after both pre- and post-multiplication rounding, is (3627)(22.66) =
82190. The absolute error is ε = 25.7504, and the relative error is
25.7504
≈ 0.3134 × 10−3
82164.2496
.
2
Download