On Fri, Apr 13, 2012 at 12:36, krastanov.ste...@gmail.com <krastanov.ste...@gmail.com> wrote: > I was looking at evalf.py. and I don't understand how it come to be so > complicated. I thought that all the evaluation is automatically done > by mpmath, but there is much pre- and post-processing that I do not > understand. Can someone explain the general idea to me?
The pre- and post-processing is mostly tracking accuracy, but there are lots of subtle special cases that need handling. Now that mpmath has much better support for interval arithmetic, it wouldn't be unreasonable to rewrite evalf using interval functions. You'd traverse the expression tree and do interval arithmetic, starting at the target prec plus a few extra bits, then check if the resulting interval is precise enough, and if not try again at geometrically increasing precision (say adding 20, 40, 80, 160, ... bits). The evalf code does basically this plus a few more tricks that could be incoporated (this would add back some of the complexity, but it would still probably be cleaner and less bug-prone than the present code). If the internal interval functions (mpi_ and mpci_ prefix in mpmath.libmp) are used, performance should be ok, probably a bit slower than the current evalf code but not terrible (and some of the slowdown could probably be recovered with future improvements to the interval functions in mpmath). And for arithmetic operations, floor function, etc. the error tracking will be completely rigorous. Fredrik -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.