Oh, so that's where the broken Mul comes from... =) Makes sense, of course, but I was looking at my code saying "there's no multiplication!".
I've submitted the issue. On Wednesday, September 19, 2012 7:02:11 PM UTC-7, Aaron Meurer wrote: > > Ah, that is a bug. You should report that at > http://code.google.com/p/sympy/issues/. The reason it happens is that > it tries to do the expansion recursively, but sin(-x) becomes -sin(x). > The fix is not too hard either, if you want to give it a shot. > > The work around is to do the expansion with +y and then do > expr.subs(y, -y) at the end. > > By the way, x - y and x + -y are exactly the same thing in SymPy. > Both are represented internally as Add(x, Mul(-1, y)). > > Aaron Meurer > > On Wed, Sep 19, 2012 at 7:55 PM, G B <[email protected] <javascript:>> > wrote: > > I'm still new to sympy, so I might be doing something stupid, but I > think > > there's a problem here: > > > > In [1]: from sympy import * > > In [2]: x,y=symbols('x,y') > > In [3]: cos(x+y).expand(trig=True) > > Out[3]: -sin(x)*sin(y) + cos(x)*cos(y) > > > > So far so good. but then: > > In [4]: cos(x-y).expand(trig=True) > > > > Leads to a long traceback that culminates with: AttributeError: 'Mul' > object > > has no attribute '_eval_expand_trig' > > > > For giggles, I also tried: > > In [5]: cos(x + (-y)).expand(trig=True) > > > > Which fails in the same way. I can post the full traceback if it helps. > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "sympy" group. > > To view this discussion on the web visit > > https://groups.google.com/d/msg/sympy/-/-Z8Y7YC_PuEJ. > > To post to this group, send email to [email protected]<javascript:>. > > > To unsubscribe from this group, send email to > > [email protected] <javascript:>. > > For more options, visit this group at > > http://groups.google.com/group/sympy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/CZlR3N-VhIAJ. 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?hl=en.
