No BSD License  

Highlights from
Numerical Methods for Physics

from Numerical Methods for Physics by Alejandro Garcia
Companion Software

rndoff.m
% rndoff - Demo program illustrating round-off error
clear; help rndoff;  % Clear memory and print header
h=1;   % Initial value for h
for i=1:21
  temp = (10+h)-10;  % Without round-off, temp=h
  hplot(i) = h;
  eplot(i) = abs(temp-h)/h;  % Absolute fractional error
  h = h/10;      % Decrement magnitude of h
end
loglog(hplot,eplot,'*');  % Plot data using log-log scale
xlabel('h');
ylabel('Fractional error');
title('Round-off Error');

Contact us at files@mathworks.com