octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: eps function and numerical accuracy


From: Pascal Dupuis
Subject: Re: eps function and numerical accuracy
Date: Tue, 9 Jul 2013 14:13:35 +0200

2013/7/9 Dr. Alexander Klein <address@hidden>:
>
> I'm really not sure what the standards say, but I seem to remember that EPS 
> in C is defined as the smallest positive number such that 1+EPS != 1, or 
> rather (1+EPS)-1==EPS.
>
> As a first approximation, this seems to be the case in Octave, too:
>
>> eps(1)
> ans =  2.22044604925031e-16
>> eps(2)
> ans =  4.44089209850063e-16
>

The computing of eps is :

eps(x) = abs(x) * power(2, -precision(x))

In this case, the precision is 52 bits, corresponding to the 52 bits
of mantissa in IEEE-754 'double precision' floating point numbers. In
some cases, gcc may use an extended double precision (long double
type), wit 64 bits of mantissa and eps of  5.42101086242752e-20, but
this is OS and platform specific.

Note also that floating-point computations are sometimes not associative:
(2^60+1) - (2^60) = 0, as (2^60+1) is approximated by 2^60.

To conclude: trying to play around with variables mixing big and small
quantities requires carefull examination of the effects of rounding.
Or better, look at the operation with higher precision arithmetic :-)

Regards

Pascal


reply via email to

[Prev in Thread] Current Thread [Next in Thread]