How to figure out the Argument of complex number?
Solution 1:
You should know that any complex number can be represented as a point in the Cartesian ($x$-$y$) plane. That is to say that a complex number $z=a+b\text i$ is associated with some point (say $A$) having co-ordinates $(a,b)$ in the Cartesian plane.
You might have heard this as the Argand Diagram.
Let $\tan \theta$ be the direction ratio of the vector $\vec{OA}$ (Assume the line joining the origin, $O$ and point $A$ to be a vector)
Then, $$\tan\theta =\frac ba \implies \theta= \arctan \Big (\frac ba\Big )$$
However, we can't go about claiming $\theta$ to be $\operatorname {Arg}(z)$ just yet. There is a small detail that we need to keep in mind (Thank you to a user for pointing that out!). We need to watch out for the quadrant on which our complex number lies and work accordingly.
Example Say there are 2 complex numbers $z=a+b\text i$ and $w=-a-b\text i$. Then, $$\operatorname{Arg}(w)=\arctan\Big( \frac {-b}{-a} \Big )= \arctan\Big( \frac {b}{a} \Big )= \operatorname{Arg}(z)$$
which is just preposterous. It suggests that $w$, which lies on the third quadrant on the Argand Diagram, has the same argument as a complex number ($z$) which in the first quadrant. To correct this issue, we'll have to put forth some simple conditions. As we just saw, one of them could go something like: $\text{ if } a,b<0 \text{ then } \operatorname{Arg}(z)=\theta -\pi$
Here is a list of conditions for computing the Argument (This has already been mentioned in one of the answers above and I am just re-posting it here). Once you get a intuitive feel for this, it should come to you naturally.
$\varphi = \arg(z) =
\begin{cases}
\theta & \mbox{if } x > 0 \\
\theta + \pi & \mbox{if } x < 0 \mbox{ and } y \ge 0\\
\theta - \pi & \mbox{if } x < 0 \mbox{ and } y < 0\\
\frac{\pi}{2} & \mbox{if } x = 0 \mbox{ and } y > 0\\
-\frac{\pi}{2} & \mbox{if } x = 0 \mbox{ and } y < 0\\
\mbox{indeterminate } & \mbox{if } x = 0 \mbox{ and } y = 0.
\end{cases}$
Alternatively, you can use the fact that $|z| \sin \theta= b$ (or, $|z| \cos \theta= a$) and then solve for $\theta$. However, you might still have to make last minute amendments (like we did earlier) to come up with the correct answer. So this is not the shorter of the two methods.
Solution 2:
Note that the "answer" $arctan(y/x)$ is just wrong. To see it check out the example $-1-i$: $\arctan(-1/-1) = 45°$ but correct would be $225°$. And this is not just a problem with the definition of the range of the argument.
The correct answer is given by Wikipedia:
$\varphi = \arg(z) = \begin{cases} \arctan(\frac{y}{x}) & \mbox{if } x > 0 \\ \arctan(\frac{y}{x}) + \pi & \mbox{if } x < 0 \mbox{ and } y \ge 0\\ \arctan(\frac{y}{x}) - \pi & \mbox{if } x < 0 \mbox{ and } y < 0\\ \frac{\pi}{2} & \mbox{if } x = 0 \mbox{ and } y > 0\\ -\frac{\pi}{2} & \mbox{if } x = 0 \mbox{ and } y < 0\\ \mbox{indeterminate } & \mbox{if } x = 0 \mbox{ and } y = 0. \end{cases}$
Because of that many programming languages have the function $\operatorname{atan2}(y,x)$ which gives the above correct argument for $x+iy$.