Evaluating $\int_{0}^{\infty} \frac{1}{a_{n}x^{n} + ... + a_{2}x^{2} + a_{o}}dx$ via Residue Theory?

Let $p(X)\in\mathbb{C}[X]$ be a polynomial of degree $n\geq 2$ whose roots are in $\mathbb{C}\setminus\mathbb{R}_{\geq 0}$. The goal is to evaluate $$I:=\int_0^\infty\,\frac{1}{p(x)}\,\text{d}x\,.$$ Let $z_1,z_2,\ldots,z_k\in\mathbb{C}$ be all pairwise distinct roots of $p(X)$, respectively, with multiplicities $m_1,m_2,\ldots,m_k$ (whence $n=m_1+m_2+\ldots+m_k$). Define $f:\left(\mathbb{C}\setminus\mathbb{R}_{\geq 0}\right)\to\mathbb{C}$ to be the holomorphic function $$f(z):=\frac{\ln(z)}{p(z)}\text{ for all }z\in\left(\mathbb{C}\setminus\mathbb{R}_{\geq 0}\right)\,.$$ Here, for a complex number $z\in\left(\mathbb{C}\setminus \mathbb{R}_{\ge0}\right)$, we write $z=r\,\exp(\text{i}\phi)$ with $\phi\in(0,2\pi)$ and $r>0$, and then define $$\ln(z):=\ln(r)+\text{i}\phi\,,$$ so that the branch cut is $\mathbb{R}_{\geq 0}$. For $\epsilon\in(0,1)$, set $$J(\epsilon):=\oint_{\Gamma_{\epsilon}}\,f(z)\,\text{d}z\,,$$ where $\Gamma_{\epsilon}$ is the positively oriented keyhole contour given by $$\begin{align}\Biggr[\epsilon\,\exp(+\text{i}\epsilon),\frac{1}{\epsilon}\,\exp(+\text{i}\epsilon)\Biggl]&\cup\Biggl\{\frac{1}{\epsilon}\,\exp(\text{i}\theta)\,\Big|\,\theta\in[\epsilon,2\pi-\epsilon]\Biggr\}\\&\cup\Biggr[\frac1\epsilon\,\exp(-\text{i}\epsilon),{\epsilon}\,\exp(-\text{i}\epsilon)\Biggl]\cup\Biggl\{{\epsilon}\,\exp(\text{i}\theta)\,\Big|\,\theta\in[2\pi-\epsilon,\epsilon]\Biggr\}\,.\end{align}$$

Observe that $$\lim_{\epsilon\to0^+}\,J(\epsilon)=-2\pi\text{i}\,I\,.$$ By the Residue Theorem, $$\lim_{\epsilon\to0^+}\,J(\epsilon)=2\pi\text{i}\,\sum_{j=1}^k\,\text{Res}_{z=z_j}\big(f(z)\big)\,.$$ Hence, $$I=-\sum_{j=1}^k\,\text{Res}_{z=z_j}\big(f(z)\big)\,.$$ Since $$\begin{align}\text{Res}_{z=z_j}\big(f(z)\big)&=\frac{1}{\left(m_j-1\right)!}\,\lim_{z\to z_j}\,\frac{\text{d}^{m_j-1}}{\text{d}z^{m_j-1}}\,\Big(\left(z-z_j\right)^{m_j}\,f(z)\Big)\\&=\frac{1}{\left(m_j-1\right)!}\,\lim_{z\to z_j}\,\frac{\text{d}^{m_j-1}}{\text{d}z^{m_j-1}}\,\left(\frac{\left(z-z_j\right)^{m_j}\,\ln(z)}{p(z)}\right)\end{align}$$ for $j=1,2,\ldots,k$, we conclude that $$I=-\sum_{j=1}^k\,\frac{1}{\left(m_j-1\right)!}\,\lim_{z\to z_j}\,\frac{\text{d}^{m_j-1}}{\text{d}z^{m_j-1}}\,\left(\frac{\left(z-z_j\right)^{m_j}\,\ln(z)}{p(z)}\right)\,.\tag{*}$$ In particular, if $m_j=1$ for all $j=1,2,\ldots,k$, then $k=n$ and $$I=-\sum_{j=1}^n\,\frac{\ln\left(z_j\right)}{p'\left(z_j\right)}\,.\tag{$\star$}$$

For example, let $p(X):=\left(X^2+1\right)^2\,(X+1)$. You can see that the partial fraction decomposition gives $$\int\,\frac{1}{p(x)}\,\text{d}x=\frac{1}{8}\,\left(\frac{2\,(x+1)}{x^2+1}-\ln\left(x^2+1\right)+2\,\ln(x+1)+4\,\arctan(x)\right)+\text{constant}\,,$$ so that $$I=\int_0^\infty\,\frac{1}{p(x)}\,\text{d}x=\frac{1}{4}\,(\pi-1)\,.$$ You can also use (*) to compute $I$. Let $z_1=-1$, $z_2=+\text{i}$, and $z_3=-\text{i}$, so that $m_1=1$, $m_2=2$, and $m_3=2$. Then, $$\frac{1}{\left(m_1-1\right)!}\,\lim_{z\to z_1}\,\frac{\text{d}^{m_1-1}}{\text{d}z^{m_1-1}}\,\left(\frac{\left(z-z_1\right)^{m_1}\,\ln(z)}{p(z)}\right)=\lim_{z\to -1}\,\frac{\ln(z)}{\left(z^2+1\right)^2}=\frac{\pi\text{i}}{4}\,,$$ $$\begin{align}\frac{1}{\left(m_2-1\right)!}\,\lim_{z\to z_2}\,\frac{\text{d}^{m_2-1}}{\text{d}z^{m_2-1}}\,\left(\frac{\left(z-z_2\right)^{m_2}\,\ln(z)}{p(z)}\right)&=\lim_{z\to +\text{i}}\,\frac{\text{d}}{\text{d}z}\,\frac{\ln(z)}{(z+\text{i})^2\,(z+1)}\\&=\frac{1+\pi}{8}-\text{i}\,\left(\frac{\pi-2}{16}\right)\,,\end{align}$$ and $$\begin{align}\frac{1}{\left(m_3-1\right)!}\,\lim_{z\to z_3}\,\frac{\text{d}^{m_3-1}}{\text{d}z^{m_3-1}}\,\left(\frac{\left(z-z_3\right)^{m_3}\,\ln(z)}{p(z)}\right)&=\lim_{z\to -\text{i}}\,\frac{\text{d}}{\text{d}z}\,\frac{\ln(z)}{(z-\text{i})^2\,(z+1)}\\&=\frac{1-3\pi}{8}-\text{i}\,\left(\frac{3\pi+2}{16}\right)\,.\end{align}$$ Hence, $$I=-\left(\frac{\pi\text{i}}{4}+\left(\frac{1+\pi}{8}-\text{i}\,\left(\frac{\pi-2}{16}\right)^{\vphantom{a^a}}\right)+\left(\frac{1-3\pi}{8}-\text{i}\,\left(\frac{3\pi+2}{16}\right)^{\vphantom{a^a}}\right)^{\vphantom{a^a}}\right)=\frac{\pi-1}{4}\,.$$


In fact, if $m_j=1$ for all $j=1,2,\ldots,k$ (so $k=n$), then it follows that $$\frac{1}{p(x)}=\sum_{j=1}^n\,\frac{1}{p'\left(z_j\right)\,\left(x-z_j\right)}\,.$$ Without loss of generality, we assume that $$\text{arg}\left(z_1\right)\geq \text{arg}\left(z_2\right) \geq \ldots \geq \text{arg}\left(z_n\right)\,,$$ wher $\text{arg}(z)$ is the argument of $z\in\left(\mathbb{C}\setminus\mathbb{R}_{\geq 0}\right)$ in the interval $(0,2\pi)$. Because $$\sum_{j=1}^n\,\frac{1}{p'\left(z_j\right)}=\lim_{x\to\infty}\,\frac{x}{p(x)}=0\,,$$ we can write $$\frac{1}{p(x)}=\sum_{j=1}^{n-1}\,\frac{1}{p'\left(z_j\right)}\,\left(\frac{1}{x-z_j}-\frac{1}{x-z_n}\right)\,.$$ That is, $$\int\,\frac{1}{p(x)}\,\text{d}x=\sum_{j=1}^{n-1}\,\frac{1}{p'\left(z_j\right)}\,\ln\left(\frac{x-z_j}{x-z_n}\right)+\text{constant}=\sum_{j=1}^n\,\frac{1}{p'\left(z_j\right)}\,\ln\left(x-z_j\right)+\text{constant}\,,$$ whence $$\int_0^\infty\,\frac{1}{p(x)}\,\text{d}x=-\sum_{j=1}^{n-1}\,\frac{1}{p'\left(z_j\right)}\,\ln\left(\frac{z_j}{z_n}\right)=-\sum_{j=1}^{n}\,\frac{\ln\left(z_j\right)}{p'\left(z_j\right)}\,.$$ For example, one can evaluate $$\int_0^\infty\,\frac{1}{(x+2)(x+3)}\,\text{d}x$$ to be $$-\left(\frac{\ln(-2)}{(-2+3)}+\frac{\ln(-3)}{(-3+2)}\right)=\ln\left(\frac{3}{2}\right)\,.$$


If $s(X)\in\mathbb{C}[X]$ is a polynomial of degree at most $n-2$ such that $p(X)$ and $s(X)$ do not share a common factor, then $$\int_0^\infty\,\frac{s(x)}{p(x)}\,\text{d}x$$ can be evaluated in the same way. That is, we have $$\int_0^\infty\,\frac{s(x)}{p(x)}\,\text{d}x=-\sum_{j=1}^k\,\frac{1}{\left(m_j-1\right)!}\,\lim_{z\to z_j}\,\frac{\text{d}^{m_j-1}}{\text{d}z^{m_j-1}}\,\left(\frac{\left(z-z_j\right)^{m_j}\,\ln(z)\,s(z)}{p(z)}\right)\,.$$ In particular, if $m_j=1$ for all $j=1,2,\ldots,k$ (so $k=n$), then $$\frac{s(x)}{p(x)}=\sum_{j=1}^n\,\frac{s\left(z_j\right)}{p'\left(z_j\right)\,\left(x-z_j\right)}$$ and so $$\int_0^\infty\,\frac{s(x)}{p(x)}\,\text{d}x=-\sum_{j=1}^n\,\frac{\ln\left(z_j\right)\,s\left(z_j\right)}{p'\left(z_j\right)}\,.$$


Let $p(X)\in\mathbb{C}[X]$ be a nonconstant polynomial whose roots are in $\mathbb{C}\setminus\mathbb{R}_{\geq 0}$. If $p(X)$ has only even powers of $X$ (i.e., $p(X)=q\left(X^2\right)$ for some nonconstant polynomial $q(X)\in\mathbb{C}[X]$), then the answer can be made simpler. Let $z_1,z_2,\ldots,z_l$ be the roots of $p(X)$ in the upper half plane $$\mathbb{H}^+:=\big\{z\in\mathbb{C}\,|\,\text{Im}(z)>0\big\}\,,$$ respectively, with multiplicities $m_1,m_2,\ldots,m_l$. (Thus, $p(X)$ also has $-z_1,-z_2,\ldots,-z_l$ as roots, respectively, with multiplicities $m_1,m_2,\ldots,m_l$. Ergo, $n=2\,\left(m_1+m_2+\ldots+m_l\right)$, where $n$ is the degree of $p(X)$, which must be an even positive integer.)

For $R>0$, consider the contour positively oriented contour $C_R$ given by $$[-R,+R]\cup\big\{R\,\exp(\text{i}t)\,\big|\,t\in[0,\pi]\big\}\,.$$ Let $$I:=\int_0^\infty\,\frac{1}{p(x)}\,\text{d}x\text{ and }K(R):=\oint_{C_R}\,\frac{1}{p(z)}\,\text{d}z\,.$$ Thus, $$2I=\lim_{R\to\infty}\,K(R)=2\pi\text{i}\,\sum_{j=1}^{l}\,\text{Res}_{z=z_j}\left(\frac{1}{p(z)}\right)\,.$$ Therefore, $$I=\pi\text{i}\,\sum_{j=1}^l\,\frac{1}{\left(m_l-1\right)!}\,\lim_{z\to z_j}\,\frac{\text{d}^{m_j-1}}{\text{d}z^{m_j-1}}\,\frac{\left(z-z_j\right)^{m_j}}{p(z)}\,.\tag{$\square$}$$ In particular, if $m_j=1$ for every $j=1,2,\ldots,l$, then we get $l=\dfrac{n}{2}$ and $$I=\pi\text{i}\,\sum_{j=1}^{\frac{n}{2}}\,\frac{1}{p'\left(z_j\right)}=\frac{\pi\text{i}}{2}\,\sum_{j=1}^{\frac{n}{2}}\,\frac{1}{z_j\,q'\left(z_j^2\right)}\,.\tag{#}$$ Note that (#) can be proven by ($\star$) from my other answer. Similarly, ($\square$) also follows from (*).

For example, if $p(X)=\left(X^2+1\right)\,\left(X^2+4\right)$, then $q(X)=(X+1)\,(X+4)$. You can use the partial fraction decomposition to get $$\int\,\frac{1}{p(x)}\,\text{d}x=\frac{1}{6}\,\Biggl(2\,\arctan(x)-\arctan\left(\frac{x}{2}\right)\Biggr)+\text{constant}\,,$$ so that $$I=\int_0^\infty\,\frac{1}{p(x)}\,\text{d}x=\frac{\pi}{12}\,.$$ However, using (#), we get $$I=\frac{\pi\text{i}}{2}\,\left(\frac{1}{\text{i}\cdot 3}+\frac{1}{2\text{i}\cdot(-3)}\right)=\frac{\pi}{12}\,.$$

On the other hand, if $p(X)=\left(X^2+1\right)^3$, then we need to use ($\square$). Note that $l=1$, with $z_1=\text{i}$ and $m_1=3$. Hence, $$I=\int_0^\infty\,\frac{1}{\left(x^2+1\right)^3}\,\text{d}x$$ equals $$\frac{\pi\text{i}}{2!}\,\lim_{z\to\text{i}}\,\frac{\text{d}^2}{\text{d}z^2}\,\frac{1}{(z+\text{i})^3}=\frac{\pi\text{i}}{2}\,\left(\frac{12}{(2\text{i})^5}\right)=\frac{3\pi}{16}\,.$$ Using the partial fraction decomposition yields $$\int\,\frac{1}{p(x)}\,\text{d}x=\frac{1}{8}\,\left(\frac{x\,\left(3\,x^2+5\right)}{\left(x^2+1\right)^2}+3\,\arctan(x)\right)+\text{constant}\,,$$ so we get the same answer $I=\dfrac{3\pi}{16}$.


Indeed, if $m_j=1$ for every $j=1,2,\ldots,l$ (so $l=\dfrac{n}{2}$), then $$\frac{1}{p(x)}=\sum_{j=1}^{\frac{n}{2}}\,\frac{2\,z_j}{p'\left(z_j\right)\,\left(x^2-z_j^2\right)}=\sum_{j=1}^{\frac{n}{2}}\,\frac{1}{q'\left(z_j^2\right)\,\left(x^2-z_j^2\right)}\,.$$ This provides an alternative proof of (#).


If $s(X)\in\mathbb{C}[X]$ is a polynomial of degree at most $n-2$ such that $p(X)$ and $s(X)$ do not have a common factor, and if $s(X)$ only has even-degree terms (namely, $s(X)=u\left(X^2\right)$ for some $u(X)\in\mathbb{C}[X]$), then we also have $$\int_0^\infty\,\frac{s(x)}{p(x)}\,\text{d}x=\pi\text{i}\,\sum_{j=1}^l\,\frac{1}{\left(m_l-1\right)!}\,\lim_{z\to z_j}\,\frac{\text{d}^{m_j-1}}{\text{d}z^{m_j-1}}\,\frac{\left(z-z_j\right)^{m_j}\,s(z)}{p(z)}\,.$$ In particular, if $m_j=1$ for every $j=1,2,\ldots,l$, then $l=\dfrac{n}{2}$ and $$\int_0^\infty\,\frac{s(x)}{p(x)}\,\text{d}x=\pi\text{i}\,\sum_{j=1}^{\frac{n}{2}}\,\frac{s\left(z_j\right)}{p'\left(z_j\right)}=\frac{\pi\text{i}}{2}\,\sum_{j=1}^{\frac{n}{2}}\,\frac{u\left(z_j^2\right)}{z_j\,q'\left(z_j^2\right)}\,.$$


Assume $P(x)$ and $Q(x)$ are polynomials with real coefficients and

I. $$ deg(P(x))\leq deg(Q(x))-2 $$ and

II. $Q(x)$ have no roots $z_j$ in $\textbf{R}=(-\infty,+\infty)$.

Assume that $c$ is a simple closed curve that contains all roots in the upper plane and $\gamma_R$ is the sigment $[-R,R]$, $R>0$, along with $$ \delta(R):=\left\{z\in\textbf{C}:|z|=R\textrm{ and }0\leq arg(z)\leq \pi \right\}, $$ then if $\gamma_R$ encloses $c$, we can write:
$$ \oint_c\frac{P(z)}{Q(z)}dz=\int_{\gamma_R}\frac{P(z)}{Q(z)}dz=\int^{R}_{-R}\frac{P(x)}{Q(x)}dx+\int_{\delta(R)}\frac{P(z)}{Q(z)}dz $$ From (I) exist $M>0$ and $z_0\in \textbf{C}$ such that
$$ \left|\frac{P(z)}{Q(z)}\right|\leq \frac{M}{|z|^2}\textrm{, }\forall |z|>|z_0|. $$ Hence $$ \lim_{z\rightarrow \infty}\left|\int_{\gamma_R}\frac{P(z)}{Q(z)}dz\right|\leq \lim_{z\rightarrow \infty}\int_{\gamma_R}\left|\frac{P(z)}{Q(z)}\right||dz|\leq \lim_{R\rightarrow \infty}\frac{M}{R^2}\int_{\gamma}|dz|= $$ $$ =\lim_{R\rightarrow \infty}\frac{M}{R^2}\pi R=0. $$ Hence $$ \int^{R}_{-R}\frac{P(x)}{Q(x)}dx+\int_{\delta(R)}\frac{P(z)}{Q(z)}dz=\oint_{c}\frac{P(z)}{Q(z)}dz=2\pi i\sum^{n}_{j=1}Res\left[\frac{P(z)}{Q(z)},z_j\right], $$ where $z_j$ are the roots of $Q(z)=0$ in the upper plane. Taking the limit $R\rightarrow +\infty$, we arive to $$ \int^{\infty}_{-\infty}\frac{P(x)}{Q(x)}dx=2\pi i\sum^{n}_{j=1}Res\left[\frac{P(z)}{Q(z)},z_j\right], $$ which is the desired result.

Note that $n$ are the number of distinct roots (without counting multiplicity) in the upper plane.

If we set $R(z):=\frac{P(z)}{Q(z)}$, then

i) If $z_0$ is a pole of first class, we have $$ Res\left[R(z),z_0\right]=\lim_{z\rightarrow z_0}\left((z-z_0)R(z)\right). $$

ii) If $z_0$ is a pole of higher class$-k$, where $k$ integer greater than 1, then $$ Res\left[R(z),z_0\right]=\frac{1}{(k-1)!}\lim_{z\rightarrow z_0}\left(\frac{d^{k-1}}{dz^{k-1}}(z-z_0)^k R(z)\right). $$

CONTINUING NOTE.

Assume now the differential equation $$ y'(x)=\sum^{N}_{n=1}a_ny(x)^n=H(y(x)) $$ This differential equation have solution $$ x+C=\sum_{\rho/H}\frac{\log(y(x)-\rho)}{H'(\rho)}, $$ where the summation is taken over all roots of $H(x)=0$, (here $H$ is a simple polynomial function). If we invert $y$ we get $$ y^{(-1)}(x)=\int\frac{1}{H(x)}dx=\sum_{\rho/H}\frac{\log(x-\rho)}{H'(\rho)}. $$ Hence given a polynomial $H(x)$, with simple roots$-\rho$, then $$ \int\frac{1}{H(x)}dx=\sum_{\rho/H}\frac{\log(x-\rho)}{H'(\rho)}+C_1 $$ Now I use a lemma

Lemma (Mathematical Olympiad, Poland 1979)

Let $H(x)$ be a polynomial of degree $N>1$ with simple distinct roots $\rho_1,\rho_2,\ldots,\rho_N$. Then $$ \sum_{\rho/H}\frac{1}{H'(\rho)}=0. $$

From the above lemma we have $$ S(h):=\sum_{\rho/H}\frac{\log(h-\rho)}{H'(\rho)}=\sum^{N-1}_{k=1}\frac{\log(h-\rho_k)}{H'(\rho_k)}+\frac{1}{H'(\rho_N)}\log(h-\rho_N)= $$ $$ =\sum^{N-1}_{k=1}\frac{\log(h-\rho_k)}{H'(\rho_k)}-\sum^{N-1}_{k=1}\frac{1}{H'(\rho_k)}\log(h-\rho_N)=\sum^{N-1}_{k=1}\frac{\log(h-\rho_k)-\log(h-\rho_N)}{H'(\rho_k)} $$ From which (easily) one can see that $$ \lim_{h\rightarrow+\infty}S(h)=0. $$ Hence $$ \int^{\infty}_{0}\frac{dt}{H(t)}=-\sum_{\rho/H}\frac{\log(-\rho)}{H'(\rho)}. $$ $qed$

Hence knowing that $H(x)=a(x-\rho_1)(x-\rho_2)\ldots (x-\rho_N)$ is a polynomial with simple roots, then the following formula (1) give us the value of $$ \int^{\infty}_{0}\frac{dt}{a(t-\rho_1)(t-\rho_2)\ldots(t-\rho_N)}=-\sum^{N}_{k=1}\frac{\log(-\rho_k)}{H'(\rho_k)} $$