I have a problem when simplifying a symbolic expression in sympy when having a trigonometric function and a complex exponent, namely I just assumed a different definition of tan function, and I have a weird thing going on. So I do:
# Deleting variables
from IPython import get_ipython;
get_ipython().magic('reset -sf')
import sympy as sym;
# defining variables
test1 = sym.Symbol('test');
test2 = sym.Symbol('test2');
a = sym.Symbol('a');
# Defining tests
test1 = sym.tan(a) + sym.I*(sym.exp(sym.I*a)-sym.exp(-sym.I*a))/(sym.exp(sym.I*a)+sym.exp(-sym.I*a));
test2 = sym.I*(sym.exp(sym.I*a)-sym.exp(-sym.I*a))/(sym.exp(sym.I*a)+sym.exp(-sym.I*a));
Symbolic variable sym.simplify(test2) is equal to -tan(a) and normaly test1 variable should be equal to 0, however when I simplify a test1 variable, I do get:
sym.simplify(test1)
Out[140]:
(-I*(1 - exp(2*I*a)) + (exp(2*I*a) + 1)*tan(a))/(exp(2*I*a) + 1)
So the question is what do I get wrong, how to tell Python to simplify a text1 expression in order to get 0 which it naturally should be
Rewriting in terms of exp
then simplifying gives 0
test1.rewrite(sym.exp).simplify()