Comment #2 on issue 1429 by asmeurer: matches fails to match differential equation http://code.google.com/p/sympy/issues/detail?id=1429
The fix doesn't seem to affect performance much based on some benchmarks I ran, despite the running of expand in a function that gets called as often as match(). There were several tests that ran a little slower, but over all the new state actually finished the benchmark two seconds faster. We can make it better because we really only need to call expand_mul with deep=False. Also, the call should be moved from _matches_commutative() to Add._combine_inverse(), as it is only need when that is the _combine_inverse function that is called. As for the issue of the minus sign distributing, I think it might be because the Mul is evaluated iteratively when it is not in the Add, and it is set to distribute when there are exactly two arguments: a number and an Add. I am not sure if there is an easy way to fix it up in combine_inverse so that it properly subtracts (f(x) - x)*diff(f(x), x) from -(x - f(x))*diff(f(x), x). It is no good to try to distribute minus signs selectively, because you could possibly distribute them into the wrong Add (like -(x + y)*(x - y) becoming (-x - y)*(x - y) when it needs to become (x + y)*(y - x)). Frankly, the best thing would be to remove all automatic distribution as per http://groups.google.com/group/sympy/browse_thread/thread/32bbf03c1bd922aa/a6557f077e3b2df1? and issue 1497, but until then, I think calling expand_mul in Add._combine_inverse() is the best work around. -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sympy-issues?hl=en -~----------~----~----~----~------~----~------~--~---
