I haven't run any tests on this except for my code where I found the problem.
def _eval_expand_trig(self, **hints):
from sympy import expand_mul
arg = self.args[0]
x = None
if arg.is_Add: # TODO, implement more if deep stuff here
# TODO: Do this more efficiently for more than two terms
x, y = arg.as_two_terms()
#GCB 120920 added ",evaluate=False" to the next 4 lines
sx = sin(x,evaluate=False)._eval_expand_trig()
sy = sin(y,evaluate=False)._eval_expand_trig()
cx = cos(x,evaluate=False)._eval_expand_trig()
cy = cos(y,evaluate=False)._eval_expand_trig()
return sx*cy + sy*cx
else:
n, x = arg.as_coeff_Mul(rational=True)
if n.is_Integer: # n will be positive because of .eval
# canonicalization
if n.is_odd:
return (-1)**((n - 1)/2)*C.chebyshevt(n, sin(x))
else:
return expand_mul((-1)**(n/2 - 1)*cos(x)*C.chebyshevu(n -
1, sin(x)), deep=False)
return sin(arg)