Le 10/08/2016 à 13:38, Erik Bray a écrit :
> Hi all,
> 
> Sorry if this has been discussed ad-infinitum before--I looked around
> a bit but didn't find a definitive answer.
> 
> I have one (well at least one) test that's failing on Cygwin due to
> tiny difference in the last digit of the result of log(3).
> 
> This leads to to several questions:
> 
> 1) Is it worth investigating the reason for the difference?
> 2) Is it worth trying to provide a workaround for the difference?
> 3) Or should the test just be updated to ignore the last couple digits
> of the result, and if so how (ellipses?)
> 
> Thanks,
> Erik
> 
Hello,

What do you mean by log(3) ?

Is it log(3.) or log(RDF(3)) ?


With log(RDF(3)), this is classical; changing the library version, or
the compiler version often changes the way some expressions and
functions are computed. As floating point arithmetic is not associative,
this is classical. With log(3.) (RealField()), I don't know.
When we wrote the book "Calcul Mathématique avec Sage", we had this
problem: after some release (some months) some  doctests of the chapter
on numerical algebra and floating point numbers failed. The only work
around we found was to truncate the last digit in the output, to try to
test what should remain constant.

Note that:

sage: log(RDF(3))
1.0986122886681098
sage: log(3.)
1.09861228866811

But:
sage: log(RDF(3)).n(prec=53)
1.09861228866811
sage: log(3.).n(prec=53)
1.09861228866811

sage: log(RDF(3))==log(3.)
True

as we also know that:
sage: RDF.prec()==RealField().prec()
True


So in this case it is only a problem of rounding output.


Good luck.

Yours
t.



-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

<<attachment: tdumont.vcf>>

Reply via email to