<s>[INST] What is $\arctan(x) + \arctan(y)$ I know $$g(x) = \arctan(x)+\arctan(y) = \arctan\left(\frac{x+y}{1-xy}\right)$$
which follows from the formula for $\tan(x+y)$. But my question is that my book defines it to be domain specific, by which I mean, has different definitions for different domains:
$$g(x) = \begin{cases}\arctan\left(\dfrac{x+y}{1-xy}\right), &xy < 1 \\[1.5ex] 
\pi + \arctan\left(\dfrac{x+y}{1-xy}\right), &x>0,\; y>0,\; xy>1 \\[1.5ex] 
-\pi + \arctan\left(\dfrac{x+y}{1-xy}\right), &x<0,\; y<0,\; xy > 1\end{cases}$$
Furthermore, When I plot the function $2\arctan(x)$, it turns out that the book definition is correct. I don't understand how such peculier definition emerges. Thank you. 
 [/INST] The fact, that $\tan x = \theta$ only implies $x = \arctan \theta  + k \pi$,  makes the fomular of $g(x)$ a little complicated.
First proof.
There are many good answers pointed by KonKan. The following one is based on the Lagrange mean value theorem. It is not the shortest proof, but the idea is easy.
Denote
$$F(y) = \arctan x + \arctan y - \arctan \frac{x+y}{1-xy}.$$
We find that $F'(y) = 0$.
It is easily to see that
$$
\arctan x + \arctan \frac{1}{x} = \begin{cases} \frac{\pi}{2}, \quad x>0, \\
-\frac{\pi}{2}, \quad x<0, \end{cases}
$$
and
$$
\arctan z = -\arctan (-z),\quad \lim_{z\to -\infty}\arctan z = -\frac{\pi}{2}, \quad  \lim_{z\to +\infty}\arctan z = \frac{\pi}{2}.
$$
We divide the problem to three cases.
Case 1. $x = 0$. We have $F(y)\equiv 0$.
Case 2. $x > 0$. The domain of $F(y)$ is $(-\infty, \frac 1 x)  \cup (\frac 1 x, +\infty)$. Since $F'(y) = 0$, we have
$$
F(y) \equiv
\begin{cases} \lim\limits_{z\to -\infty}F(z) = \arctan x - \frac \pi 2 + \arctan \frac 1 x = 0, \quad xy<1,\\
\lim\limits_{z\to +\infty}F(z) = \arctan x + \frac \pi 2 + \arctan \frac 1 x = \pi, \quad xy > 1.
\end{cases}
$$
Case 3. $x < 0$. The domain of $F(y)$ is $(-\infty, \frac 1 x)  \cup (\frac 1 x, +\infty)$. Since $F'(y) = 0$, we have
$$
F(y) \equiv
\begin{cases} \lim\limits_{z\to -\infty}F(z) = \arctan x - \frac \pi 2 + \arctan \frac 1 x  = -\pi, \quad xy>1,\\
\lim\limits_{z\to +\infty}F(z) = \arctan x +\frac \pi 2 + \arctan \frac 1 x = 0,   \quad xy < 1.
\end{cases}
$$
Summarize above cases, we get the formular $g(x)$ in the problem.
Second proof.
Denote
$$F(x,y) = \arctan x + \arctan y - \arctan \frac{x+y}{1-xy}.$$
Noticing that the function $xy=1$ separates the $x-y$ plane into three connected domains
$$E_1 =\{(x,y)\mid x,y >0, xy > 1\},$$
$$E_2 = \{(x,y)\mid x,y <0, xy > 1\},$$
$$E_3= \{(x,y)\mid xy < 1\},$$ and $F_x(x,y) = F_y(x,y) =0$, we find that $F$ is constant in each $E_i (i=1,2,3)$.
Thus
$$
F(x,y)=\begin{cases}
F(\sqrt 3,\sqrt 3) = \pi, \quad &(x,y)\in E_1,\\
F(-\sqrt 3,-\sqrt 3) = -\pi, &(x,y)\in E_2,\\
F(0,0)=0, & (x,y) \in E_3.
\end{cases}
$$
</s>