Calcuating an Integral via Residues I am trying to solve the following integral:
$$\int_0^\infty\frac{dx*x}{(x^2+1)(2+x)}$$
What I have done is an analytical extenstion to the upper half plane only by recognising that the above integral is just 1/2 the integral over the entire real line, then only considered poles that exist in the upper half.
I then found the corresponding residues of the poles and used the resiude theorem.
My final answer is:
$$(\frac{1}{10} - \frac{i}{5}) \pi$$
However, using mathematica I find that the actual answer should be:
$$\frac{1}{10}(\pi + Log[16])$$
What am I doing wrong? Any ideas?
 A: Consider $\displaystyle \oint_C \frac{z \, \textrm{Log }z \, dz}{(z^2+1)(z+2)}$ where $C$ is the keyhole contour that goes from $\epsilon$ to $R$ then around a large circle of radius $R$ counterclockwise, from $R$ to $\epsilon$ (below the positive real axis) and around a circle of radius $\epsilon$ clockwise.  There are three poles within the contour at $\{-2,i,-i \}$.
The integral is equal to $2\pi i$ times the sum of the residuals at the poles inside the contour.
The integral around the keyhole is equal to the sum of the integrals along the curves making up the keyhole contour.  On the circles of radius $R$ and radius $\epsilon$, the integrals approach zero in the limit.
Taking the limit as $\epsilon\rightarrow 0$ and $R\rightarrow \infty$, and showing only the non-zero terms that remain, we have
$$\lim_{\epsilon \rightarrow 0 , R \rightarrow \infty} \left[ \int_\epsilon^R \frac{x \log x \, dx}{(x^2+1)(x+2)} - \int_\epsilon^R \frac{x (\log x+2\pi i)\,dx}{(x^2+1)(x+2)}\right]= 2\pi i \sum_{z\in \textrm{poles}} \textrm{Res }\left[ \frac{z \, \textrm{Log }z}{(z^2+1)(z+2)}\right].$$
The left-hand side is
$$-2\pi i \int_0^\infty  \frac{x \, dx}{(x^2+1)(x+2)}$$
The sum of the residues (multiplied by $2\pi i$) is also purely imaginary, so we obtain a real expression for the integral.  
$$ \int_0^\infty  \frac{x \, dx}{(x^2+1)(x+2)} = 
- \left. \text{Res } \frac{z\,\text{Log }z}{(z^2+1)(z+2)}\right|_{z=i}
- \left. \text{Res } \frac{z\,\text{Log }z}{(z^2+1)(z+2)}\right|_{z=-i}
- \left. \text{Res } \frac{z\,\text{Log }z}{(z^2+1)(z+2)}\right|_{z=-2}.$$
$$ \int_0^\infty  \frac{x \, dx}{(x^2+1)(x+2)} = 
- \frac{ i (\frac{i\pi}{2})}{2i(2+i)}
- \frac{ (-i) (\frac{3\pi i}{2})}{(-2i)(2-i)}
+ \frac{2(\log 2 + \pi i)}{5}.$$
After simplifying, we get
$$\int_0^\infty  \frac{x \, dx}{(x^2+1)(x+2)}=\frac{\pi}{10}  + \frac{2 \ln 2}{5}.$$
This agrees with the result you quoted from Mathematica.
