%
%   MEPS.M    Estimate Machine Epsilon 
%
%   Machine epsilon is defined as the smallest floating point number
%   such that 
%      1 + epsilon > 1
%
%   We can estimate this quantity by continually decreasing a number until this
%   condition is no longer valid.  This is what is done here in this simple
%   program.
%
%   Note that Matlab has a built-in value of machine epsilon, called eps.
%
%   Written by J. R. White, UMass-Lowell (last update: Oct. 2017)
%

      clear all,   close all
%
%   initialize epsilon and continue to divide by two until condition is not met
      epsilon = 1.0;
      while epsilon + 1.0 > 1.0
        epsilon = epsilon/2;
      end
%
%   multiply estimate by two to be conservative
      epsilon = 2*epsilon;
      disp('Estimate of machine epsilon is'),   disp(epsilon)
%
%   edit Matlab's built-in value
      disp('   ')
      disp('Matlab''s internal value of machine epsilon is'),   disp(eps)
%
%  end of problem

