% Script File: EulerRoundOff
%
% Illustrates Euler method in 3-digit floating point arithmetic
 
   close all
   t = linspace(0,1);
   e = exp(-t);
   for n = 140:20:180
	  tvals = linspace(0,1,n+1);
	  yvals = 0*tvals;
	  one = represent(1);
	  yc = one;
	  factor = float(one,float(one,represent(n),'/'),'-');
	  yvals(1) = 1;
	  for k=1:n
	     yc = float(factor,yc,'*');
		 yvals(k+1) = convert(yc);
	  end
 	  plot(tvals,abs(exp(-tvals)-yvals))
	  hold on
	  axis([0 1 0 .05])	
	  title(sprintf('n = %3.0f ',n))
   end
   hold off
   gtext('n = 140')
   gtext('n = 160')
   gtext('n = 180')

   
