Why does this expansion of cosine work? $\cos(\theta) = \frac{e^{i\theta}}{2} + \frac{|e^{i\theta}|^2}{2e^{i\theta}}$ My friend showed me this expansion for cosine. I know it has something to do with Euler's identity $e^{i\pi}+1 = 0$ but I can't quite figure out how they worked this out.
$$\cos(\theta) = \frac{e^{i\theta}}{2} + \frac{|e^{i\theta}|^2}{2e^{i\theta}}$$
 A: $|e^{i\theta}|$ for real $\theta$ is 1, since $e^{i\theta}$ is the polar representation of a unit vector. Thus the expression is equivalent to
$$\frac{e^{i\theta}}2+\frac1{2e^{i\theta}}$$
Bring $e^{i\theta}$ to the top of the second fraction and collect denominators:
$$=\frac{e^{i\theta}+e^{-i\theta}}2$$
Use Euler's formula* $e^{ix}=\cos x+i\sin x$ and the symmetry $\cos(-x)=\cos x$:
$$=\frac{\cos\theta+i\sin\theta+\cos\theta-i\sin\theta}2=\cos\theta$$
*Euler's identity is the special case of the formula when $x=\pi$
A: What I couldn't understand is why your friend left $|e^{i\theta}|^2$ in there, rather than just simplifying it to $1$. Then after thinking it over, I believe I figured it out. 
First we need to identify some properties of complex numbers before we jump into it.
We know that $\bar{z} = \frac{|z|^2}{z}$
We also know that $\frac{z + \bar{z}}{2}$ gives you the real part of a complex number.
Finally, we know that $e^{i\theta} = \cos(\theta) + i\sin(\theta)$
We combine the first two properties to create a function the separates out the real part, we can name that $R(x)$.
$$R(x) = \frac{x+\frac{|x|^2}{x}}{2}$$
Or, something you might recognize,
$$R(x) = \frac{x}{2}+\frac{|x|^2}{2x}$$
Now, with the third property, we use this function to separate out $\cos(\theta)$, which just so happens to be the real part of $e^{i\theta}$.
So, 
$$R(e^{i\theta})$$
When "worked out" gives you the equation above for $\cos(\theta)$
The same process can be done to $\sin(\theta)$, with $\frac{z - \bar{z}}{2i}$ to get the imaginary part of the complex number.
This is my first answer, how did I do? I attempted to answer how your friend may have arrived upon it, rather than proving it.
