upiterbarg / mpmath

Automatically exported from code.google.com/p/mpmath
Other
0 stars 0 forks source link

Support per-number precision/accuracy #111

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be good if mpmath were able to support accuracy/precision on a 
per-number basis as 
opposed to globally. Currently, with a global precision variable, it is 
possible to get a more precise 
output than the input allows.

For example: Pi * 2.34 * 0.58 can be happily computed to 1000s of significant 
figures, even though 
it is not valid to quote the result to more than 2 s.f. (as the 0.58 is only 
accurate to 2 s.f.). If 
individual precision was possible on a per-number basis then each number could 
be given its own 
precision and this would not be such an issue.

Original issue reported on code.google.com by fred...@witherden.org on 23 Dec 2008 at 4:20

GoogleCodeExporter commented 9 years ago
Thanks for reporting it. We discussed this on IRC -- but just a note for 
Fredrik J.:
we think it'd be good to have this. I think we maybe discussed this in the 
past, but
I forgot what was the argument for having a global precision?  

Original comment by ondrej.c...@gmail.com on 23 Dec 2008 at 11:56

GoogleCodeExporter commented 9 years ago
This would make things much more complicated IMO. In any case, if you need this
feature, it is not hard to write a number type that implements it by wrapping 
libmpf
(as SymPy does). Another option is to use intervals.

Original comment by fredrik....@gmail.com on 26 Dec 2008 at 8:30

GoogleCodeExporter commented 9 years ago
We mean in the sympy case. Is the precision stored somewhere in the Real class?

Original comment by ondrej.c...@gmail.com on 26 Dec 2008 at 8:59

GoogleCodeExporter commented 9 years ago
Yes, the _prec attribute.

Original comment by fredrik....@gmail.com on 26 Dec 2008 at 9:24