Apparently I have an understanding issue regarding the topic in the title.
Let's convert a complex number $z=re^{i\varphi}=a+ib$ from cartesian into polar form. Obviously $r^2=a^2+b^2$. But for the angle $\varphi$ I have to consider 4 cases:
- $a>0,b>0$ (1st quadrant): Then we simply have $\cos\varphi=a/r$, so $\varphi=\arccos(a/r)$.
- $a<0,b>0$ (2nd quadrant): Then we have $\cos(\pi-\varphi)=a/r$, so $-\cos\varphi=a/r$ and therefore $\varphi=\arccos(-a/r)$.
- $a<0,b<0$ (3rd quadrant): Then we have $\cos(\varphi-\pi)=a/r$, so $-\cos\varphi=a/r$ and therefore $\varphi=\arccos(-a/r)$.
- $a>0,b<0$ (4th quadrant): Then we have $\cos(2\pi-\varphi)=a/r$, so $\cos(\varphi)=a/r$ and therefore $\varphi=\arccos(a/r)$.
In total I obtain $$\varphi=\begin{cases}\arccos(a/r) & ,a\geq 0\\ \arccos(-a/r) &,a<0\end{cases}$$
If I look up the "formula" in wikipedia however it says $$\varphi=\begin{cases}\arccos(a/r) & ,b\geq 0\\ -\arccos(a/r) &,b<0\end{cases}$$
Where is my error?
However obvious, point is that $\,r(\cos \varphi + i \sin \varphi)=a+ib \implies r \cos \varphi = a\,$ and $\,r \sin \varphi = b\,$. The following will assume $\,r \ne 0\,$, in which case $\,\cos \varphi = a/r\,$ and $\,\sin \varphi = b/r\,$.
No, because that gives $\,\cos \varphi = - \cos(\pi - \varphi) = -a/r \color{red}{\ne} a/r\,$. Remember that $\,\cos \varphi = a/r\,$ regardless of quadrant.
Instead, $\,\cos \varphi = a/r \implies \varphi = 2k\pi \pm \arccos(a/r)\,$ for some integer $\,k \in\mathbb{Z}\,$. With the usual conventions that $\,\arccos\,$ takes values in $\,[0,\pi]\,$ and the complex $\,\arg\,$ is in $\,(-\pi,\pi]\,$, this means $\,k=0\,$, and so $\,\varphi = \pm \arccos(a/r)\,$.
The choice of signs depends on the quadrant. In the first and second quadrants $\,\sin \varphi = b/r\,$ is positive, so $\,\varphi = +\arccos(a/r)\,$ when $\,b \ge 0\,$. In the third and fourth quadrants $\,\sin \varphi = b/r\,$ is negative so $\,\varphi = -\arccos(a/r)\,$ when $\,b \lt 0\,$, which is precisely what the wikipedia page says.