On 19 mai, 03:36, leif <not.rea...@online.de> wrote: > vdelecroix wrote: > > In an attempt to improve #14567, I found the following thing (which > > for me is a bug). Consider the different real fields with rounding > > RNDD or RNDU. Then -pi is systematically wrongly approximated. > > AFAIK that's a (probably unexpected) feature rather than a bug, because > > R(-pi) = R(-1)*R(pi) > > (since pi is a symbolic constant, hence -pi a symbolic expression).
We should not have R(-pi) = R(-1) * R(pi) with rounding mode RNDD or RNDU because it is how it is documented and how it works for rationals. I agree that -pi is a symbolic expression but it is not a reason for having a wrong answer. If we want to round down the expression "- expr" then we should round up "expr" and then take the opposite. Note that there are more dramatic problems with the symbolic ring due to cancellation {{{ sage: sage: a.n(digits=8) 293.65079 sage: sage: a.n(digits=10) 292.6277805 sage: sage: a.n(digits=12) 292.634618133 sage: sage: a.n(digits=15) 292.634591053247 }}} What is shown above is that the rounding of ``a`` is *very far* from being the nearest element of RR... In my first post I also mentionned that it does not work either for number field elements {{{ a = NumberField(x^3-2, 'a', embedding=1.25).gen() for rnd in 'RNDD','RNDU': R = RealField(15,rnd=rnd) s,m,e = R(-a).sign_mantissa_exponent() }}} gives {{{ RNDD 20642 RNDU 20643 }}} instead of {{{ RNDD 20643 RNDU 20642 }}} Moreover, the approximation does not work as expected either (the last digits are always False) {{{ sage: sage: b = (76504*a - 96389) / (90325 - 71691*a) sage: b.n(digits=5) 0.096557 sage: b.n(digits=6) 0.0965556 sage: b.n(digits=7) 0.09655549 }}} Vincent -- 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 http://groups.google.com/group/sage-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.