Revisiting Ahmed Integral in $(0,\infty)$ A recent post in MSE:
Evaluate $\int_0^{\infty } \frac{\tan ^{-1}\left(a^2+x^2\right)}{\left(x^2+1\right)\sqrt{a^2+x^2}} \, dx$
re-emphasizes that when Ahmed Integral is converted to a two-dimensional integral in $x,y$, then the sameness of domain the $(0,1)$ of $x$ and $y$ makes it do-able. Further, it asks for the evaluation of a slightly different Integral, which is challenging.
In this light, now the question here is: How to find $$\int_{0}^{\infty} \frac{\tan^{-1}\sqrt{2+x^2}}{(1+x^2)\sqrt{2+x^2}} dx?$$
Mind the upper limit that is $\infty$, there is square root sign in the argument of $\tan^{-1}$, and yes the integrand is the same as that of Ahmed integral.
 A: \begin{align}
&\int_{0}^{\infty} \frac{\tan^{-1}\sqrt{2+x^2}}{(1+x^2)\sqrt{2+x^2}}~ dx\\
=& \int_{0}^{\infty}\int_0^1  \frac{1}{(1+x^2)(1+y^2(2+x^2))}dy~dx\\
= & \int_{0}^{1}\int_0^\infty  \frac{1}{1+y^2}
\bigg( \frac{1}{1+x^2}-\frac{y^2}{1+y^2(2+x^2) }\bigg) dx~dy\\ 
 = & \ \frac\pi2\int_{0}^1 \frac{1}{1+y^2}
\bigg( 1-\frac{y}{\sqrt{1+2y^2} }\bigg)dy\\
=& \ \frac\pi2 \left(\tan^{-1}y-\tan^{-1}\sqrt{1+2y^2}\right)\bigg|_0^1
=\frac\pi2\cdot \frac\pi{6}=\frac{\pi^2}{12}
\end{align}
A: $$I=\int_{0}^{\infty} \frac{\tan^{-1}\sqrt{2+x^2}}{(1+x^2)\sqrt{2+x^2}}~ dx= \int_{0}^{\infty} \frac{\pi/2-\tan^{-1}(1/\sqrt{2+x^2})}{(1+x^2)\sqrt{2+x^2}}~dx$$
$$\implies I=\frac{\pi}{2}\int_{0}^{\infty} \frac{1}{(1+x^2)\sqrt{2+x^2}} dx
 -\int_{0}^{\infty} \frac{\tan^{-1}(1/\sqrt{2+x^2})}{(1+x^2)\sqrt{2+x^2}} dx =I_1-I_2$$
Let $x=\tan t$, then $ \sin t=\sqrt{2} \sin f$, we get
$$I_1=\frac{\pi}{2} \int_{0}^{\pi/2} \frac{\cos t~dt}{\sqrt{2-\sin^2 t}} =\int_{0}^{\pi/4} df=\frac{\pi^2}{8} $$
For $I_2$, we use the integral representation:
$$\frac{1}{z}\tan^{-1}\frac{1}{z}=\int_{0}^{1} \frac{dy}{y^2+z^2} $$
Then we get $$I_2=\int_{0}^{1} dy \int_{0}^{\infty} \frac{dx}{(1+x^2)(2+y^2+x^2)}$$ $$=\int_{0}^{1}\frac {dy}{1+y^2} \int_{0}^{\infty} \left(\frac{1}{1+x^2}-\frac{1}{2+y^2+x^2} \right) dx=\frac{\pi}{2}\int_{0}^{1} \frac{dy}{[2+y^2+\sqrt{2+y^2}]}$$
Next let $2+y^2=u^2$, then
$$I_2=\frac{\pi}{2} \int_{\sqrt{2}}^{\sqrt{3}} \frac{du}{(u+1)\sqrt{u^2-2}}=-
\frac{\pi}{2}\int_{\sqrt{2}-1}^{(\sqrt{3}-1)/2} \frac{dv}{\sqrt{2-(v+1)^2}}$$
We used $u+1=1/v$ in above. further
$$I_2=-\frac{\pi}{2}\left .\sin^{-1}\frac{v+1}{\sqrt{2}}\right|_{\sqrt{2}-1}^{(\sqrt{3}-1)/2}=- \frac{\pi}{2} \left(\sin^{-1}\frac{\sqrt{3}+1}{2\sqrt{2}}-\frac{\pi}{2}\right)=\frac{\pi^2}{24}$$
Finally, $$I=I_1-I_2=\frac{\pi^2}{8}-\frac{\pi^2}{24}=\frac{\pi^2}{12}.$$
