TITLE: How to get principal argument of complex number from complex plane?
QUESTION [17 upvotes]: I am just starting to learn calculus and the concepts of radians. Something that is confusing me is how my textbook is getting the principal argument ($\arg z$) from the complex plane. i.e. for the complex number $-2 + 2i$, how does it get $\frac{3\pi}{4}$? (I get $\frac{\pi}{4}$).  
The formula is $\tan^{-1}(\frac{b}{a})$, and I am getting $\frac{\pi}{4}$ when I calculate $\tan^{-1}(\frac{2}{-2})$. When I draw it I see that the point is in quadrant 2.
So how do you compute the correct value of the principal argument?

REPLY [3 votes]: I've come up with this recipe for principal argument. It saves messing around adding or subtracting $\pi$.
$$\text{Arg} (z) = n\ \text{cos}^{-1} \left(\frac{x}{z}\right)$$
in which n = 1 if y ≥ 0 but n = -1 if y < 0.
I've tried to 'automate' the value of n, but the best I can do is
$$\text{Arg} (z) = \frac{y}{|y|}\ \text{cos}^{-1} \left(\frac{x}{z}\right).$$
Unfortunately this fails for y = 0 (real z), so the y = 0 case would still have to be catered for separately.
Edit: A very ugly self-contained recipe would be
$$\text{Arg} (z) = \text{sgn}\left(\text{sgn}(y) + \frac{1}{2}\right)\ \text{cos}^{-1} \left(\frac{x}{z}\right).$$