On exponent rule and complex numbers Consider the following integral:
$$
\frac{1}{a}\int_0^ae^{i\frac {2\pi n }{a}x } \cos\left(\frac{2\pi}{a}x\right)dx 
$$
with $a \in \mathbb R$ and $n \in \mathbb{Z}$.
My professor solved it by expressing the function $\cos$ in terms of complex exponentials and so on.
I thought it was faster to apply the exponent rule:
$$
u^{vw} = (u^v)^w
$$
In this way, $\ \displaystyle e^{i\frac {2\pi n }{a}x }=\left(e^{i 2\pi} \right)^{\frac {n}{a} x} = 1 \quad \forall\,x,n,a\neq0 \ $ and the integral vanishes.
But this is not true. That means evidently this rule can't be applied to complex numbers. Indeed, it can be done only with integer exponents, and yet, there are many examples of formulae which remain valid even if one tries to extend their limits of applicability.
So why doesn't it work in this case?
 A: Exponent and logarithm rules doesn’t work, in general, in the complex numbers. You have to think about what $(u^v)^w$ actually means. You find quickly that the only way (which can be implemented in the complex plane) is $u^v:=\exp(v\log u)$. But this introduces new problems, since $\log u$ is not uniquely defined, or continuous. It jumps every time you make a turn around the unit circle, leading to different branches. It then makes sense to talk about different branches of $a^x$, in particular you could say $1^i=1$ (principal branch), $1^i=-2\pi$ (branch with $\log1=2\pi i$), $1^i=2\pi$ (branch with $\log1=-2\pi i$) and so on...
This completely screws with most exponent and logarithm rules
The only one that comes to mind which is safe is the rule: $\exp(a+b)=\exp(a)\exp(b)$, since this can be proven via the power series (or other means). But this doesn’t mean that $z^az^b=z^{a+b}$, mind, since $z^{x}$ is ambiguous.
A classic (and much duplicated) example of this is the following fallacy:

$$\begin{align}1&=\sqrt{1}\\&=\sqrt{(-1)(-1)}\\&\color{red}{\overset{?}{=}}\sqrt{-1}\cdot\sqrt{-1}\\&=i\cdot i\\&=-1\end{align}$$

This makes three assumptions, which combined make an error. Assumption number one is that $1=\sqrt{1}$ is unambiguous: $-1=\sqrt{1}$ is also a valid statement. Assumption number two, highlighted red, is the fallacy that $\sqrt{ab}=\sqrt{a}\sqrt{b}$ holds for a fixed branch of the square root. Assumption three is that $\sqrt{-1}=i$ is unambiguous: $\sqrt{-1}=-i$ also holds, for a different branch. Carefully managing branches reveals no contradiction, but naively asserting the principal branches for all cases whilst presuming $\sqrt{ab}=\sqrt{a}\sqrt{b}$ causes problems.
