When should I add $\pi i$ to the exponent when computing the polar form of complex nubmers? This is maybe math $101$ question:
Let $z_1=1+i$.
I know that $r=\sqrt 2$ and $\theta=\arctan(1/1)=\pi/4$ so $$z_1=\color{blue}{\sqrt 2e^{i\pi/4}} .$$
But now if I take a look at
$z_2=-1-i$,
I know that $r=\sqrt 2$ and $\theta=\arctan(-1/-1)=\pi/4$ so $$z_1=\color{blue}{\sqrt 2e^{i\pi/4}}.$$
But $z_2$ should be equal to $$\color{red}{\sqrt 2 e^{5i\pi/4}} .$$
Why in $z_2$ should I add $\pi$ in the power of the exponent?
 A: It is a matter of definition. Usually they define an angle called the principal angle in the interval $[-\pi,\pi)$. But you can choose your interval to be $[0,2\pi)$ too. Then you should look up for the unique angle in those intervals such that
$$\begin{cases}
\cos \theta = \frac{x}{\sqrt{x^2+y^2}} \\
\sin \theta = \frac{y}{\sqrt{x^2+y^2}}
\end{cases}$$
where
$$z=x+iy$$
A: Here's one way to view this: The arctangent function $\arctan m$ returns the unique value $\alpha \in \left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$ such that $\tan \alpha = m$, that is, the signed angle $\alpha$ in that range between the $x$-axis and a line with slope $m$.
Now, we can write any point $z = x + i y \in \Bbb C$ not on the $y$-axis as $\rho e^{i \theta}$ for a unique $r \in \Bbb R$ (not necessarily positive) and $\theta \in \left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$: Here, $\theta$ is the signed angle determined by the slope of the line through $0$ and $z$ and $\rho$ is the signed distance from $0$ to $z$, where we take $r$ positive if $x > 0$ and $r$ negative if $x < 0$. The slope of the line is $\frac{y}{x}$ and so $\theta = \arctan \frac{y}{x}$.
For example, for $z_2 = -1 - i$, we have $\rho = -\sqrt{2}$ (since $x < 0$) and $\theta = \arctan \frac{(-1)}{(-1)} = \frac{\pi}{4}$ and so may write
$$z_2 = -\sqrt{2} e^{i \pi / 4}.$$ On the other hand, for many purposes we prefer to have the radial component positive. We can remember this for our example (and similarly any case where $x < 0$) by writing $-1 = e^{\pi i}$, and substituting gives
$$z_2 = (e^{\pi i}) \sqrt{2} e^{i \pi / 4} = \sqrt{2} e^{5 \pi i / 4}$$ as desired.
We can summarize this as writing $z = x + i y \in \Bbb C$ (with $x \neq 0$) as
$$r = e^{i \theta},$$
where $r = |z|$ and
$$
\color{#bf0000}{\boxed{\theta = \left\{\begin{array}{rl}\arctan \frac{y}{x}, & x > 0\\ \pi + \arctan \frac{y}{x}, & x < 0\end{array}\right.}}
$$
In short, one "must add $\pi$" when $\Re z = x < 0$.
By construction, we have $\theta \in \left(-\frac{\pi}{2}, \frac{3 \pi}{2}\right),$ but notice that, since $e^{2 \pi i k} = 1$ for all $k \in \Bbb Z$, we can write $r e^{i \theta}$ as $r e^{i (\theta + 2 \pi i k)}$ for any $k$, so there are many choices of functions that map complex numbers to corresponding angles. These are call branches of the argument.
See the closely related function atan2() used in many programming languages.
