Weird behavior in combining precisions in numerical evaluation: why?

17 views
Skip to first unread message

r.du...@gmail.com

unread,
Sep 22, 2017, 3:03:38 PM9/22/17
to sy...@googlegroups.com
Hi to all.

I understand that "prec" as reported in Float internal representation is just not a measure of the "true" error but at most an upper bound on it.

But, as explained here [1], in sympy "If inexact, low-precision numbers are involved in a calculation with with higher precision values, the evalf engine will increase the precision of the low precision values and inexact results will be obtained."

Example:
>>> srepr(Float('1/3',30)+Float('2/3',20))
Float('1.00000000000000000000028234431569', prec=30)
>>> srepr(Float('3/5',30)*Float('5/3',20))
Float('0.999999999999999999999661186821177', prec=30)

A user mixing precisions and looking at the precision of the result would have the false impression that the final precision is 30, while here it is at most 20.

So, to be "fool-proof", here I would have expected to have as results Floats of precision 20.

May be I'm missing something: what is the point of this weird behavior in numerical evaluation?

Thanks for any insight
ric

[1] http://docs.sympy.org/latest/gotchas.html?highlight=precision#evaluating-expressions-with-floats-and-rationals

Aaron Meurer

unread,
Sep 22, 2017, 9:53:40 PM9/22/17
to sy...@googlegroups.com
This has been discussed in some recent issues (which I can't seem to
find at the moment). We definitely should change the float operations
to use the minimum precision, not the maximum.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/3223608.D5bRag6ZZt%40ipht-ia-004976.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages