Prove $$ \tan^{-1}\frac{2x}{1-x^2}=\begin{cases}2\tan^{-1}x,\quad|x|<1\\ -\pi+2\tan^{-1}x,\quad |x|>1,x>0\\ \pi+2\tan^{-1}x,\quad |x|>1,x<0\end{cases} $$ using differentiation and integration.
My Attempt
$$ \frac{d}{dx}\bigg(\tan^{-1}\frac{2x}{1-x^2}\bigg)=\frac{1}{1+\Big(\dfrac{2x}{1-x^2}\Big)^2}.\frac{(1-x^2).2-2x(-2x)}{(1-x^2)^2}\\=\frac{(1-x^2)^2}{(1+x^2)^2}.\frac{2.(1+x^2)}{(1-x^2)^2}=\frac{2}{|1+x^2|}=\frac{2}{1+x^2}\\ \boxed{\tan^{-1}\frac{2x}{1-x^2}=\int\frac{2}{1+x^2}dx=2\tan^{-1}x+C} $$ How do I derive the value of $C$ for the respective range of $x$ ?
Note: I can evaluate the value of $C$ by putting different $x$ values,I am looking for more generalised way to derive the constant $C$.
Example. $$ x=\sqrt{3}, \tan^{-1}-\sqrt{3}=2\tan^{-1}\sqrt{3}+C\\ C=-\pi/3-2\pi/3=-\pi $$
Let $f(x) = \tan^{-1}\frac{2x}{1-x^2}$ with domain $x\ne \pm1$. Then, $f'(x) = \frac2{1+x^2}$ and
$$ f(x) = f(x_0) + \int_{x_0}^x \frac2{1+t^2}dt =C+ 2\tan^{-1}x$$
where the constant $C$ is given by
$$C = f(x_0)- 2\tan^{-1}x_0 $$
Now, evaluate $C$ in the three cases.
1) Case $-1<x<1$: Let $x_0=0$,
$$C = f(0)- 2\tan^{-1}(0) =0$$
2) Case $x>1$: Let $x_0 \to \infty $,
$$C= f(\infty)- 2\tan^{-1}(\infty) =0 - 2\cdot\frac\pi2=-\pi$$
3) Case $x<-1$: Let $x_0 \to -\infty $,
$$C= f(-\infty)- 2\tan^{-1}(-\infty) =0 - 2\cdot\left(-\frac\pi2\right)=\pi$$