<s>[INST] How do I use residue theorem to evaluate this improper integral to get a good looking solution? The problem is $\int_{0}^{\infty} \frac{\sqrt{x}}{x^2+2x+5}dx$ 
I replace x with z, and did some algebra, but the solution was rather nasty. it contains exponential and arctan such and such. However, the solution given was $\frac{\pi}{2\sqrt{2}}{\sqrt{\sqrt{5}-1}}$. It was pretty neat and I have no idea how I could convert my solution to that form. 
 [/INST] Suppose we seek to evaluate
$$J = \int_0^\infty \frac{\sqrt{x}}{x^2+2x+5} dx$$
using a keyhole contour and the function
$$f(z) = \frac{\exp(1/2\log(z))}{z^2+2z+5}$$
with the branch cut of the logarithm on the positive real axis and the
argument from $0$ to $2\pi.$

We obtain that
$$J (1- e^{\pi i})
= 2\pi i
\left(\mathrm{Res}_{z=\rho_1} f(z)
+ \mathrm{Res}_{z=\rho_2} f(z)\right)$$
where $\rho_{1,2} = -1\pm 2i.$

The two residues are
$$\frac{\exp(1/2\log(\rho_{1,2}))}{2\rho_{1,2} + 2}.$$
Let $\rho_1 = \sqrt{5} \exp(i\theta)$ with $0\lt\theta\lt \pi$ so that
$\rho_2 = \sqrt{5} \exp(2\pi i - i\theta)$ with the chosen branch of the logarithm.
This gives
$$\mathrm{Res}_{z=\rho_1} f(z) =
\frac{5^{1/4} \exp(1/2 i\theta)}{2\rho_1+2}
= \frac{5^{1/4} \exp(1/2 i\theta)}{4i} $$
and
$$\mathrm{Res}_{z=\rho_2} f(z) =
- \frac{5^{1/4} \exp(-1/2 i\theta)}{2\rho_2+2}
= \frac{5^{1/4} \exp(-1/2 i\theta)}{4i}.$$
Collecting everything we obtain
$$\pi i \times
\frac{5^{1/4}}{2i} \cos(1/2\theta)
= \pi \frac{5^{1/4}}{2}  \cos(1/2\theta).$$

This is
$$\pi \frac{5^{1/4}}{2} \sqrt{\frac{1+\cos\theta}{2}}
= \pi \frac{5^{1/4}}{2} \sqrt{\frac{1-1/\sqrt{5}}{2}}
= \frac{\pi}{2} \sqrt{\frac{\sqrt{5}-1}{2}}.$$
</s>