<s>[INST] Integrate $\int_{0}^{\infty}\frac{\tan^{-1}x}{x\left(1+x^{2}\right)}dx$ Q:

Integrate $I=\int_{0}^{\infty}\frac{\tan^{-1}x}{x\left(1+x^{2}\right)}dx$

My Approach:
Put $$\tan^{-1}x=t\to x=\tan t$$
Also we have, $$\frac{dx}{1+x^{2}}=dt$$
We get, $$I=\int_{0}^{\frac{\pi}{2}}\frac{t}{\tan t}dt$$
I'm stuck here, how do I proceed further? I tried integration by parts but it doesn't seem to work out for me.
Edit: I tried again and I got the answer 
 [/INST] $$\begin{align*}
\int_0^\infty \frac{\tan^{-1}(x)}{x(1+x^2)} \, dx &= \int_0^1 \frac{\tan^{-1}(x)}{x(1+x^2)} \, dx + \int_1^\infty \frac{\tan^{-1}(x)}{x(1+x^2)} \, dx \\[1ex]
&= \int_0^1 \frac{\tan^{-1}(x)}{x(1+x^2)} \, dx - \int_1^0 \frac{\tan^{-1}\left(\frac1x\right)}{\frac1x\left(1+\frac1{x^2}\right)} \frac{dx}{x^2} & (1) \\[1ex]
&= \int_0^1 \frac{\tan^{-1}(x)}{x(1+x^2)} \, dx + \int_0^1 \frac{\frac\pi2 x-x\tan^{-1}(x)}{1+x^2} \, dx & (2)\\[1ex]
&= \frac\pi2 \int_0^1 \frac x{1+x^2} \, dx + \int_0^1 \frac{\tan^{-1}(x)}{1+x^2} \left(\frac1x-x\right) \, dx \\[1ex]
&= \frac{\pi\ln(2)}4 + \int_0^1 \frac{\tan^{-1}(x)}x \, dx - \int_0^1 \frac{2x\tan^{-1}(x)}{1+x^2} \, dx & (3) \\[1ex]
&= \frac{\pi\ln(2)}4 + G - \left(\frac{\pi\ln(2)}4 - \int_0^1 \frac{\ln(1+x^2)}{1+x^2} \, dx\right) & (4) \\[1ex]
&= \boxed{\frac{\pi\ln(2)}2} & (5)
\end{align*}$$

*

*$(1)$ substitute $x\mapsto\frac1x$

*$(2)$ if $x>0$, then $\tan^{-1}(x)+\tan^{-1}\left(\frac1x\right)=\frac\pi2$

*$(3)$ partial fractions

*$(4)$ $G$ is Catalan's constant; integration by parts

*$(5)$ this integral with $a=1$
</s>