Residue Theorem for Real Integral: Where did I go Wrong

calculuscomplex-analysisintegrationresidue-calculus

So the integral is
$$\int_{0}^{\infty} \frac{\sqrt{x}}{x^2 + 4x + 5} d x.$$

I did keyhole integration avoiding the positive real axis. Let this be $C$.

I defined the integrand as a complex valued function, and found that the poles are at $-2-i$ and $-2+i$.
Computing the residues, we have
$$Res(f, -2+i) = -\frac{\sqrt{-2-i}}{2i}$$
and
$$Res(f, -2+i) = \frac{\sqrt{-2+i}}{2i}.$$
So then
$\int_C f(z) = 2\pi i (\frac{\sqrt{-2+i}}{2i}-\frac{\sqrt{-2-i}}{2i}) = \pi (\sqrt{-2+i}-\sqrt{-2-i}).$

Now, after doing the keyhole part, the integral over the large circle and the small circle goes to 0 and so the only thing left are the integral over the line segment connecting the small circle to the large circle at angle $\epsilon$ and the integral over the line segment connecting the large circle to the small circle at angle $2\pi – \epsilon$. Letting the radius of the small circle go to 0 and the radius of the large circle to infinity, we find that the two integrals are equal and

$$\int_C f(z) dz = 2\int_{0}^{\infty} f(x) dx.$$
But
$$\int_{0}^{\infty} f(x) dx = \frac{\pi}{2} (\sqrt{-2+i}-\sqrt{-2-i}),$$
which is an imaginary number.

I've been trying to find my mistake but I can't seem to. Where did I go wrong? Wolfram tells me that the answer is $\sqrt{\frac{1}{2}(\sqrt{5} – 2)}\pi$. My guess is that it's somewhere in the residue theorem step… Please help!

Best Answer

With a keyhole contour you give $z$ a phase from $0$ to $2\pi$, not $-\pi$ to $\pi$, because of how the contour is traversed anticlockwise, so the phase of phase $\sqrt{z}$ is in $[0,\,\pi)$. (Logarithms provide a similar need for caution.) Write $w:=\sqrt{-2+i}$ as $x+iy$ with $x,\,y\in\Bbb R$ so$$x^2+y^2=\sqrt{5},\,x^2-y^2=-2\implies x^2=\frac{\sqrt{5}-2}{2}.$$Since $w^2$ has obtuse phase, $w$ has acute phase, so $x>0$. What's more, $\sqrt{-2-i}=-w^\ast$ (you took it as $w^\ast$), so since $z^2+4z+5=(z-w^2)(z-w^{\ast2})$ the integral is$$\frac{2\pi i}{1-e^{2\pi i\cdot\frac32}}\frac{w+w^\ast}{w^2-w^{\ast2}}=\pi x=\pi\sqrt{\frac{\sqrt{5}-2}{2}}$$as expected, because $w^2-w^{\ast2}=2i\Im(-2+i)=2i$.