PS01S

advertisement
ENGRD 241: Engineering Computation
PS01S, Fall 2002
SOLUTION TO PROBLEM SET NUMBER 1
1. Suppose that you are using a computer with a floating point system having a 5-digit
mantissa and exponents of ±0 through ±99 (Base 10). If the computer hardware normalizes
after every operation, then the smallest non-zero positive number is 0.10000E-99. Numbers
can be either negative or positive.
a) With normalization, what is the machine representation of the difference: 0.14358E-99
– 0.14359E-99 ?
0.14358E-99 – 0.14359E-99 = – 0.00001E-99
with normalization this becomes – 0.10000-103 which cannot be represented in this
machine. Therefore, 0.14358E-99 – 0.14359E-99 = 0.
b) If the hardware does not normalize, what is the smallest non-zero positive number that
can be represented?
Without normalization, the smallest non-zero positive number would be 0.00001E-99
c) What is the smallest possible number (algebraic)?
The smallest possible number would be the largest possible negative number, i.e.,
-0.99999E+99
2. If the hardware normalizes, how many different floating-point numbers can the hardware
represent (big and small, positive and negative)?
There are 8 different positions that can be available in the representation of a floatingpoint number by this machine:
±a.bcdfg E ±m
where: ±
2 values
a = 0 (always) 1 value
b = [1 to 9] 9 possible values
c, d, f & g = [0 to 9] 10 possible values
± m [-99 to 99]
199 possible values [including zero]
Thus there are 2*a*b*c*d*f*g*(±)m + 1 = 35,820,001 possible values.
(The +1 comes from the representation of 0.)
3. What is the smallest positive floating-point number that can be added to 1.0 and, after
chopping, still yield a number larger than one? This is machine epsilon.
Following the example in Chapra and Canale, 1.0 is represented as 0.10000E+01.
The smallest floating point number that can be added that will increase the value
(after chopping) is 0.00001E+01 = 10-5 * 101 = 10-4. Comparing this with the formula
on p. 64 of Chapra and Canale (for chopping):  = b1-t = 101-5 = 10-4
Page 1 of 2
ENGRD 241: Engineering Computation
PS01S, Fall 2002
4. What is the absolute difference between 0.10000E+03 (or 100) and the next largest and
smallest numbers available on this machine? Express the result in normalized form.
Next largest number: 0.10001E+03
+ = 0.10001E+03 – 0.10000E+03 = 0.00001E+03 = 0.10000E-01
In normalized form x/x = 0.10000E-01/0.10000E+03 = 10-4 (same as )
Next smallest number: 0.99999E-02
– = 0.10000E+03 – 0.999999E+02 = 0.10000E+03 – 0.09999E+03 = 0.00001E+03
= 0.10000E-01
In normalized form, same as above
5. Evaluate the function:
4x

3  2x 2

2
at x = 1.20 and 1.22 twice, once using full precision on your calculator or computer and
once using 4-digit arithmetic. Evaluate the error and suggest a reason for the difference in
the error.
x
1.2
1.22
Exact
f(x)
333.3333
9066.587
4*x
4.8
4.88
2x2
2.88
2.977
(3-2x2) 2
0.0144
0.5290E-3
Approx.
~f(x)
333.3
9225
% True Error (t)
= [ f(x) – ~f(x)]/f(x)
0.01 %
-1.74%
The denominator is equal to zero when 2x2 = 3, or when x = 1.22475 . . . As x gets nearer
to this value, more significant figures are required to perform the calculation with accuracy.
Page 2 of 2
Download