Docsity

Study Guide for Homework 3 | Applied Numerical Methods | MATH 151A, Assignments of Mathematics

Toggle sidebar
bg1
Math 151A Homework #3 – due Wednesday 10/25, in class
Show all your work!
1. Trinary computing.
Imagine we’ve invented a trinary (base 3) computer, which stores information as trits
(trinary bits) which can take on values 0,1 or 2. If (as with binary computers) the tri-
nary computer uses 52 trits to hold the mantissa (a.k.a. the trinary fraction), how many
decimal digits of precision can we expect?
Answer:
Each trit can take on three values, so 52 trits take on 352 values. And log10 (352) =
52 ·log10(3) ≈24.810, so we can expect 24 or 25 digits of precision.
2. k-digit rounding approximation (Problem 24 of section 1.2)
Suppose that f l(y) is a k-digit rounding approximation to y. Show that
y−fl(y)
y≤0.5×10−k+1.
[Hint: If dk+1 <5, then f l(y) = 0.d1d2. . . dk×10n. If dk+1 ≥5, then fl(y) = 0.d1d2. . . dk×10n+
10n−k.]
Answer:
Let ybe represented by y= 0.d1d2d3. . . dkdk+1 . . . ×10n, where 1 ≤d1≤9 and 0 ≤
di≤9. If dk+1 <5, then fl(y) = 0.d1d2. . . dk×10nand so
y−fl(y)
y=
0.d1d2. . . dkdk+1 . . . ×10n−0.d1d2. . . dk×10n
0.d1d2d3. . . dkdk+1 . . . ×10n
=
0.dk+1dk+2 . . . ×10n−k
0.d1d2. . . dk+1dk+2 . . . ×10n
=
0.dk+1dk+2 . . .
0.d1d2. . . ×10−k
The denominator of the above expression is bounded below by 0.1, since we know that
d1≥1. The numerator is bounded above by 0.5, since we have assumed that dk+1 <5.
So we have
y−fl(y)
y≤0.5
0.1×10−k
≤0.5×10−k+1.
So the error bound holds for dk+1 <5.
Now if dk+1 ≥5, then we round up by adding 1 to the digit dk, which means that
fl(y) = 0.d1d2. . . dk×10n+ 10n−kand thus
y−fl(y)
y=
0.d1d2. . . dkdk+1 . . . ×10n−0.d1d2. . . dk×10n−10n−k
0.d1d2d3. . . dkdk+1 . . . ×10n
=0.dk+1dk+2 . . . ×10n−k−10n−k
0.d1d2. . . dk+1dk+2 . . . ×10n
=0.dk+1dk+2 · · · − 1
0.d1d2. . . dk+1dk+2 . . . ×10−k.
pf3

Partial preview of the text

Download Study Guide for Homework 3 | Applied Numerical Methods | MATH 151A and more Assignments Mathematics in PDF only on Docsity!

Math 151A Homework #3 – due Wednesday 10/25, in class

Show all your work!

  1. Trinary computing.

Imagine we’ve invented a trinary (base 3) computer, which stores information as trits

(trinary bits) which can take on values 0, 1 or 2. If (as with binary computers) the tri-

nary computer uses 52 trits to hold the mantissa (a.k.a. the trinary fraction), how many

decimal digits of precision can we expect?

Answer:

Each trit can take on three values, so 52 trits take on 3

52 values. And log 10 (

52 ) =

52 · log 10 (3) ≈ 24 .810, so we can expect 24 or 25 digits of precision.

  1. k-digit rounding approximation (Problem 24 of section 1.2)

Suppose that f l(y) is a k-digit rounding approximation to y. Show that

∣ ∣ ∣

y − f l(y)

y

∣ ≤ 0. 5 × 10

−k+ .

[Hint: If dk+1 < 5, then f l(y) = 0.d 1 d 2... dk× 10

n

. If dk+1 ≥ 5, then f l(y) = 0.d 1 d 2... dk× 10

n

10

n−k .]

Answer:

Let y be represented by y = 0.d 1 d 2 d 3... dkdk+1... × 10

n , where 1 ≤ d 1 ≤ 9 and 0 ≤

di ≤ 9. If dk+1 < 5, then f l(y) = 0.d 1 d 2... dk× 10

n and so

∣ ∣ ∣

y − f l(y)

y

0 .d 1 d 2... dkdk+1... × 10

n − 0 .d 1 d 2... dk× 10

n

0 .d 1 d 2 d 3... dkdk+1... × 10 n

0 .dk+1dk+2... × 10

n−k

0 .d 1 d 2... dk+1dk+2... × 10

n

0 .dk+1dk+...

0 .d 1 d 2...

∣× 10

−k

The denominator of the above expression is bounded below by 0.1, since we know that

d 1 ≥ 1. The numerator is bounded above by 0.5, since we have assumed that dk+1 < 5.

So we have ∣ ∣ ∣

y − f l(y)

y

∣ ≤^

× 10

−k

≤ 0. 5 × 10

−k+ .

So the error bound holds for dk+1 < 5.

Now if dk+1 ≥ 5, then we round up by adding 1 to the digit dk, which means that

f l(y) = 0.d 1 d 2... dk× 10

n

  • 10

n−k and thus

∣ ∣ ∣

y − f l(y)

y

0 .d 1 d 2... dkdk+1... × 10

n − 0 .d 1 d 2... dk× 10

n − 10

n−k

0 .d 1 d 2 d 3... dkdk+1... × 10

n

∣ 0 .d k+1dk+2...^ ×^10

n−k − 10

n−k

∣ 0 .d 1 d 2... dk+1dk+2...^ ×^10

n

∣ 0 .d k+1dk+2 · · · −^1

∣ 0 .d 1 d 2... dk+1dk+...^

× 10

−k .

Again, the denominator is bounded below by 0.1. The first term of the numerator is

bounded above by 1.0 and below by 0.5, which means the numerator is bounded above

by 0.5. So we have

∣ ∣ ∣

y − f l(y)

y

× 10

−k

≤ 0. 5 × 10

−k+ .

Therefor, the error bound also holds for dk+1 ≥ 5.

  1. Approximating π

Compute the absolute error and relative error for approximating π by 22/7. How many

significant digits is the approximation good to?

Answer:

The absolute error is |π − 22 / 7 | ≈ 1. 26 × 10

− 3 and the relative error is the absolute

error divided by π, (1. 26 × 10

− 3 )/(π) = 4. 02 × 10

− 4

. The number of significant digits

is the largest integer t for which

Relative Error ≤ 5 × 10

−t .

Since 4. 02 × 10

− 4 ≤ 5 × 10

− 4 but 4. 02 × 10

− 4

5 × 10

− 5 , the approximation is good to

4 significant digits.

  1. Approximating e

a. The number e can be approximated by the sequence

e ≈

n ∑

k=

k!

If n = 4, what is the relative error and number of significant digits in this approximation

of e? How about when n = 8?

Answer:

When n = 4, e ≈

k=

1 k!

1 2

1 6

1 24

= 2.708¯3, which gives a relative

error of ∣ ∣ ∣

e − 2 .708¯ 3

e

∣ ≈^3.^66 ×^10

− 3

and 3 significant digits.

When n = 8, e ≈

8 k=

1 k!

≈ 2 .718278770, which gives a relative error of

e − 2. 718278770

e

∣ ≈ 1. 125 × 10

− 6

and 6 significant digits.

b. The number e can also be approximated by

e ≈ n ·

2 πn

n!

) 1 /n

What is the relative error and number of significant digits when n = 4, n = 8, and

n = 20?