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]> 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]. > 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. -- You received this message because you are subscribed to the Google Groups "sympy" 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?hl=en.
