# 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.

\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}

$$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}.$$

I was working on this problem today actually, you can do it multiple ways. The usual method is to introduce some parameter $$t$$ in the problem, and then take a derivative. Here our parameter is defined, $$t \in [0,1]$$.

$$I(t) = \int_0^{\infty}\frac {arctan(t(\sqrt{x^2+2})} {(x^2+1)(\sqrt{x^2+2})}dx$$

Note that $$I(0)=0$$, and $$I(1)=I$$ is the integral you are looking for. Now let's take the derivative.

$$I'(t) = \frac{d} {dt} \int_0^\infty\frac {arctan(t(\sqrt{x^2+2})} {(x^2+1)(\sqrt{x^2+2})}dx= \int_0^\infty\frac {\frac{\partial}{\partial t}arctan(t(\sqrt{x^2+2})} {(x^2+1)(\sqrt{x^2+2})}dx= \int_0^\infty\frac {\sqrt{x^2+2}} {(x^2+1)(t^2(x^2+2)+1)(\sqrt{x^2+2})}dx$$

$$I'(t)=\int_0^\infty\frac {dx} {(x^2+1)(t^2(x^2+2)+1)}$$

Now I will make the variable change $$u= xt$$. Our limits stay the same, but our problem becomes,

$$I'(t)=t \int_0^\infty\frac {du} {(u^2+t^2)(u^2+2t^2+1)}$$

Normally people would do partial fractions here, and integrate each term, but I want to take some advantage of the improper nature of the integral, the rational nature of the expression, and that the integrand is even.

Now consider the following contour integral in the complex plane.

$$\oint\limits_{C}\frac {dz} {(z^2+t^2)(z^2+2t^2+1)}$$ = $$\oint\limits_{C}f(z)dz$$

Where our Contour, is the semi-circle in the upper half plane.

$$\oint\limits_{C}=\oint\limits_{C_{1}}+\oint\limits_{C_{2}}$$

$$C_{2}:z = x$$, $$x \in [-R,R]$$

$$C_{1}:z = Re^{i\theta}$$, $$\theta \in [0,\pi]$$

You can use an estimate to show that $$\oint\limits_{C_{1}} \longrightarrow 0$$, This is because our function has the appropriate decay behavior for large $$z$$, namely $$|zf(z)| \longrightarrow 0$$ as $$z \longrightarrow \infty$$

The integral on $$C_{2}$$ is the real valued integral we are looking for.

$$\oint\limits_{C_{2}}f(z)dz = lim_{R \to \infty}\int^{R}_{-R}\frac {dx} {(x^2+t^2)(x^2+2t^2+1)} = \int^{\infty}_{-\infty}\frac {dx} {(x^2+t^2)(x^2+2t^2+1)}$$

Note that I've reverted back to using the variable $$x$$ instead of $$u$$, it matters very little since the limits are the same. Now all that remains is to evaluate the integral on the main contour. Our function has poles at $$z=it$$ and $$z = i\sqrt{2t^2+1}$$, and we can use the Residue Theorem to evaluate the integral. These poles are contained within our contour and we need not consider the other poles since they lie outside our contour.

$$\oint\limits_{C}f(z)dz = 2\pi i\cdot Res(f(z),it)+2\pi i\cdot Res(f(z),i\sqrt{2t^2+1}))$$ = $$\frac{\pi} {t(t^2+1)} - \frac{\pi }{(t^2+1)\sqrt{2t^2+1}}$$

$$\oint\limits_{C}=\oint\limits_{C_{1}}+\oint\limits_{C_{2}} = \frac{\pi} {t(t^2+1)} - \frac{\pi }{(t^2+1)\sqrt{2t^2+1}} = \int^{\infty}_{-\infty}\frac {dx} {(x^2+t^2)(x^2+2t^2+1)}=2\int^{\infty}_{0}\frac {dx} {(x^2+t^2)(x^2+2t^2+1)}$$

$$\int^{\infty}_{0}\frac {dx} {(x^2+t^2)(x^2+2t^2+1)} = \frac{\pi} {2t(t^2+1)} - \frac{\pi }{2(t^2+1)\sqrt{2t^2+1}}$$

$$I'(t) = t\int^{\infty}_{0}\frac {dx} {(x^2+t^2)(x^2+2t^2+1)} = t \bigg(\frac{\pi} {2t(t^2+1)} - \frac{\pi }{2(t^2+1)\sqrt{2t^2+1}}\bigg) = \frac{\pi}{2} \bigg( \frac{1} {(t^2+1)} - \frac{ t}{(t^2+1)\sqrt{2t^2+1}}\bigg)$$

Now we integrate both sides

$$\int_0^1 I'(t)dt = I(1)-I(0) = I = \int_0^{\infty}\frac {arctan((\sqrt{x^2+2})} {(x^2+1)(\sqrt{x^2+2})}dx = \frac{\pi} {2} \bigg( \int_0^1\frac{dt} {(t^2+1)} - \int_0^1\frac{ t}{(t^2+1)\sqrt{2t^2+1}}\bigg)$$

For the second one make the substition $$\sqrt{2t^2+1} = tan^{2}\theta$$,

$$I = \frac{\pi}{2}\bigg( arctan(t)\Biggr|_0^1 - arctan(\sqrt{2t^2+1})\Biggr|_0^1\bigg) = \frac{\pi}{2} \bigg(\frac{\pi} {4}-0 - (\frac{\pi}{6}-\frac{\pi}{4})\bigg)$$

$$\int_0^{\infty}\frac {arctan((\sqrt{x^2+2})} {(x^2+1)(\sqrt{x^2+2})}dx = \frac{\pi^2}{12}$$