I tend to forget some of the trigonometric functions and someone showed me how to derive the double angle identities from what I think is Euler's formula:

$\displaystyle e^{ix} = \cos x + i\sin x$

=

$\displaystyle e^{i2x} = \cos 2x + i\sin 2x$

=

$\displaystyle (e^{ix})^{2} = (\cos x + i\sin x)^{2}$

I have a question about this step...I understand how the '2' from the e^(i2x) was pulled out, but is it okay to pull the '2' out from the '2x' of the trigonometric functions and to square the right hand expression? How does that work?