How to derive the formula for $\arctan(x) + \arctan(y)$ depending on $x,y$? I was trying to derive the following formula
$$\arctan(x)+\arctan(y) = \begin{cases}\arctan\left(\dfrac{x+y}{1-xy}\right), &amp;xy &lt; 1 \\[1.5ex] 
\pi + \arctan\left(\dfrac{x+y}{1-xy}\right), &amp;x&gt;0,\; y&gt;0,\; xy&gt;1 \\[1.5ex] 
-\pi + \arctan\left(\dfrac{x+y}{1-xy}\right), &amp;x&lt;0,\; y&lt;0,\; xy &gt; 1\end{cases}$$

I proceeded this way

$$\tan{(A+B)}= \frac{\tan{A}+\tan{B}}{1-\tan{A}\tan{B}}$$
$$\arctan(\tan{(A+B)})=\arctan\bigg(\frac{\tan{A}+\tan{B}}{1-\tan{A}\tan{B}}\bigg)$$
$$A+B=\arctan\bigg(\frac{\tan{A}+\tan{B}}{1-\tan{A}\tan{B}}\bigg)$$ $$\tag*{$\frac{-\pi}{2}&lt;A+B&lt;\frac{\pi}{2}$}$$
$$A=\arctan(\tan A)$$ $$\tag*{$\frac{-\pi}{2}&lt;A&lt;\frac{\pi}{2}$}$$
$$B=\arctan(\tan B)$$ $$\tag*{$\frac{-\pi}{2}&lt;B&lt;\frac{\pi}{2}$}$$
$$\arctan(\tan A) + \arctan(\tan B)=\arctan\bigg(\frac{\tan{A}+\tan{B}}{1-\tan{A}\tan{B}}\bigg)$$
$$\tan A=x$$
$$\tan B=y$$
$$\arctan(x) + \arctan(y)=\arctan\bigg(\frac{x+y}{1-xy}\bigg)$$

Now from here ownwards I don’t know how It gets converted to 3 different definitions. You’re help will be highly appreciated.
Let $y\in\Bbb R$ and let $f(x)=\arctan\left(\frac{x+y}{1-xy}\right)$. Then, by the chain rule,\begin{align}f'(x)&amp;=\frac{\frac{y^2+1}{(1-xy)^2}}{1+\left(\frac{x+y}{1-xy}\right)^2}\\&amp;=\frac{y^2+1}{(1-xy)^2+(x+y)^2}\\&amp;=\frac{y^2+1}{1+x^2y^2+x^2+y^2}\\&amp;=\frac{y^2+1}{(1+y^2)(1+x^2)}\\&amp;=\frac1{1+x^2}\\&amp;=\arctan'(x).\end{align}So, $f-\arctan$ is constant. But $f(0)-\arctan(0)=\arctan(y)$.
Hint: Apply $\tan$ to the both sides of the equality and use the fact that $\tan$ is injective.

$\tan(\arctan(x)+\arctan(y))={{x+y}\over{1-xy}}$.