============= Forewords =============

I investigated the numerical issues on my ARM build, and after much poking around and searching, I found that I was chasing the dahu : the tests were wrong, and the result were good.

Let's consider the numerical failures one by one :
============= 1/4 =============
File "/home/jpuydt/sage-4.8/devel/sage-main/sage/functions/other.py", line 511:
    sage: gamma1(float(6))
Expected:
    120.0
Got:
    119.99999999999997

Let's see how bad this is :
sage: res=gamma(float(6))
sage: res
119.99999999999997
sage: n(res,prec=57)
120.0000000000000
sage: n(res,prec=58)
119.99999999999997

============= 2/4 =============
File "/home/jpuydt/sage-4.8/devel/sage-main/sage/symbolic/expression.pyx", line
 6256:
    sage: SR(10.0r).gamma()
Expected:
    362880.0
Got:
    362880.00000000047

Let's see how bad that is:
sage: res=SR(10.0r).gamma()
sage: res
362880.00000000047
sage: n(res,prec=54)
362880.000000000
sage: n(res,prec=55)
362880.0000000005

============= 3/4 =============
File "/home/jpuydt/sage-4.8/devel/sage-main/sage/interfaces/maxima_abstract.py"
, line 1595:
    sage: float(maxima("1.7e+17"))
Expected:
    1.7e+17
Got:
    1.6999999999999997e+17

Let's see how bad that is:
sage: res=float(maxima("1.7e17"))
sage: res
1.6999999999999997e+17
sage: n(res,prec=57)
1.700000000000000e17
sage: n(res,prec=58)
1.6999999999999997e17


============= 4/4 =============
File "/home/jpuydt/sage-4.8/devel/sage-main/sage/rings/arith.py", line 3061:
    sage: binomial(0.5r, 5)
Expected:
    0.02734375
Got:
    0.02734375000000001

Let's see how bad that is:
sage: res=binomial(0.5r,5)
sage: res
0.02734375000000001
sage: n(res,prec=57)
0.02734375000000001
sage: n(res,prec=54)
0.0273437500000000

============= CONCLUSION =============
A double precision floating point number is supposed to have 53 digits, according to the norm (http://en.wikipedia.org/wiki/IEEE_754-2008), and the results are correct from that point of view.

So the tests should be modified not to depend on the specific implementation : they're currently testing equality of floats!

I would provide a patch for the tests so they use n(..., prec=53), but I'm hitting a problem in one of the cases ; see the mail I sent yesterday for more about that.

Snark on #sagemath

--
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to 
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to