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}}$$
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.