# integrate square of $\arctan x$. Tricky

$$\int \left(\frac{\tan^{-1}x}{x-\tan^{-1}x}\right)^{2}dx$$

I ran across an integral I am having a time solving. The solution merely works out to $\displaystyle\frac{1+x\tan^{-1}x}{\tan^{-1}x-x}$, but for the life of me I can not find a suitable method to tackle it.

Does anyone have any hints on a good strategy, substitution, parts, etc?. Thanks much.

-
We have to be careful not to be too "clever" in substituting. For instance, the substitution $u=\frac{1+x\arctan x}{\arctan x -x}$ does not really qualify as a method. – André Nicolas Nov 4 '11 at 23:32
This is a study in iterated tangents. God only knows what those are good for. Supposing we let $\alpha = \tan\beta$ and $x=\tan\tan\beta$. Then $\dfrac{1+x\arctan x}{\arctan x -x}$ $= \dfrac{1}{\tan(\beta-\tan\beta)}$. – Michael Hardy Nov 5 '11 at 1:12

The denominator suggests that maybe an integration by parts will help where $v=\frac{1}{x-\arctan x}$. This may make for a strange looking $dv$ that is not readily apparent from the given integral.

$$\frac{d}{dx}\left(\frac{1}{x-\arctan x}\right)=\frac{-\frac{x^2}{1+x^2}}{(x-\arctan x)^2}$$

So let's try $dv=\frac{-\frac{x^2}{1+x^2}}{(x-\arctan x)^2}$ and $u =-\arctan^2x\frac{1+x^2}{x^2}$. Note that $u = -\left(\frac{1}{x^2}+1\right)\arctan^2 x$.

Computing $du$, we have \begin{align} du &=\left[-\left(\frac{1}{x^2}+1\right)\frac{2\arctan x}{1+x^2}+\frac{2\ \arctan^2x}{x^3}\right]dx\\ &=\frac{2\arctan x}{x^3}\left(\arctan x-x\right)\ dx\end{align}

Applying the integration by parts formula $\int u\,dv=uv-\int v\,du$, the given intergal is equal to $$-\left(\frac{1}{x^2}+1\right)\arctan^2 x\frac{1}{x-\arctan x}+\int\frac{2\arctan x}{x^3}\,dx$$

The new integral can be handled with another integration by parts where $u$ is $\arctan x$ and $dv$ is $2x^{-3}$. That will leave you with a rational function in $x$, which can be integrated using partial fraction decomposition. Once all of the integration is complete, the terms should add together to give what you know the antiderivative to be (perhaps with a constant difference). These next steps are "ugly" details, but follow the description above. We have \begin{align}&-\frac{\left(\frac{1}{x^2}+1\right)\arctan^2 x}{x-\arctan x}-\frac{\arctan x}{x^2}+\int\frac{1}{x^2(1+x^2)}\ dx\\ =&-\frac{\left(\frac{1}{x^2}+1\right)\arctan^2 x}{x-\arctan x}-\frac{\arctan x}{x^2}+\int\frac{1}{x^2}\ dx-\int\frac{1}{x^2+1}\ dx\\ =&-\frac{\left(\frac{1}{x^2}+1\right)\arctan^2 x}{x-\arctan x}-\frac{\arctan x}{x^2}-\frac{1}{x}-\arctan x+C\\ =&\frac{1+x\arctan x}{x^2(x-\arctan x)}-\frac{\arctan x(x-\arctan x)}{x^2(x-\arctan x)}\\&-\frac{x(x-\arctan x)}{x^2(x-\arctan x)}-\frac{x^2(x-\arctan x)\arctan x}{x^2(x-\arctan x)}+C\\ \\ =&-\frac{\left(1+x^2\right)\arctan^2 x}{x^2(x-\arctan x)}-\frac{\arctan x(x-\arctan x)}{x^2(x-\arctan x)}\\&-\frac{x(x-\arctan x)}{x^2(x-\arctan x)}-\frac{x^2(x-\arctan x)\arctan x}{x^2(x-\arctan x)}+C\\ \\ =&\frac{-x^2-x^3\arctan x}{x^2(x-\arctan x)}+C\\ =&-\frac{1+x\arctan x}{(x-\arctan x)}+C\\ \end{align}

-
Note that since $\arctan^2x$ was involved, it's not a total surprise that integration by parts got used twice in this solution. Each application lowers the exponent on $\arctan x$ by $1$. – alex.jordan Nov 5 '11 at 0:00
Nice. Are you aware that you can use double dollar signs to get displayed equations? I find them quite a bit easier to read. – joriki Nov 5 '11 at 0:00
@joriki Yes thanks, I think I have already changed them. Sometimes when I post in math.se I compose a rough version first, post it, and then go back to clean it up. – alex.jordan Nov 5 '11 at 0:05
I actually tried the suggested sub and the v in the parts, but failed to put it together. I suppose I should not have given up so quick. Thank you all very much for excellent solutions. – Cody Nov 5 '11 at 0:28

With $x = \tan(u)$, $\mathrm{d}x = \frac{1}{\cos^2(u)}\mathrm{d} u$, thus $$\int \left(\frac{\tan^{-1}x}{x-\tan^{-1}x}\right)^{2} \mathrm{d}x = \int \left( \frac{u}{\tan(u) - u} \cdot \frac{1}{\cos(u)} \right)^2 \mathrm{d} u = \int \left( \frac{u}{\sin(u) - u \cdot \cos(u)} \right)^2 \mathrm{d} u$$ Now, observe that $$\mathrm{d} \left( \frac{1}{\sin(u)-u \cos(u)} \right) = \frac{-u \sin(u) \mathrm{d} u }{(\sin(u)-u \cos(u))^2}$$ This allows to integrate by parts: $$\begin{eqnarray} I &=& \int \left( \frac{u}{\sin(u) - u \cdot \cos(u)} \right)^2 \mathrm{d} u = \int \left( -\frac{u}{\sin(u)} \right) \mathrm{d}\left( \frac{1}{\sin(u)-u \cos(u)} \right) \\ &=& -\frac{u}{\sin(u)\left(\sin(u)-u \cos(u) \right)} + \int \frac{1}{\sin(u)-u \cos(u)} \mathrm{d} \left( \frac{u}{\sin(u)} \right) \\ &=& -\frac{u}{\sin(u)\left(\sin(u)-u \cos(u) \right)} + \int \frac{\mathrm{d}u}{\sin^2(u)} \\ &=& -\frac{u}{\sin(u)\left(\sin(u)-u \cos(u) \right)} - \frac{1}{\tan(u)} + C \\ &=& -\frac{\arctan(x)}{\frac{x}{\sqrt{1+x^2}} \left(\frac{x}{\sqrt{1+x^2}} -\arctan(x) \cdot \frac{1}{\sqrt{1+x^2}} \right)} - \frac{1}{x} + C \\ &=& -\frac{1}{x} \left( 1+ \frac{(1+x^2) \arctan(x) }{x - \arctan(x)}\right) + C = -\frac{ 1 + x \arctan(x) }{x - \arctan(x)} + C \end{eqnarray}$$

-
Thanks Alex and Sasha. Your solutions are clever and very detailed. – Cody Nov 5 '11 at 11:00