Problem 1: Compute the absolute error and relative
error in approximations of p by p* .
(Use calculator!)
a) p = π, p* = 22/7;
b) p = π, p* = 3.1416.
Solution : For this exercise, you can use either calculator
or Matlab .
a) Absolute error: |p − p* | = | π − 22/7| = 0.0012645.
Relative error:

b) Absolute error: |p − p* | = | π − 3.1416| = 7.3464 ×
10-6.
Relative error:

Problem 2: Find the largest interval in which p*
must lie to approximate
with
relative error at most 10-5 for each value for p .
Solution: The relative error is defined as
where in our case,
We have

Therefore,

or

Hence,

This interval can be written in decimal notation as [1.41419942 . . .,
1.41422770 . . .].
Problem 3: Use the 64-bit long real format to find the decimal equivalent of the
following
floating-point machine numbers.
a) 0 10000001010 10010011000000· · ·0
b) 1 10000001010 01010011000000· · ·0
Solution:
a) Given a binary number (also known as a machine number)

a decimal number (also known as a floating-point decimal number) is of the form:

Therefore, in order to find a decimal re equation s/lcm-and- variable -expressions.html">presentation of a binary number, we need
to find
s, c, and f.
The leftmost bit is zero , i.e. s = 0, which indicates that the number is
positive .
The next 11 bits, 10000001010, giving the characteristic, are equivalent to the
decimal
number:

The exp onent part of the number is therefore

The final 52 bits specify that the mantissa is

Therefore, this binary number represents the decimal number

b) Given a binary number

a decimal number is of the form:

Therefore, in order to find a decimal representation of a binary number, we need
to find
s, c, and f.
The leftmost bit is zero, i.e. s = 1, which indicates that the number is
negative .
The next 11 bits, 10000001010, giving the characteristic, are equivalent to the
decimal
number:

The exponent part of the number is therefore

The final 52 bits specify that the mantissa is

Therefore, this binary number represents the decimal number

Problem 4: Find the next largest and smallest machine numbers in decimal form
for the
numbers given in the above problem.
Solution:
a) Consider a binary number (also known as a machine number)
0 10000001010 10010011000000 · · ·00 ,
• The next largest machine number is
0 10000001010 10010011000000 · · ·01 . (1)
From problem 3(a), we know that s = 0 and c = 1034. We need to find f:

Therefore, this binary number (in (1)) represents the decimal number

• The next smallest machine number is
0 10000001010 10010010111111 · · ·11 . (2)
From problem 3(a), we know that s = 0 and c = 1034. We need to find f:
1

1 Note that

The formula above is a specific case of the fol lowing more general equation:

Similarly, we also have a formula:

To get some intuition about these formulas, consider an example with M = 2 and N
= 5, for instance.
Therefore, this binary number (in (2)) represents the decimal number

b) Consider a binary number
1 10000001010 01010011000000 · · ·0
• The next largest (in magnitude) machine number is
1 10000001010 01010011000000 · · ·1 (3)
From problem 3(b), we know that s = 1 and c = 1034. We need to find f:

Therefore, this binary number (in (3)) represents the decimal number

• The next smallest (in magnitude) machine number is
1 10000001010 01010010111111 · · ·1 (4)
From problem 3(b), we know that s = 1 and c = 1034. We need to find f:

Therefore, this binary number (in (4)) represents the decimal number
