Find the indefinite integral $\int \left(\frac{\arctan x}{\arctan x - x}\right)^2 dx$. I am wondering if there is a systematic way to find the indefinite integral
$$\int \left(\frac{\arctan x}{\arctan x - x}\right)^2 dx.$$
It indeed has a clean closed form 
$$\frac{x^2 + 1}{\arctan x - x} + x.$$
But I am not able to reach it in a logical way. The transformation $t = \arctan x$ doesn't seem to help much.

The integrand is
$$ \left(1+\frac{x}{\arctan x - x}\right)^2 = 1 + \frac{2x}{\arctan x - x} + \frac{x^2}{(\arctan x - x)^2} $$
Observe that
$$ (\arctan x - x)' = \frac{1}{x^2+1} - 1 = -\frac{x^2}{x^2+1} $$
So we can perform IBP on the last term
$$ \int (x^2+1)\left(\frac{1}{(\arctan x - x)^2}\frac{x^2}{x^2+1}\right)dx = \frac{x^2+1}{\arctan x - x} - \int\frac{2x}{\arctan x - x} dx $$
Thus 
$$ \int \frac{x^2}{(\arctan x - x)^2}dx +  \int\frac{2x}{(\arctan x - x)^2} dx = \frac{x^2 + 1}{\arctan x - x} $$
The rest is obvious.
