I am going to "prove" that $\cos\left(\frac{2\pi}{n}\right) = 1$ for all $n \geq 1.$ While this is definitely not true, I have a chain of arguments that seemingly shows exactly that. Please help me understand where the error creeped in.
Here we go. We start with recalling a number of identities involving the complex exponential function. First, recall that $$e^{ix} = \cos{x} + i\sin{x}.$$ By trigonometry, it follows that $$e^{-ix} = \cos(-x) + i\sin(-x)= \cos{x} - i\sin{x}.$$ By these two identities, we have $$\cos{x} = \frac{e^{ix} + e^{-ix}}{2}.\tag{1}$$
Next, recall Euler's identity: $$e^{i\pi} = -1.$$
Squaring both sides, we obtain $$e^{2i\pi} = 1.\tag{2}$$
And now to the meat of the "argument". Letting $x = \frac{2\pi}{n}$ in (1), we get \begin{align} \large \cos\left(\frac{2\pi}{n}\right) &= \large \frac{e^{i\frac{2\pi}{n}} + e^{-i\frac{2\pi}{n}}}{2} \\ &= \large \frac{(e^{2 \pi i})^\frac1n + (e^{2 \pi i})^{-\frac1n}}{2} \\ & = \large \frac{1^\frac1n + 1^{-\frac1n}}{2} = \large \frac{1 + 1}{2} = 1. \end{align}
My guess is that I messed up the factoring of the exponents in step 2 of the above, but it's not clear to me why what I did is not allowed.
The error lies in the equality$$e^{i\frac{2\pi}n}=\left(e^{2\pi i}\right)^{\frac1n}.$$The LHS is a concrete complex number, whereas the RHS could be any $n$th-root of $e^{2\pi i}$.
In general, the equality$$e^{ab}=(e^a)^b$$is meaningless.