#!/usr/bin/perl -w
# The normal aproximation to EPS error of the machine in lineraly
# algorithm is done by dividing in halves until a number fractionated is
# undishgisable of the previous. Thus, the error showed is a fact, but
# comes from a previous aproximation split, so the better you split
# the better aproximation to EPS you get. Not halves, let say a hundred.
# Why a hundred? Because it's said that this algorithm has one order
# of magnitude of error (over 3rr0r).
use 5.030;
my $epsilon1 = 1.0;
my $epsilon2;
my $last;
my $divisor = 100; # greedy but not too much
while (1.0 + 0.5 * $epsilon1 != 1.0){
$last = $epsilon1; # last error that is significant
$epsilon1 *= 0.5;
}
say "epsilon1 = $epsilon1";
$epsilon2 = $last; # passed to phase 2
for ( my $i = $divisor-1; $i>0 && 1.0 + $epsilon2 != 1.0; $i-- ) {
$last = $epsilon2;
$epsilon2 *= ($i/$divisor); # same strategy, less steps
}
say "epsilon2 = $last"; # because $epsilon2 "truly" == 0
my $epsilon3 = $last; # passed to phase 3
for ( my $i = $divisor-1; $i>0 && 0.0 + $epsilon3 != 0.0; $i-- ) {
$last = $epsilon3;
$epsilon3 *= ($i/$divisor); # same
}
say "epsilon3 = $last"; # curious thing comparing 1's is different to comparing 0's
say "See details inside.";
exit 1;
__END__
Wow! If you cut the 1.0+ and compares with 0.0 ...
Why wow? Beacuse it's near 1e-50 which is a rounded Plank number, so
you can try with modeles of higher precision maths.
Problem is that IEEE754 which defines formats for floats, says that
the digits corresponding to a 64 bit float are 53, so top is reached
and no more could be expected, to be pedantic.