Contour Integration of Logarithmic Rational Function
I am looking to integrate the following
$$\int_{0}^{\infty} \frac{\ln^2(x)}{(x-1)^2} \,dx$$
Using Contour Integration. I made an attempt with a keyhole contour indented around $z = 0$ and took the branch cut to be on the positive real axis. Since the point at $z = 1$ is a removable singularity, we have no poles within our contour. If we consider the following contour integral in the complex plane
$$\oint_C{}^{} \frac{\ln^3(z)}{(z-1)^2} \,dz$$
Now since our contour is free of singularity we can use the residue theorem and say the above integral is $0$.
$$\oint_C{}^{} = \int_A{}^{}+\int_B{}^{}+\int_E{}^{}+\int_F{}^{}=0$$
For $A$ we have the path where $z=x, dz=dx$, the argument of the log equals $0$, and $x \in [\epsilon,R]$
$$\int_A{}^{} = \int_{\epsilon}^{R}\frac{\ln^3(x)}{(x-1)^2}dx$$
For $B$ we have the path where $z=x, dz=dx$, the argument of the log equals $2\pi i$, and $x \in [R,\epsilon]$
$$\int_B{}^{} = \int_{R}^{\epsilon}\frac{(\ln(xe^{2\pi i}))^3}{(xe^{2\pi i}-1)^2}dx$$
A quick computation shows that $B$, reduces down to
$$-\int_{\epsilon}^{R}\frac{\ln^3(x)}{(x-1)^2}dx-6\pi i\int_{\epsilon}^{R}\frac{\ln^2(x)}{(x-1)^2}dx \\ +12\pi^2 \int_{\epsilon}^{R}\frac{\ln(x)}{(x-1)^2}dx+8\pi^3 i \int_{\epsilon}^{R}\frac{1}{(x-1)^2}dx$$
Adding $A$ and $B$ together cancels the cubic logarithmic term nicely and gives us
$$-6\pi i\int_{\epsilon}^{R}\frac{\ln^2(x)}{(x-1)^2}dx+12\pi^2 \int_{\epsilon}^{R}\frac{\ln(x)}{(x-1)^2}dx+8\pi^3 i \int_{\epsilon}^{R}\frac{1}{(x-1)^2}dx$$
Now all that remains is to show that the integrals along the large circle, this is Path $E$, it goes from $\theta \in [0, 2\pi]$. But using the fact that the $zf(z)$ goes to zero as $R$ goes to $\infty$, ($f(z)$ is our integrand), $E$ provides $0$ contribution.
Similarly, along path $F$, this is the small indented circle around the branch point $z = 0$, our integrand behaves like $\epsilon \ln^3(\epsilon)$ which goes to $0$ as $\epsilon$ goes to $0^+$, at least thats what it should do based on this set up.
So after adding all of the paths and setting every thing equal to $0$, and letting the limits for $R$ and $\epsilon$ go to their appropriate values
$$-6\pi i\int_{0}^{\infty}\frac{\ln^2(x)}{(x-1)^2}dx+12\pi^2 \int_{0}^{\infty}\frac{\ln(x)}{(x-1)^2}dx+8\pi^3 i \int_{0}^{\infty}\frac{1}{(x-1)^2}dx=0$$
Now take the imaginary part of both sides
$$-6\pi \int_{0}^{\infty}\frac{\ln^2(x)}{(x-1)^2}dx=-8\pi^3 \int_{0}^{\infty}\frac{1}{(x-1)^2}dx$$
Simplifying this
$$\int_{0}^{\infty}\frac{\ln^2(x)}{(x-1)^2}dx=\frac{4}{3}\pi^2 \int_{0}^{\infty}\frac{1}{(x-1)^2}dx$$
Now this is where something is wrong. For one thing the integral on the right does not converge. Even if I were to use the principle value and apply the limit carefully, the result is $-1$.
$$\int_{0}^{\infty}\frac{\ln^2(x)}{(x-1)^2}dx=-\frac{4}{3}\pi^2$$
Having already been given the answer by a textbook, the correct answer should be $\frac{2}{3}\pi^2$, so I am wondering where I went wrong. Were my estimates for the big and small circle wrong? I am not 100% certain on the small circle, but the large circle should be zero. Rather annoying that it was off by a $-1/2$, I feel like it might be something algebraic, but I am not sure.
Solution 1:
The singularity at $z=1$ is removable on the upper side of the branch cut, but it's a double pole on the lower side of the branch cut.
Instead of dealing with the complications that arise when indenting a contour around a double pole, we can instead integrate the function $$\frac{\ln^{2}(z)}{(1-z)^2} $$ around a semicircular contour in the upper half-plane that is indented at the origin.
Letting the radius of the semicircle go to infinity, we get $$ \small \int_{-\infty}^{0} \frac{\left(\ln(|x|) + i \pi\right)^{2}}{(1-x)^{2}} \, \mathrm dx + \int_{0}^{\infty} \frac{\ln^{2}(x)}{(1-x)^{2}} \, \mathrm dx = \int_{0}^{\infty} \frac{\left(\ln(u) + i \pi\right)^{2}}{(1+u)^{2}} \, \mathrm du + \int_{0}^{\infty} \frac{\ln^{2}(x)}{(1-x)^{2}} \, \mathrm dx =0. $$
And equating the real parts on both sides of the equation, we get $$ \begin{align} \int_{0}^{\infty} \frac{\ln^{2}(x)}{(1-x)^{2}} \, \mathrm dx &= -\int_{0}^{\infty} \frac{\ln^{2} (u)}{(1+u)^{2}} \, \mathrm du+ \pi^{2} \int _{0}^{\infty}\frac{1}{(1+u)^{2}} \, \mathrm du \\ &= -\int_{0}^{\infty} \frac{\ln^{2}(u)}{(1+u)^{2}} \, \mathrm du+\pi^{2}. \end{align} $$
You can then show that $$ \int_{0}^{\infty}\frac{\ln^{2}(u)}{(1+u)^{2}} \, \mathrm du = \frac{\pi^{2}}{3} $$ by integrating the function $ \frac{\ln^{3}(z)}{(1+z)^{2}}$ around the keyhole contour that you described.
If you want to indent the contour around the double pole, the approach would be similar to this answer.