Any general methods to calculate integral of $P(x)/Q(x)$ from $0$ to $\infty$? In complex analysis, we have general formula for $P(x)/Q(x)$ [$P$ and $Q$ are polynomials] from minus infinity to infinity, if $ \deg Q - \deg P > 2$.
Is it possible to have a general formula for improper integral of P(x)/Q(x) from 0 to infinity? Like,
$$\int_0^{\infty} \frac{1}{1+x^3} \mathrm{d} x =\frac{2\pi}{3\sqrt{3}} $$
$$\int_0^{\infty} \frac{1}{1+x+x^2+x^3} \mathrm{d} x =\frac{\pi}{4}$$
$$\int_0^{\infty} \frac{1}{(x+1)(x+2)(x+3)} \mathrm{d} x=\frac{\ln(4/3)}{2}$$
 A: With residue calculus, put
$$
f(z) = \frac{P(z)}{Q(z)}\log z$$
where $log$ denotes the natural branch, i.e. with a branch cut along the positive real axis. Integrate over a keyhole contour:

Assuming that $\deg Q \ge 2+ \deg P$ and that $Q$ has no zero on the positive real axis, it's not hard to show that the integral over the big and large circle vanish as $R \to \infty$ and $\varepsilon \to 0$. What remains is (after some cancellation along the positive real axis):
$$
-2\pi i \int_{0}^{\infty} \frac{P(x)}{Q(x)}\,dx = 2\pi i \sum \operatorname{Res} \Big( \frac{P(z)\log z}{Q(z)} \Big)
$$
where the sum is taken over all poles of $P/Q$ (not just the ones in one half-plane). Remember to use the correct branch of $\log$ when you compute the residues.
Of course, if $P/Q$ happens to be even, you have a shorter solution.
Some concrete examples:


*

*Real integral by keyhole contour

*Is there an elementary method for evaluating $\int_0^\infty \frac{dx}{x^s (x+1)}$? (not a rational function, but same idea)

*Complex analysis and Residue theorem. (again not a rational function)

