On Friday, July 11, 2014 11:13:28 PM UTC-5, Richard Fateman wrote: > > The obvious brute force method would be to use software floats in which > case you could increase the precision and the range of the > numbers involved. I'm assuming the NaNs come from division by zero where > the denominator is not actually zero but computes to zero. > And the infs come from machine float overflows. > > The NaNs come from division events where the denominator is actually zero, but after simplification isn't. For example:
>>> expr = sin(a)/tan(a) >>> expr.subs(a, 0) nan # The deniminator of that was actually 0 (tan(0) = 0) >>> expr = expr.trigsimp() >>> expr cos(a) >>> expr.subs(a, 0) 1 In this case I don't think software floats would solve anything. > Incidentally, if you have 31,000,000 operations that result in a single > number, you can be fairly confident that the number is > not particularly accurate, and that rearranging the operations will get > you a different evaluation. Maybe extremely different. > > there are some forms that are susceptible to accurate evaluation, or > evaluation with known bounds. There is also > interval arithmetic, which should give you a bounding interval for a true > result. > > Possible winning forms would be polynomials, so-called Poisson series, > truncated Taylor series. > > This is something that hadn't occured to me, or seemingly anyone in the `mechanics` team. I was under the impression that when evaluating numerically sympy used arbitrary precision floats to get accurate results. Is this not so? If not, what would be a good way around this, keeping in mind that the expressions in `mechanics` are often large, but fairly simple (i.e. contain mostly sums of terms containing variables, trigonometric functions, powers, and sqrt). > RJF > > >>> -- 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+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/b1f054fe-30e8-4272-89a3-9eab0b093f70%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.