Updates: Labels: -Priority-Medium Priority-High Comment #2 on issue 1495 by smichr: minus problem http://code.google.com/p/sympy/issues/detail?id=1495
I got an infinite recursion from could_extract_minus_sign() when checking the expression: x*(-2*a*x - 2*x**3). I also note that the routine has the test for multiplicative terms: if den != 0 but I think that should be "den != 1". And then I'm not sure of the logic that should follow that so I'm hesitant to do more. Should the test for a multiplicative term just be something like the following? Note that no check for den (or num) being "1" is done since these terms are no problem to check. elif self.is_Mul: num, den = self.as_numer_denom() return len([1 for tmp in num.args if tmp.could_extract_minus_sign()]+ \ [1 for tmp in den.args if tmp.could_extract_minus_sign()])%2 Although this code works for answering the question of whether a minus could be factored out, it doesn't resolve the issue of getting something into canonical form, e.g. >>> -x*(-2*a*x - 2*x**3) -x*(-2*a*x - 2*x**3) We would like to see x*(2*a*x + 2*x**3) instead, right? I can copy this to a new issue if deemed necessary. I'm putting this as a high priority because a simple question should not give an infinite recursion ;-) /c -- You received this message because you are listed in the owner or CC fields of this issue, or because you starred this issue. You may adjust your issue notification preferences at: http://code.google.com/hosting/settings --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy-issues" group. To post to this group, send email to sympy-issues@googlegroups.com To unsubscribe from this group, send email to sympy-issues+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sympy-issues?hl=en -~----------~----~----~----~------~----~------~--~---