Calculating $Arg(x+iy)-Arctg(\frac{y}{x})$ I was given the following question:

Denote $Arg(z)$ as the Principal branch of $arg(z)$ that have values
  in $(-\pi,\pi]$, 
Denote $Arctg(x)$ as the Principal branch of $arctg(x)$ that have
  values in $(-\frac{\pi}{2},\frac{\pi}{2})$
Calculate $Arg(x+iy)-Arctg(\frac{y}{x})$ where $x,y\in\mathbb{R}$ and
  $x\neq0$.

I need some help with this question, there are some things that are unclear to me:
1) What does it mean that $Arctg(x)$ as the Principal branch of $arctg(x)$
that have values in $(-\frac{\pi}{2},\frac{\pi}{2})$ ? its $tg(x)$
that (if we restrict its domain) have values in $(-\frac{\pi}{2},\frac{\pi}{2})$
and not $arctg(x)$
2) I thought that if $z=x+yi$ then $z=|z|e^{iarctg(\frac{y}{x})}$ ,
so I thought that the answer should be $0$, but was being told I
am wrong.
Can someone please help and explain what does $Arg(x+iy)$ mean compared
to $Arctg(\frac{y}{x})$ and how to calculate both of them ?
note that in class the lecture did not formally define $Arg(...)$
, he only said that we want $\theta$ in the representation $re^{i\theta}$
to be unique so we choose some range for $\theta$ so we will not
have $\theta,\theta+2\pi k$ as options where $0\neq k\in\mathbb{Z}$
 A: The function $\arctan$ is defined on ${\mathbb R}$. For a given $t\in{\mathbb R}$ it gives the unique angle $\alpha\in\ \bigl]{-{\pi\over2}},{\pi\over2}\bigr[\ $ such that $t=\tan\alpha$. It follows that $\arctan{y\over x}$ is defined whenever $x\ne0$. But note that $\arctan{-y\over -x}=\arctan{y\over x}$. The domain of the function $(x,y)\mapsto\arctan{y\over x}$ is painted green in the following figure.
The function ${\rm Arg}$ is defined on the slit plane  $C':={\mathbb C}\setminus\{z| z\leq0\}$, painted amber in the following figure. For a given $z\in C'$ it gives the unique angle $\phi\in\ ]{-\pi},\pi[\ $ such that $z=|z| e^{i\phi}=|z|(\cos\phi+ i\sin\phi)$.
When $z=x+iy$ and $x\ne0$  then ${y\over x}={\sin\phi\over\cos\phi}=\tan\phi$. Therefore $\arctan{y\over x}=\phi- k\pi$ for a $k\in{\mathbb Z}$, or
$${\rm Arg}(x+iy)-\arctan{y\over x}= k\pi\ .$$
It remains to determine the ominous $k$, which may depend on $x$ and $y$. Looking at the figure below we see that
$${\rm Arg}(x+iy)-\arctan{y\over x}=\cases{-\pi &$(x<0,\ y<0)$ \cr
0&$(x>0)$\cr \pi&$(x<0,\ y>0)$\cr}\quad.$$

A: A principal branch is a function which selects one branch, or "slice", of a multi-valued function. 
$\text {arg}(z=a+ib)= \{\varphi_i  \ | \ \cos \varphi_i=a/|z| \ , \ \sin \varphi_i =b/|z| \ \}$, since $z=|z| \cdot (\cos \varphi + i \cdot \sin \varphi)$ this is why even though $\text {arctg}(x)$ is $\pi-$periodic.

$$\text {arg}(z) = \{\varphi + 2k\pi, \ k\in \mathbb Z, \ \varphi = \text {arctg}(b/a)\in ]-\pi, \ \pi]\ \}$$

But $\text {arctg}(x)$ on the other hand is simply 

$$\text {arctg}(x)=\{\varphi + k\pi, \ k\in \mathbb Z, \ \varphi \in ]-\pi, \ \pi]\ \}$$

Both $\text {arg}(z)$ and $\text {arctg}(x)$ have many possible values but according to your question, by using the function (notation) $\text {Arg}(z)$ and $\text {Arctg}(x)$ (note the capitalized $\text A$), we are only interested in values in the given range i.e.

$$\text {Arg}(z)=\text {arg}(z) \ \bigcap \ ]−π,\ π]$$
  $$\quad \quad \ \ \ \ \ \text {Arctg}(x)=\text {arctg}(x)\  \bigcap \ ]− π/2,\ π/2[$$

The complex logarithm is a perfect example of a multi-valued function. Given $z=a+ib$ the $\mathrm{log}(z)= w\ |\ e^w=z$ and since $z=\sqrt{a^2+b^2}\cdot e^{\ i\cdot(\mathrm {arctg}(b/a) + 2\pi k)}$ where $k$ is any integer, then $\mathrm{log}(z)= \ln(\sqrt{a^2+b^2}) + i\cdot(\mathrm {arctg} (b/a) + 2\pi k)$. This gives a sequence of different values for just one value of $z\ne 0$. 
The notation $\mathrm{Log}(z)$ (note the start with a capital $\text L$) is mostly used to denote the principal value of  $\mathrm{log}(z)$. For a complex number $z\ne 0$, the principal value $\text {Log} (z)$ is the logarithm whose imaginary part lies in the interval $]−π,π]$.
Back to your question. Given $z=x+iy\ne 0$, then $\text {arg}(z)$ and $\text {arctg}(y/x)$ both take the sequence of values I gave above  but by using $\text {Arg}(z)$ and $\text {Arctg}(y/x)$ they are defined in the given intervals.
If $\text {Arctg}(y/x) = \theta \in ]−π/2,\ π/2[$, then $\text { arctg}(y/x) =\{\theta + k\pi , \ \forall k\in \mathbb Z\}$
Since $]−π/2,\ π/2] \subset ]−π,\ π]$  let's consider the following cases for $\text{Arctg(y/x)}$ where 

  
*
  
*$  ]-\pi/2, \ 0[\quad \Rightarrow \quad -1 < \sin \theta<0, \ \ 0<\cos \theta<1, \text { possibly $x>0$, $y<0$ and $y/x \le0$} $
  
*$ [0, \ \pi/2[\quad \Rightarrow\quad 0 \le \sin \theta<1, \ \ 0<\cos \theta\le 1, \text { possibly $x>0$, $y\ge0$ and  $y/x \ge0$} $
  

If we divide the interval $ ]−π,\ π]$ into four for cases of $\text{Arg(z)}$

  
*
  
*$]−π,\ -π/2]$ $\quad \Rightarrow\quad $ $-1\le\sin \theta < 0$, $-1<\cos \theta \le 0$ and $y/x \ge 0$
  
*$]−π/2,\ 0]$ $\quad \Rightarrow\quad $  $-1<\sin \theta \le 0$, $0< \cos \theta \le 1$  and $y/x \le 0$
  
*$]0,\ π/2]$ $\quad \Rightarrow\quad $  $0<\sin \theta \le 1$, $0\le \cos \theta < 1$  and $y/x \ge 0$
  
*$]π/2,\ π]$ $\quad \Rightarrow\quad $  $0\le\sin \theta < 1$, $-1\le \cos \theta < 0$  and $y/x \le 0$
  



*

*If $x\le 0$ and $y< 0$ then  $\text{Arg(z)} = \theta \in ]-\pi, \ -\pi/2]$ then $\text{Arctg}(y/x) = \theta+\pi \in ]0, \ \pi/2[$ and we have $\text{Arg}(z)-\text{Arctg}(y/x) = -\pi$

*If $x >0$ and $y\le 0$ then  $\text{Arg(z)} = \theta \in ]-\pi/2, \ 0]$ then $\text{Arctg}(y/x) = \theta \in ]-\pi/2, \ 0[$ and we have $\text{Arg}(z)-\text{Arctg}(y/x) = 0$

*If $x\ge 0$ and $y> 0$ then  $\text{Arg(z)} = \theta \in ]0,\ π/2]$ then $\text{Arctg}(y/x) = \theta \in ]0,\ π/2]$ and we have $\text{Arg}(z)-\text{Arctg}(y/x) = 0$

*If $x< 0$ and $y\ge 0$ then  $\text{Arg(z)} = \theta \in ]\pi/2, \ π]$ then $\text{Arctg}(y/x) = \theta-\pi \in ]-\pi/2, \ 0[$ and we have $\text{Arg}(z)-\text{Arctg}(y/x) = \pi$


P.S. The most important thing to know is that $\text {arctg}(y/x)$ only cares about the sign of $y/x$ but $\text {arg}(z)$ cares about the sign of both $x$, $y$ and $x/y$.
