Calculate $\int_0^{\infty}\frac{1}{(x+1)(x-2)}dx$ using residues I'm supposed to calculate 
$$\int_0^{\infty}\frac{1}{(x+1)(x-2)}dx$$ 
using residues. The typical procedure on a problem like this would be to integrate a contour going around an upper-half semicircle of radius $R$, and come back through the real axis, taking two indents on the path at the points $z=-1$, $z=2$, say of radius $\rho_1,\rho_2$ respectively. Then the total integral around the path is $0$ and I can calculate the limits as $\rho_1,\rho_2\to0$ and $R\to\infty$ using the known formulas/theorems. However, this leaves me with $\int_{-\infty}^{\infty}\frac{1}{(x+1)(x-2)}dx$, instead of $0$ to $\infty$. And the function is not even so I can't just take half of the whole integral.
Does anybody know a way around this problem? Taking a path going a quarter around the circle and back down to the origin seems unnecessarily complicated, and I'm not even sure that would work here.
 A: The integrand function has a simple pole at $z=2$, hence the integral
$$ \int_{0}^{+\infty}\frac{dz}{(z+1)(z-2)}\,dx $$
is not converging in the usual Riemann- or Lebesgue-sense. However, if $\gamma_r$ is a key-hole contour from $0$ to $R\in(4,+\infty)$ in the right half-plane that avoids $z=2$ with a small semi-circular bulge having radius $r$, 

we may consider:
$$\begin{eqnarray*} \lim_{r\to 0}\oint_{\gamma_r}\frac{dz}{(z+1)(z-2)}&=&\frac{1}{3}\lim_{r\to 0}\oint_{\gamma_r}\left(\frac{1}{z-2}-\frac{1}{z+1}\right)\\&=&\frac{1}{3}\left(\int_{4}^{R}\frac{dz}{z-2}-\int_{0}^{R}\frac{dz}{z+1}\right)\\&=&\frac{1}{3}\left(\int_{2}^{R-2}\frac{dz}{z}-\int_{1}^{R+1}\frac{dz}{z}\right)\\&=&\frac{1}{3}\left(-\int_{1}^{2}\frac{dz}{z}-\int_{R-2}^{R+1}\frac{dz}{z}\right)\\&=&\color{red}{-\frac{\log 2}{3}}+O\left(\frac{1}{R}\right).\end{eqnarray*} $$
By letting $R\to +\infty$, we have that $\color{red}{-\frac{\log 2}{3}}$ is the principal value (PV) of the given integral.
A: Even if you are not familiar with Cauchy's principal value, you can see you integration as
$$\int_{0}^{\infty } \frac{\mathrm{d} x}{(x+1) (x-2)} = \lim_{\delta \to 0} \, \left(\int_0^{2-\delta} \frac{\mathrm{d} x}{(x+1) (x-2)} + \int_{2+\delta}^{\infty} \frac{\mathrm{d} x}{(x+1) (x-2)} \right),$$
Which is
$$\lim_{\delta \to 0} \, \left( \frac{1}{3} (\log (\delta +3)-\log (\delta )) + \frac{1}{3} (-\log (3-\delta )+\log (-\delta )- i \pi -\log (2)) \right).$$
Simplifying we have
$$\lim_{\delta \to 0} \,  \frac{1}{3} \left(\log \left(-\frac{\delta }{2}\right)-\log (\delta )+2 \tanh ^{-1}\left(\frac{\delta }{3}\right)-i \pi \right) = -\frac{\log (2)}{3}.$$
A: You use, as Jack said, a keyhole contour with bumps above and below the pos. real axis at $z=2$.  Thus, if $C$ is that keyhole contour with the bumps of radius $\epsilon$, we consider
$$\oint_C dz \frac{\log{z}}{(z+1)(z-2)}$$
which is equal to (assuming we have taken the radius of the large circular arc to go to $\infty$)
$$PV \int_0^{\infty} dx \frac{\log{x}}{(x+1)(x-2)} + i \epsilon \int_{\pi}^0 d\phi \, e^{i \phi} \frac{\log{(2+\epsilon e^{i \phi}})}{(3+ \epsilon e^{i \phi})(e^{i \phi})} \\ + PV \int_{\infty}^0 dx \frac{\log{x}+i 2 \pi}{(x+1)(x-2)} + i \epsilon \int_{2 \pi}^{\pi} d\phi \, e^{i \phi} \frac{\log{(2+\epsilon e^{i \phi})+i 2 \pi}}{(3+ \epsilon e^{i \phi})(e^{i \phi})} $$
The contour integral is equal to $i 2 \pi$ times the residue at the pole $z=e^{i \pi}$.  Thus,
$$-i 2 \pi PV \int_0^{\infty}  \frac{dx}{(x+1)(x-2)} - i 2 \pi \frac{\log{2}}{3} + \frac{2 \pi^2}{3} = i 2 \pi \frac{i \pi}{-3}$$
Therefore we now say that
$$PV \int_0^{\infty}  \frac{dx}{(x+1)(x-2)}  = - \frac{\log{2}}{3} $$
