TITLE: How to compute $\int_{0}^{\infty}\frac{\sqrt x\log(x)}{x^2+16}\;dx$ using Residue theorem?
QUESTION [5 upvotes]: I considered $\gamma$ the following curve:
From there, I know that
\begin{equation}
\int_{\gamma}\frac{\sqrt z\log(z)}{z^2+16}\;dz = 2\pi i\left(\operatorname{Res}\left(f(z),4i\right)+\operatorname{Res}\left(f(z),-4i\right)\right) = \frac{2\pi i}8e^{\frac{\pi i}4}(1-i)(\log(16)+\pi) = \frac{\sqrt2}4\pi i(\log(16)+\pi)
\end{equation}
\begin{equation}
\operatorname{Res}(f,4i) = \lim_{z\to 4i}(z-4i)f(z) = \lim_{z\to 4i}\frac{\sqrt z\log(z)}{x+4i} = \frac{2e^{\frac{\pi i}{4}}(\log(16)+\frac\pi2 i)}{8i} = \frac18e^{\frac{\pi i}{4}}(-i\log(16)+\pi)
\end{equation}
\begin{equation}
\operatorname{Res}(f,-4i) = \lim_{z\to -4i}(z+4i)f(z) = \lim_{z\to -4i}\frac{\sqrt z\log(z)}{x-4i} = \frac{-2e^{\frac{3\pi i}{4}}(\log(16)-\frac\pi2 i)}{-8i} = \frac18e^{\frac{\pi i}{4}}(\log(16)-\pi i)
\end{equation}
We also have that
\begin{equation}
\int_{\gamma}f(z)\;dz = \int_{\gamma_1}f(z)\;dz + \int_{\gamma_2}f(z)\;dz - \int_{\gamma_3}f(z)\;dz - \int_{\gamma_4}f(z)\;dz 
\end{equation}
It is easy to check that $\int_{\gamma_2}f(z)\;dz\to 0$ when $R\to\infty$ and $\int_{\gamma_4}f(z)\;dz\to 0$ when $\varepsilon\to0^+$. Then, the only thing we need to do is the following:
\begin{equation}
\int_{\gamma_1}f(z)\;dz =  \int_0^{\sqrt{R^2-\varepsilon^2}}f(x+i\varepsilon)\;dx\to \int_0^{\infty}f(x)\;dx\text{ when $R\to\infty$ and $\varepsilon\to0^+$}
\end{equation}
Now, with $\gamma_3$ we get that
\begin{equation}
\int_{\gamma_3}f(z)\;dz =  \int_0^{\sqrt{R^2-\varepsilon^2}}f(x-i\varepsilon)\;dx\to -\int_0^{\infty}\frac{\sqrt x(\log(x) + 2\pi i)}{x^2+16}\;dx\text{ when $R\to\infty$ and $\varepsilon\to0^+$}
\end{equation}
Therefore:
\begin{equation}
\frac{\sqrt2}4\pi i(\log(16)+\pi) = 2\int_0^{\infty}\frac{\sqrt x\log(x)}{x^2+16}\;dx + \int_0^{\infty}\frac{2\pi i\sqrt x}{x^2+16}\;dx\;\;\;\;(1)
\end{equation}
To not complicate this much, I computed $\int_0^{\infty}\frac{2\pi i\sqrt x}{x^2+16}\;dx$ in Mathematica and got $\frac{i\pi^2}{\sqrt2}$. Substracting it in (1) we get
\begin{equation}
\int_0^{\infty}\frac{\sqrt x\log(x)}{x^2+16}\;dx = i\pi\frac{\log(16)-\pi}{4\sqrt2}\ne \pi\frac{\log(16)+\pi}{4\sqrt2}
\end{equation}
which is the result that Mathematica gives me.
Could anyone please check where my calculations are wrong?

REPLY [3 votes]: Here's an alternative way to do the integral that doesn't involve as complex considerations about the branch cuts of the function. Consider the auxiliary integral
$$I(a;y)=\int_0^\infty \frac{x^a}{x^2+y^2}dx=y^{a-1}\int_{0}^\infty\frac{z^a}{z^2+1}dz$$
which converges for $|a|<1$.
Then the integral in question is given by a simple operation on the auxiliary integral: $\frac{dI(a;4)}{da}\big|_{a=1/2}$ is the expression we seek to find. Using the keyhole contour with an inner hole of radius $\epsilon$ and outer radius $R$ and taking the branch cut of $z^a$ to be the positive real axis we compute the integral using the residue theorem
$$\int_0 ^{\infty}\frac{x^a}{x^2+1}dx-\int_0^{\infty}\frac{(xe^{2\pi i })^a dx}{x^2+1}-i\epsilon^{a+1}\int_0^{2\pi}\frac{e^{i(a+1)\theta}}{\epsilon^2e^{2i\theta}+1}+iR^{a+1}\int_0^{2\pi}\frac{e^{i(a+1)\theta}}{R^2e^{2i\theta}+1}=2\pi i\left(\frac{x^a}{x+i}\Bigg|_{x=i}+\frac{x^a}{x-i}\Bigg|_{x=-i}\right)$$
In the range of $a$ prescribed, both inner and outer circle contributions vanish as we take the limit $R\to\infty$ and $\epsilon\to 0$. We evaluate the RHS carefully with respect to the chosen branch cut for $z^a$ (in particular $i=e^{i\pi/2}$ and $-i=e^{3\pi i /2}$ here) and we obtain the desired result
$$I(a;1)=\frac{\pi}{2\cos\frac{\pi a}{2}}$$
We can now take the derivative
$$\frac{d}{da}I(a;y)=\frac{\pi y^{a-1}}{2\cos\frac{\pi a}{2}}\left(\log y+\frac{\pi}{2}\tan\frac{\pi a }{2}\right)$$
and evaluate for the final result
$$\int_0^\infty dx\frac{\sqrt{x}\log x}{x^2+16}=\frac{\pi}{2\sqrt{2}}(\log 4+\frac{\pi}{2})$$