Keyhole contour integration of $\int_0^{\infty}\frac{z^{1/2}\log(z)}{(1+z)^2}dz$ I'm trying to use a contour integral to integrate $$K = \int_0^{\infty}\frac{z^{1/2}\log(z)}{(1+z)^2}dz$$
I used the "squaring to log" trick with a keyhole contour on the postive real axis. I must be bungling something though.
When I compute the residue of $\frac{z^{1/2}\log(z)^2}{(1+z)^2}$ at $-1$, I obtain $2\pi i(2\pi + \frac{i\pi^2}{2})$ (obtained by taking the derivative of the numerator and evaluating at $-1$). On the otherhand, when I simplify $$\int_0^{\infty}\frac{z^{1/2}\log(z)^2}{(1+z)^2}-\frac{z^{1/2}(\log(z)+2\pi i)^2}{(1+z)^2}dz = \\-4\pi i K+2\pi^3$$
I suspect something is wrong because the real parts of this don't match my residue computation.  What am I missing?
 A: When dealing with branch points it is not a bad idea to enforce some substitution in order to simplify the problem. By letting $z=w^2$ we have
$$ \int_{0}^{+\infty}\frac{\sqrt{z}\log(z)}{(1+z)^2}\,dz = 4\int_{0}^{+\infty}\frac{w^2 \log(w) }{(1+w^2)^2}\,dw=4\int_{0}^{1}\frac{w^2 \log(w) }{(1+w^2)^2}\,dw+4\int_{0}^{1}\frac{-\log(w) }{(1+w^2)^2}\,dw $$
and it is enough to compute
$$ 4\int_{0}^{1}\frac{1-w^2}{(1+w^2)^2}\left(-\log w\right)\,dw=4\sum_{n\geq 0}(-1)^n(2n+1)\int_{0}^{1}w^{2n}(-\log w)\,dw $$
which is just
$$ 4\sum_{n\geq 0}\frac{(-1)^{n}}{2n+1} = 4\arctan(1) = \color{red}{\pi}.$$
This shows that we may avoid the hunting phase for the suitable contour.
Feyman's trick and the (inverse) Laplace transform allow to do the same in many other situations.
A: We provide support for  the main steps. Introducing $\mathrm{Log}(z)$,
the branch with argument in $[0,2\pi)$ we integrate
$$f(z) =
\exp((1/2)\mathrm{Log}(z)) \frac{\mathrm{Log}(z)}{(1+z)^2}$$
along a keyhole contour with the slit on the positive real axis.
We get in the limit above the slit
$$K = \int_0^\infty \sqrt{x}\frac{\log(x)}{(1+x)^2} \; dx.$$
Below the slit we find
$$\int_\infty^0 \exp(\pi i)
\sqrt{x} \frac{\log(x)+2\pi i}{(1+x)^2} \; dx
= \int_0^\infty
\sqrt{x} \frac{\log(x)+2\pi i}{(1+x)^2} \; dx
\\ = K + 2\pi i \int_0^\infty
\sqrt{x} \frac{1}{(1+x)^2} \; dx = K + 2\pi i J.$$
We have the two contributions separated into real and imaginary parts,
so  we  just  need  to  compute  the  residue  at  $z=-1$  of  $f(z).$
Differentiating we find
$$\frac{1}{2z} \exp((1/2)\mathrm{Log}(z)) \mathrm{Log}(z)
+ \frac{1}{z} \exp((1/2)\mathrm{Log}(z)).$$
Evaluate at $z=-1$ to get
$$-\frac{1}{2} \exp((1/2)\pi i) (\pi i) - \exp((1/2)\pi i)
= \frac{\pi}{2} - i.$$
With $K$ and $J$ real we collect the contributions to obtain
$$2K + 2\pi i J = 2\pi i \times \left(\frac{\pi}{2} - i\right)
= \pi^2 i + 2\pi.$$
This means that
$$\bbox[5px,border:2px solid #00A000]{
K = \pi \quad\text{and}\quad J = \frac{\pi}{2}.}$$
The required ML estimates for  the circular components go through with
$\lim_{R\to\infty}  2\pi R  \times \sqrt{R}  \log(R)/(1+R)^2 =  0$ and
$\lim_{\epsilon\to   0}    2\pi   \epsilon    \times   \sqrt{\epsilon}
\log(\epsilon) /(1+\epsilon)^2 = 0.$
