>> diary off >> explore_eps For u = 3.0517578e-05 1.0+u> 1.0 For u = 1.5258789e-05 1.0+u> 1.0 For u = 7.6293945e-06 1.0+u> 1.0 For u = 3.8146973e-06 1.0+u> 1.0 For u = 1.9073486e-06 1.0+u> 1.0 For u = 9.5367432e-07 1.0+u> 1.0 For u = 4.7683716e-07 1.0+u> 1.0 For u = 2.3841858e-07 1.0+u> 1.0 For u = 1.1920929e-07 1.0+u> 1.0 For u = 5.9604645e-08 1.0+u> 1.0 For u = 2.9802322e-08 1.0+u> 1.0 For u = 1.4901161e-08 1.0+u> 1.0 For u = 7.4505806e-09 1.0+u> 1.0 For u = 3.7252903e-09 1.0+u> 1.0 For u = 1.8626451e-09 1.0+u> 1.0 For u = 9.3132257e-10 1.0+u> 1.0 For u = 4.6566129e-10 1.0+u> 1.0 For u = 2.3283064e-10 1.0+u> 1.0 For u = 1.1641532e-10 1.0+u> 1.0 For u = 5.8207661e-11 1.0+u> 1.0 For u = 2.910383e-11 1.0+u> 1.0 For u = 1.4551915e-11 1.0+u> 1.0 For u = 7.2759576e-12 1.0+u> 1.0 For u = 3.6379788e-12 1.0+u> 1.0 For u = 1.8189894e-12 1.0+u> 1.0 For u = 9.094947e-13 1.0+u> 1.0 For u = 4.5474735e-13 1.0+u> 1.0 For u = 2.2737368e-13 1.0+u> 1.0 For u = 1.1368684e-13 1.0+u> 1.0 For u = 5.6843419e-14 1.0+u> 1.0 For u = 2.8421709e-14 1.0+u> 1.0 For u = 1.4210855e-14 1.0+u> 1.0 For u = 7.1054274e-15 1.0+u> 1.0 For u = 3.5527137e-15 1.0+u> 1.0 For u = 1.7763568e-15 1.0+u> 1.0 For u = 8.8817842e-16 1.0+u> 1.0 For u = 4.4408921e-16 1.0+u> 1.0 For u = 2.220446e-16 1.0+u> 1.0 Finally, after 39 iterations we find that for u = 1.110223e-16 1.0+u is NOT > 1.0 therefore unit roundoff is 2.220446e-16 Break out of the for loop >> type explore_eps % explore_eps.m % k. stewart spring 1998 - written for CS 205 % we want to examine the behavior of the floating point % number system % % assuming no background or familiarity with floating point % behavior, we'll examine first a finite list of values % % it's dangerous to use the variable named "eps" since this is % predefined MATLAB value which the user can reset % echo off u = 1/2^15; % start the search off at an arbitrary, but exact, binary value formax = 40; for i=1:formax if (1.0 + u > 1.0) ; fprintf('For u = %12.8g 1.0+u> 1.0 \n',u) else fprintf('Finally, after %4.0f iterations we find that\n',i) fprintf(' for u = %12.8g 1.0+u is NOT > 1.0 \n',u) fprintf(' therefore unit roundoff is %12.8g\n',2*u) fprintf(' Break out of the for loop\n') break; end % if-else block u = u/2; if (i == formax) fprintf('Used %g loop iterations without finding u\n',formax) end end % for i=1:10 loop >> diary off