I'm trying to evaluate the machine epsilon of my computer (see below). I wrote this:
eps = 1.0;
p = 0;
While[(1.0 + eps) > 1.0, eps = eps/2.0; p += 1];
eps
p
eps*2
and got:
1.42109*10^-14
46
2.84217*10^-14
which is not what I expected (IEEE754). So I did this
EngineeringForm[1.0 + 2 * eps, 20]
EngineeringForm[1.0 + eps, 20]
EngineeringForm[1.0 + (eps/2.0), 20]
EngineeringForm[1.0 + (eps/4.0), 20]
EngineeringForm[1.0 + (eps/16.0), 20]
EngineeringForm[1.0 + (eps/32.0), 20]
and got that:
1.000000000000028
1.000000000000014
1.000000000000007
1.000000000000004
1.000000000000001
1.
which seems to contradict the termination condition of the 'while' loop. So I would like to understand what's going on under Mathematica's hood. I tried to look for some information on Mathematica's internal float representation without success. Any help to explain these results is welcome. I'm sorry if my question is a bit vague.
Eric
Context:
SystemInformationData[{"Kernel" ->
{"Version" -> "9.0 for Mac OS X x86 (64-bit) (January 24, 2013)",
"ReleaseID" -> "9.0.1.0 (4055646, 4055073)", ...}]
EDIT
It was suggested the following program that works directly for some reason:
eps = 1.0;
n = 0;
While[(1.0 + eps) - 1.0 > 0.0,
eps = eps/2;
n++;
];
eps*2
n
Log[2, eps*2]
$MachineEpsilon
? $\endgroup$1. + $MachineEpsilon > 1.
... $\endgroup$