<s>[INST] $\int_{0}^{\infty}\tan^{-1}\left(\frac{2x}{1+x^2}\right)\frac{x}{x^2+4}dx$ $$\int_{0}^{\infty}\tan^{-1}\left(\frac{2x}{1+x^2}\right)\frac{x}{x^2+4}dx$$
I am given solution for this definite integral is $\frac{\pi}{2}\left(\ln\frac{\sqrt2+3}{\sqrt2+1}\right)$. Any idea or approach you would use to solve this?
 [/INST] Using integration by parts, we find
$$\int_0^\infty \tan^{-1}\left(\frac{2 x} {x^2 +1}\right)\frac{x}{x^2 +4}dx=\int_0^{\infty}\frac{(x^2-1)\ln(x^2+4)}{x^4+6x^2+1}  dx.$$
Factoring the denominator as
$$x^4+6x^2+1=(x^2+3+2\sqrt{2})(x^2+3-2\sqrt{2})\\
=(x^2+(\sqrt{2}+1)^2)(x^2+(\sqrt{2}-1)^2)$$ and then applying the partial fraction decomposition, we obtain
$$\frac{\sqrt{2}+1}{2}\int_0^{\infty} \frac{\ln(x^2+4)}{x^2+(\sqrt{2}+1)^2}  dx - \frac{\sqrt{2}-1}{2}\int_0^{\infty} \frac{\ln(x^2+4)}{x^2+(\sqrt{2}-1)^2}  dx.$$
Finally we use An improper integral : $\int_{0}^\infty {\ln(a^2+x^2)\over{b^2+x^2}}dx$? $=\frac{\pi}{b} \,   \ln(a+b) $, getting
$$\frac{\pi}{2}\ln(\sqrt{2}+3)-\frac{\pi}{2}\ln(\sqrt{2}+1)=\frac{\pi}{2}\ln\left(\frac{\sqrt2+3}{\sqrt2+1}\right).$$
</s>