

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Numerical Computation; Subject: Computer Science; University: University of Colorado - Boulder; Term: Unknown 1989;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


January 20, 2009
Solutions to Assignment 1
function meps = macheps
meps = 1; while (1.0 + meps > 1.0) meps = meps/2; end meps = meps*
You just have to be careful not to get macheps/2. On a machine that obeys the IEEE standard, double precision macheps is 2. 2 ∗ 10 −^16. That is the value returned by Matlab’s eps. (Also, see the note at the end of the next solution.)
First, consider the 3 bit exponents:
mine = (000) 2 = 0 maxe = (111) 2 = 7.
The values 0 and 7 are reserved, so the range of biased exponents is [1, 6]. In IEEE, where there are 8 bits for the exponent, the bias on the exponent is 2^8 −^1 −1 =
minm = min(1.f ) 2 = (1.00000) 2 = 1 maxm = max(1.f ) 2 = (1.11111) 2 = 1. 96875.
Machine epsilon is 2−^5 = 0. 03125.
So, the range of normalized positive floating-point numbers (not counting zero) is
[(1.00000) 2 ∗ 2 −^2 , (1.11111) 2 ∗ 23 ] = [0. 25 , 15 .75].
If you want to consider denormalized numbers, that range becomes
[(0.00001) 2 ∗ 2 −^2 , (1.11111) 2 ∗ 23 ] = [0. 03125 , 15 .75].
But, plus and minus zero are of course representable by means of the exceptional exponents, so the range is actually
[+0. 000 , 15 .75].
(+0.000 is technically a positive number, but it’s fine if your answer is the above 0. and not this one including it.) I told you in class today that the text had the wrong definition of machine epsilon. That’s not actually true–rather it is an alternative definition of machine epsilon (but not a standard one). If you use the text’s definition, machine epsilon here is 2−^6 , and you’d remove the final step meps = meps*2 from the script in the first problem.
function u = uflo
u(1) = realmin; for i = 1: u(i+1) = u(i)/2; end format long e u
I’ll be interested to see if anyone discovered a machine where denormalized numbers were not properly implemented.
If you worked with other people on any of these problems, you must list the names of your collaborators. All writeups must be your own.