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. 
 A: Fix, as usual:
$$
-\frac{\pi}{2}<\gamma=\arctan(t)<\frac{\pi}{2}
$$
now we have:
$$
\tan (\gamma)=\tan(\alpha+\beta)=\frac{x+y}{1-xy}=t
$$
and, if $xy>1$  we have the two cases ($x$ and $y$ have the same sign):
$$
x>0, y>0 \rightarrow t<0 \rightarrow \gamma<0\rightarrow \alpha+\beta=\gamma+\pi
$$
$$
x<0, y<0 \rightarrow t>0 \rightarrow \gamma>0\rightarrow \alpha+\beta=\gamma-\pi
$$
A: I can prove that if $|xy|<1$, that 
1) $$-\frac {\pi}{2}<\arctan(x)+\arctan(y)<\frac {\pi}{2}$$
2) $$\arctan(x)+\arctan(y)=\arctan\left(\frac{x+y}{1-xy}\right)$$
A: 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}
$$
A: Here is a straightforward (though long) derivation of the piece wise function description of $\arctan(x)+\arctan(y)$.
We will show that:
$\arctan(x)+\arctan(y)=\begin{cases}-\frac{\pi}{2} \quad &\text{if $xy=1$, $x\lt 0$, and $y \lt 0$} \\\frac{\pi}{2} \quad &\text{if $xy=1$, $x\gt 0$, and $y \gt 0$} \\ \arctan\left(\frac{x+y}{1-xy}\right) \quad &\text{if $xy \lt 1$} \\\arctan\left(\frac{x+y}{1-xy}\right)+\pi \quad &\text{if $xy \gt 1$ and $x \gt 0$, $y \gt 0$}\\ \arctan\left(\frac{x+y}{1-xy}\right)-\pi \quad &\text{if $xy \gt 1$ and $x \lt 0$, $y \lt 0$} \end{cases}$
working from these below statements:

*

*$\arctan$ is strictly increasing and $\arctan(0)=0$


*if $x \gt 0$ then $\arctan(x)+\arctan(\frac{1}{x})= \frac{\pi}{2}$ and if $x \lt 0$ then $\arctan(x)+\arctan(\frac{1}{x})=-\frac{\pi}{2}$


*$\text{dom}(\arctan)=\mathbb R$ and $\text{image}(\arctan)=(-\frac{\pi}{2},\frac{\pi}{2})$

Case 1: $xy=1$
Under these circumstances, you can derive that $x\gt 0$ and $y \gt 0 \implies \arctan(x)+\arctan(y)=\frac{\pi}{2}$. Alternatively, $x \lt 0$ and $y \lt 0 \implies \arctan(x)+\arctan(y)  = -\frac{\pi}{2}$

Case 2: $xy \lt 1$
Under these circumstances, you can derive that $\arctan(x)+\arctan(y) \in (-\frac{\pi}{2},\frac{\pi}{2})$

Case 3: $xy \gt 1$
There are two subcases to consider. Either $x \gt 0$ and $y \gt 0$ OR $x \lt 0$ and $y \lt 0$.
If $x \gt 0$ and $y \gt 0$,  the we argue as follows.
Because $x \gt 0$ and $xy \gt 1$, we necessarily have that $y \gt \frac{1}{x}$. Next, because $x \gt 0$, we must have that $\arctan(x)+\arctan(\frac{1}{x}) = \frac{\pi}{2}$. Given that $\arctan$ is a strictly increasing function, we then have that $\frac{\pi}{2}=\arctan(x)+\arctan(\frac{1}{x}) \lt \arctan(x)+\arctan(y)$. Finally, we know that for any $z \gt 0:\arctan(z) \in (0,\frac{\pi}{2})$.
With the above argument, we conclude that $\arctan(x)+\arctan(y) \in (\frac{\pi}{2}, \pi)$.
A similar argument would lead one to have that if $x \lt 0$ and $y \lt 0$, then  $\arctan(x)+\arctan(y) \in (-\pi,-\frac{\pi}{2})$.

With these three cases established, we can now look at the identity:
$$\tan(\alpha+\beta)=\frac{\tan(\alpha)+\tan(\beta)}{1-\tan(\alpha)\tan(\beta)}$$
Letting $\alpha=\arctan(x)$ and $\beta=\arctan(y)$, we can rewrite the above identity as:
$$\tan(\arctan(x)+\arctan(y))=\frac{\tan(\arctan(x))+\tan(\arctan(y))}{1-\tan(\arctan(x))\tan(\arctan(y))}=\frac{x+y}{1-xy} \quad (\dagger_1)$$
From our previous work, we know that across all values of $x,y \in \mathbb R$, the sum $\arctan(x)+\arctan(y)$ can take on the values:

*

*$-\frac{\pi}{2}$ or $\frac{\pi}{2}$


*$(-\frac{\pi}{2},\frac{\pi}{2})$


*$(-\pi,-\frac{\pi}{2})$ or $(\frac{\pi}{2},\pi)$
Importantly, we know that $\tan$ is a periodic function (with period of $\pi$) defined on $\cdots (-\frac{3\pi}{2},-\frac{\pi}{2}), (-\frac{\pi}{2},\frac{\pi}{2}),(\frac{\pi}{2},\frac{3\pi}{2})\cdots \quad (\dagger_2)$
Further, by definition, $\arctan$ is the inverse function of $\tan$ when $\tan$ is restricted to $(-\frac{\pi}{2},\frac{\pi}{2})$.

With the above work in mind, how do we now precisely determine what $\arctan(x)+\arctan(y)$ equals?

Firstly, we know from Case 1 that if $x \lt 0, y\lt 0,$ and $xy=1$, then $\arctan(x)+\arctan(y)=-\frac{\pi}{2}$. Similarly, if $x \gt 0, y \gt 0,$ and $xy=1$, then $\arctan(x)+\arctan(y)=\frac{\pi}{2}$
Next, we can use the result from Case 2 and $(\dagger_1)$ to conclude that if $xy \lt 1$, then $\arctan(x)+\arctan(y)=\arctan\left(\frac{x+y}{1-xy}\right)$. This is because the argument of $\tan$, in the instance of Case 2, spans from $(-\pi/2,\pi/2)$, which implies that we are dealing with a $\tan$ function whose domain is restricted to $(-\pi/2,\pi/2)$. Therefore, when we take the $\arctan$ of $\tan(z)$, it simply computes to $z$.
So far, then, we have the piecewise function:
$\arctan(x)+\arctan(y)=\begin{cases}-\frac{\pi}{2} \quad &\text{if $xy=1$, $x\lt 0$, and $y \lt 0$} \\\frac{\pi}{2} \quad &\text{if $xy=1$, $x\gt 0$, and $y \gt 0$} \\ \arctan\left(\frac{x+y}{1-xy}\right) \quad &\text{if $xy \lt 1$}\end{cases}$
For the final part (i.e. consider when $xy \gt 1$), suppose $z=\arctan(x)+\arctan(y) \in (-\pi,-\frac{\pi}{2}) \cup (\frac{\pi}{2},\pi)$. Although it is tempting to take the $\arctan$ of both sides in $(\dagger_1)$, we must remember that $\arctan$ is only the inverse function of $\tan$ restricted to $(-\frac{\pi}{2},\frac{\pi}{2})$. It is therefore invalid to claim that $\arctan\circ \tan(z)=z$. However, what IS valid is to employ the fact that $\tan$ is periodic as identified in $(\dagger_2)$. Therefore, suppose $z \in (-\pi,-\frac{\pi}{2})$, which corresponds to $x \lt 0$ and $y \lt 0$. We know that $\tan(z)=\tan(z+\pi)$, where $z+\pi \in (0,\frac{\pi}{2})$. Returning to $(\dagger_1)$, let us then write:
$$\tan(z+\pi)=\tan(z)=\frac{x+y}{1-xy}$$
We can then apply $\arctan$ to $\tan(z+\pi)$ which yields:
$$z+\pi=\arctan\left(\frac{x+y}{1-xy}\right) \implies \arctan(x)+\arctan(y)=\arctan\left(\frac{x+y}{1-xy}\right)-\pi$$
If $z \in (\frac{\pi}{2},\pi)$, which corresponds to $x \gt 0$ and $y \gt 0$ , a similar result applied to $z-\pi$ will yield:
$$z-\pi=\arctan\left(\frac{x+y}{1-xy}\right) \implies \arctan(x)+\arctan(y)=\arctan\left(\frac{x+y}{1-xy}\right)+\pi$$
With this we can completely fill in our piecewise function as follows:
$\arctan(x)+\arctan(y)=\begin{cases}-\frac{\pi}{2} \quad &\text{if $xy=1$, $x\lt 0$, and $y \lt 0$} \\\frac{\pi}{2} \quad &\text{if $xy=1$, $x\gt 0$, and $y \gt 0$} \\ \arctan\left(\frac{x+y}{1-xy}\right) \quad &\text{if $xy \lt 1$} \\\arctan\left(\frac{x+y}{1-xy}\right)+\pi \quad &\text{if $xy \gt 1$ and $x \gt 0$, $y \gt 0$}\\ \arctan\left(\frac{x+y}{1-xy}\right)-\pi \quad &\text{if $xy \gt 1$ and $x \lt 0$, $y \lt 0$} \end{cases}$
