Log of a negative number

$e^{πi} + 1 = 0$.

$e^{πi} = -1$.

$πi = \log(-1)$.

$\log(-1) + \log(|a|) = \log(-|a|)$.

$\log(-|a|) = \log(|a|)+iπ$.


The standard explanation would go like this:

Any complex number $z$ can be written in polar form: $$z = |z|e^{i\theta}.$$ So, if we want to define the complex logarithm, we do so as follows: $$\log (z) = \log(|z|e^{i\theta}) = \log(|z|) + \log(e^{i\theta}) = \log(|z|) + i\theta.$$ In particular, the logarithm of a negative real number $x$ can then be calculated as $$\log (x) = \log(|x|e^{i\pi}) = \log(|x|) + \log(e^{i\pi}) = \log(|x|) + i\pi.$$

However, this explanation is not sufficient and the logarithm as presented is NOT a well-defined function. The angle $\theta$ is, well, an angle, and hence only defined up to multiples of $2\pi$: $$|z|e^{i\theta} = |z|e^{i(\theta+k2\pi)}$$ for all $k \in \mathbb{Z}$. Therefore, the complex logarithm is only defined up to multiples of $2\pi i$ !

For example: $$\log (x) = \log(|x|e^{i\frac{3}{2}\pi}) = \log(|x|) + \log(e^{i\frac{3}{2}\pi}) = \log(|x|) + i\frac{3}{2}\pi,$$ or maybe $$\log (x) = \log(|x|e^{-i\frac{177}{2}\pi}) = \log(|x|) + \log(e^{-i\frac{177}{2}\pi}) = \log(|x|) - i\frac{177}{2}\pi.$$ But clearly $\pi \neq \frac{3}{2}\pi \neq -\frac{177}{2}\pi$. The point is: the complex logarithm is not a function, but what we call a multivalued function. To turn it into a proper function, we must restrict what $\theta$ is allowed to be, for example $\theta \in (-\pi,\pi]$. This is called the principal complex logarithm and is usually denoted by $\operatorname{Log}$ (capital L).

Technically, it doesn't matter to what range you restrict $\theta$, as long as the resulting logarithm is a proper function (not a multivalued function) and you are consistent in your restriction of $\theta$. For example, the following "proof" can be obtained if you're sloppy: \begin{align} e^{\pi i} = -1 & \implies (e^{\pi i})^2 = (-1)^2 & \text{ (square both sides)}\\ & \implies e^{2\pi i} = 1 & \text{ (calculate the squares)}\\ & \implies \log (e^{2\pi i}) = \log(1) & \text{ (take the logarithm)}\\ & \implies 2\pi i = 0 & \text{ (calculate the logarithms)} \end{align} Clearly this is wrong!