Equation seems to violate transitive property

37 Views Asked by At

I have some function, $f(x)=\sin(mx)\cos(nx)$. I've tried rewriting this using Euler's formula.

$$ \begin{aligned} f(x) &= \sin mx \cos nx \\ &= \frac{e^{imx} - e^{-imx}}{2i} \times \frac{e^{inx} + e^{-inx}}{2} \\ &= \frac{1}{4i} \left[\left( e^{imx} - e^{-imx} \right) \times \left( e^{inx} + e^{-inx} \right)\right] \\ &= \frac{1}{4 i} \left(e^{ix(m+n)} + e^{ix(m-n)} - e^{ix(n-m)} - e^{-ix(m+n)}\right) \end{aligned} $$

However, something seems to be wrong in that last step. When I check the equalities with sagemath:

x=var('x')
m=var('m')
n=var('n')
f(x)=sin(m*x)*cos(n*x)
g(x)=((exp(I*m*x)-exp(-I*m*x))*(exp(I*n*x)+exp(-I*n*x)))/(4*I)
h(x)=(exp(I*x*(m+n))+exp(I*x*(m-n))-exp(I*x*(n-m))-exp(-I*x*(m+n)))/(4*I)
bool(f(x)==g(x))
bool(g(x)==h(x))
bool(f(x)==h(x))

I get the result:

True
True
False

In other words, it's telling me that $$ \sin mx \cos nx = \frac{1}{4i} \left[\left( e^{imx} - e^{-imx} \right) \times \left( e^{inx} + e^{-inx} \right)\right] $$ and $$ \frac{1}{4i} \left[\left( e^{imx} - e^{-imx} \right) \times \left( e^{inx} + e^{-inx} \right)\right] = \frac{1}{4 i} \left(e^{ix(m+n)} + e^{ix(m-n)} - e^{ix(n-m)} - e^{-ix(m+n)}\right) $$ but $$ \sin mx \cos nx \neq \frac{1}{4 i} \left(e^{ix(m+n)} + e^{ix(m-n)} - e^{ix(n-m)} - e^{-ix(m+n)}\right) $$ How is this possible? Did I make some error in the last step? Does sage have any introspection capabilities to elucidate why this is the case?