Integral with logarithm - residue Let $R(x)$ be rational function. Is it any general method to calculate $\int_{0}^{\infty}R(x) \log(x)dx$ ? I can do it in special cases, but I am looking for a general method. What should be a minimal assumptions about $R(x)$ ?
 A: Consider the contour integral
$$\oint_C dz\, R(z) \log^2{z} $$
where $C$ is a keyhole contour of outer radius $r$ and inner radius $\epsilon$.  As long as $R$ is sufficiently well-behaved, the integrals about the circular arcs vanish as $r \to \infty$ and $\epsilon \to 0$.  Then in this limit, we have, by the residue theorem
$$-i 4 \pi \int_0^{\infty} dx \, R(x) \log{x} + 4 \pi^2 \int_0^{\infty} dx \, R(x) = i 2 \pi \sum_k \operatorname*{Res}_{z=z_k} R(z) \log^2{z} $$
where the $z_k$ are the poles of $R$.  Note that you still have to evaluate the integral over $R$.  However, this may be done similarly to the way we've done the present integral.  That is, we may find that
$$ \int_0^{\infty} dx \, R(x) =-\sum_k \operatorname*{Res}_{z=z_k} R(z) \log{z} $$
Now you have the integral only depending on the residues of the poles of $R$:

$$\int_0^{\infty} dx \, R(x) \log{x} = -\frac12 \sum_k \operatorname*{Res}_{z=z_k} R(z) \log^2{z} + i \pi \sum_k \operatorname*{Res}_{z=z_k} R(z) \log{z} $$

NB by "sufficiently behaved," we require that
$$\int_0^{2 \pi} d\theta \, \left | R \left ( re^{i \theta} \right ) \right | = o \left ( \frac1{r \log^2{r} } \right ) $$
ADDENDUM
This result may be simplified considerably assuming that $R(x) \in \mathbb{R}$.  Let's write out the poles $z_k = r_r e^{i \theta_k}$.  Then, combining the sums, we get
$$\int_0^{\infty} dx \, R(x) \log{x} = \sum_k \operatorname*{Res}_{z=r_k e^{i \theta_k}} R(z) \left [ \frac12 \left (\pi \theta_k -\theta_k^2 - \log^2{r_k} \right )  + i (\pi-\theta_k) \log{r_k}\right ] $$
The imaginary part of the above sum may be set to zero by observing that, when $R \in \mathbb{R}$, the poles either come in complex conjugate pairs, or $\theta_k = \pi$.  For the former case, the contributions cancel (remember, $\theta_k \in [0, 2 \pi)$; for the latter, they are zero.  Thus,

$$\int_0^{\infty} dx \, R(x) \log{x} = \frac12 \sum_k \left [ \operatorname*{Res}_{z=r_k e^{i \theta_k}} R(z) \right ] \left [\theta_k (\pi-\theta_k) - \log^2{r_k} \right ] $$

