I've done a lot of work on this in the last week, and have a couple different ideas on how to make a fast way to do this. I've made a wiki page here <https://github.com/sympy/sympy/wiki/Design-Notes:-Evaluating-expr-that-results-in-%60nan%60-or-%60oo%60>. It would be extremely helpful for people to take a look through and give me their thoughts. Thanks!
On Saturday, June 28, 2014 1:24:31 PM UTC-5, Aaron Meurer wrote: > > You might also be able to get a custom trigsimp that only the > simplifications you need from the fu module. > > Aaron Meurer > > On Fri, Jun 27, 2014 at 10:53 PM, Chris Smith <smi...@gmail.com > <javascript:>> wrote: > > Ahh...trisgsimp is like simplify in that it tries several things that > are > > known to generally work. If you know that it's trig-related because of > these > > sorts of ratios, you might just try rewriting > > > >>>> cancel((sin(x)/tan(x)).rewrite(exp)).subs(x,0) > > 1 > >>>> w=Wild('w'); (sin(x)/tan(x)).replace(tan(w),sin(w)/cos(w)).subs(x,0) > > 1 > > > > You could also extract Muls (foo.atoms(Mul)) and build up a replacement > > dictionary where the value of a given Mul is the value after > substitution if > > not nan or oo or else the value you get *after* simplifying that > expression. > > This way you are targeting only trouble expressions and not working with > the > > whole expression tree. > > > > On Friday, June 27, 2014 9:35:09 PM UTC-5, James Crist wrote: > >> > >> signsimp didn't seem to help. I'll try to get a gist of the expression > up > >> tomorrow, it's so huge I haven't succesfully ran simplify on it. > However, I > >> had the same thing happen with a readable expression. The issue was > >> something like: > >> > >> >>> expr = sin(a)/tan(a) > >> >>> expr.subs(a, 0) > >> nan > >> >>> expr = expr.trigsimp() > >> >>> expr > >> cos(a) > >> >>> expr.subs(a, 0) > >> 1 > >> > >> Based on the form of equations of motion, I assume it's something along > >> this line where a trig identity needs to be subbed out. For large > >> expressions, trigsimp is too slow to actually use, but I can't see a > way > >> around it. I tried all methods of trigsimp (interestingly `fu` is > faster for > >> small expressions, but `matching` is faster for large). Looking through > to > >> see if I can find a way to generate more compact expressions to attempt > to > >> avoid this end result. > >> > >> On Friday, June 27, 2014 7:29:48 AM UTC-5, Chris Smith wrote: > >>> > >>> Try only signsimp before substitution. Can you post code to generate > one > >>> of these expressions? > > > > -- > > 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 <javascript:>. > > To post to this group, send email to sy...@googlegroups.com > <javascript:>. > > 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/aad3b143-fb1e-4e6c-bcb5-deb07762e263%40googlegroups.com. > > > > > > For more options, visit https://groups.google.com/d/optout. > -- 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/a3aa8e52-6dcb-4da2-aab8-72de18ff4ec4%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.