# How to compute $\int_{0}^{\infty}\frac{\sqrt x\log(x)}{x^2+16}\;dx$ using Residue theorem?

I considered $$\gamma$$ the following curve:

From there, I know that $$$$\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)$$$$

$$$$\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)$$$$ $$$$\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)$$$$

We also have that $$$$\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$$$$ 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: $$$$\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^+}$$$$ Now, with $$\gamma_3$$ we get that

$$$$\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^+}$$$$

Therefore:

$$$$\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)$$$$

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

$$$$\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}$$$$ which is the result that Mathematica gives me.

Could anyone please check where my calculations are wrong?

• How did you calculate the residues? Are you sure that the correct branch for the square root and the logarithm of $-4i$ was chosen? Aug 28, 2021 at 16:08
• I just edited the question with the residues of each pole. Hope it helps! I even checked it in Mathematica to see if it was correct, and it showed the same answer. Aug 28, 2021 at 16:29

Care must be taken to chose the correct branch of square roots and logarithms. For example, with the branch cut at the positive real axis we have $$\log(-4i) = \log 4 + \frac{3\pi}{2}i \, .$$

I get the following residues: $$2\pi i \operatorname{Res}(f(z), 4i) = 2 \pi i \frac{\sqrt{4i}\log(4i)}{8i} = \frac{\pi}{2\sqrt 2}(1+i)(\log 4 + \frac{\pi}{2}i) \\ = \frac{\pi}{2\sqrt 2}(\log 4 - \frac{\pi}{2} + I_1)$$ and $$2\pi i \operatorname{Res}(f(z), -4i) = 2 \pi i \frac{\sqrt{-4i}\log(-4i)}{-8i} = \frac{\pi}{-2\sqrt 2}(-1+i)(\log 4 + \frac{3\pi}{2}i) = \frac{\pi}{2\sqrt 2}(\log 4 + \frac{3\pi}{2} + I_2)$$ where $$I_1$$ and $$I_2$$ are purely imaginary numbers. It follows that $$\tag{*} \frac{\pi}{2\sqrt 2}(2 \log 4 + \pi + I_1 + I_2) = 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$$ and taking real part gives the expected result $$\int_0^{\infty}\frac{\sqrt x\log(x)}{x^2+16}\;dx = \frac{\pi}{4\sqrt 2}( \log (16) + \pi) \, .$$

Note also that the explicit value of the second integral in $$(*)$$ is not needed since it is purely imaginary.

• So the problem was that I was taking the branch of $\log(-i)$ wrong. Wonderful! Thank you so much! Aug 28, 2021 at 16:44
• @OscarLanzi: That is correct (although from the term $e^{3\pi i /4}$ I guess that OP got that right). Aug 28, 2021 at 17:40
• Also watch the square root of $−4i$. With the branch cut in this problem you have to go the long way around, counterclockise from the upper side where the argument is taken as zero, not jumping the branch cut. So at $−4i$ the argument is $3π/2$ making the relevant square root equal to $2\exp{3i/4}=\sqrt2(-1+i)$. Aug 28, 2021 at 17:41

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

• Although it was required to use residues, I appreciate that you gave a different approach. Thank you so much for answering! Aug 28, 2021 at 17:19
• I do use residues but there is an extra step with a derivative to make the evaluations way easier by removing the logarithm. You're welcome! Aug 28, 2021 at 17:22