How does $\arctan(0)$ equal $\pi?$
Solution 1:
This is a common error among new people into the complex numbers. The argument of a complex number $z = a + ib$ is not $\arctan (b/a).$ It is given by $$\arg z = \begin{cases} \arctan (b/a) &\mbox{if } a>0 &\\ \arctan (b/a)+\pi &\mbox{if } a<0,b\geq 0 \\ \arctan (b/a)-\pi &\mbox{if } a<0,b< 0 \\ \pi/2 &\mbox{if } a=0,b> 0 \\ -\pi/2 &\mbox{if } a=0,b< 0 \\ \mathrm{undefined} &\mbox{if } a=0,b= 0 \\ \end{cases} $$
Solution 2:
It is an oversimplification to say the argument of $x+iy$ is given by $\theta =\arctan \dfrac yx$. Actually you have to solve the system \begin{cases}\cos\theta=\dfrac x{\sqrt{x^2+y^2}}\\ \sin\theta=\dfrac y{\sqrt{x^2+y^2}}\end{cases} which implies $\tan\theta=\dfrac yx$, but is not equivalent to $\theta=\arctan\dfrac yx$.
The general solution is $\theta\equiv\arctan\dfrac yx\mod \pi$, and you have to choose the value of $\theta$ (mod $2\pi$) in function of the signs of $\cos\theta$ and $\sin\theta$, i.e. of $x$ and $y$.