TITLE: Evaluate $\int_{0}^{\infty} \frac{x^2+x+1}{x^6+x^4+1} dx$
QUESTION [6 upvotes]: $$\int_{0}^{\infty} \frac{x^2+x+1}{x^6+x^4+1} dx $$
Wolfram says $1.80276\ldots $
Calculating this seems complicated to me because the residues are pretty hard to find and I have tried the infinite residue method but it didn't work out.

REPLY [2 votes]: $\newcommand{\d}{\mathrm{d}}$
$\newcommand{\i}{\mathrm{i}}$
Split the integral $I$ as $I=I_0+I_1$
$$\begin{align}
I_0&=\int_0^{\infty}\frac{(x^2+1)\d x}{x^6+x^4+1} \\
I_1&=\int_0^{\infty}\frac{x\,\d x}{x^6+x^4+1}\text{.}
\end{align}$$
Replace $x\leftarrow 1/x$, $\d x \leftarrow -\d x /x^2$.
$$\begin{align}
I_0&=\int_0^{\infty}\frac{(x^4+x^2)\d x}{x^6+x^2+1} \\
I_1&=\int_0^{\infty}\frac{x^3\,\d x}{x^6+x^2+1}\text{.}
\end{align}$$
Replace $x\leftarrow \sqrt{x}$, $\d x \leftarrow \d x /(2\sqrt{x})$:
$$\begin{align}
I_0&=\frac{1}{2}\int_0^{\infty}\frac{(x+1)\sqrt{x}\,\d x}{x^3+x+1} \\
I_1&=\frac{1}{2}\int_0^{\infty}\frac{x\,\d x}{x^3+x+1}\text{.}
\end{align}$$
Let $H$ be the positive-oriented Hankel "keyhole" contour about the negative real axis, viz., the conventional branch cut of $\sqrt{x}$. Then
$$\begin{align}I_0&=\frac{1}{4\i}\oint_H\frac{(x-1)\sqrt{x}\d x}{x^3+x-1}\\
I_1&=\int_{-\infty}^0\frac{x\,\d x}{x^3+x-1}\text{.}
\end{align}$$

We make free use of standard notation for divided differences. Let $f$ and $g$ be analytic. Let $a$ be a simple root of $f$, and let $g$ be nonzero near $a$. Then
$$\frac{g(x)f'(a)}{f(x)}=\frac{g(a)}{x-a}+\frac{f'(a)g[x,a]-f[x,a,a]g(a)}{f[x,a]}$$
so that, if $a$ is the (unique, positive) real solution to $x^3+x-1$ guaranteed by the rule of signs,
$$\frac{g(x)(3a^2+1)}{x^3+x-1}=\frac{g(a)}{x-a}+\frac{(3a^2+1)g[x,a]-(x+2a)g(a)}{x^2+ax+a^2+1}$$
$$\begin{split}\frac{(3a^2+1)x}{x^3+x-1}&=\frac{a}{x-a}+\frac{a^2+1-ax}{x^2+ax+a^2+1}\\
&=\frac{a}{x-a}-\frac{a(x+\tfrac{a}{2})}{(x+\tfrac{a}{2})^2+\tfrac{3}{4}a^2+1}+\frac{\tfrac{3}{2}a^2+1}{(x+\tfrac{a}{2})^2+\tfrac{3}{4}a^2+1}
\end{split}$$
whence
$$\begin{split}I_1&=\frac{1}{3a^2+1}\left.\left(\tfrac{a}{2}\ln\frac{(x-a)^2}{x^2+ax+a^2+1}+\frac{\tfrac{3}{2}a^2+1}{\sqrt{\tfrac{3}{4}a^2+1}}\arctan \frac{x+\tfrac{a}{2}}{\sqrt{\tfrac{3}{4}a^2+1 }}\right)\right\rvert_{-\infty}^0 \\
&=\frac{1}{3a^2+1}\left(-\frac{a}{2}\ln\frac{a^2+1}{a^2}+\frac{3a^2+2}{\sqrt{3a^2+4}}\left(\frac{\pi}{2}+\arctan \frac{a}{\sqrt{3a^2+4 }}\right)\right) \end{split}$$

By the residue theorem and results above we know that (abbreviate $g(x)=(x-1)\sqrt{x}$)
$$\begin{split}I_0&=-\frac{\pi}{2}\sum_{r:r^3+r-1=0}\mathrm{Res}_r\frac{g(x)}{x^3+x-1}\\
&= -\frac{\pi}{2(3a^2+1)}\left(g(a)+\sum_{r:r^2+ar+a^2+1=0}\mathrm{Res}_r\frac{(3a^2+1)g[x,a]-(x+2a)g(a)}{x^2+ax+a^2+1}\right)\text{.}\end{split}$$
But for residues in the quadratic case,
$$(\mathrm{Res}_b+\mathrm{Res}_{b'})\frac{g(x)}{(x-b)(x-b')}=g[b,b']$$
so that if $b$ and $b'$ are the conjugate roots then
$$I_0= -\frac{\pi}{2(3a^2+1)}\left(g(a)+(3a^2+1)g[a,b,b']-g(a)\right)\text{.}$$
But
$$(3a^2+1)g[a,b,b']-g(a)=-g(b)-g(b')+g_a[b,b']$$
where $g_a(x)=(x-a)g(x)$ so
$$\begin{split}I_0&= -\frac{\pi}{2(3a^2+1)}\left(g(a)-g(b)-g(b')+g_a[b,b']\right)\\
&=-\frac{\pi}{2(3a^2+1)}\left(g(a)-2\Re g(b)+\frac{\Im b g(b)-a\Im g(b)}{\Im b}\right) \end{split}\text{.}$$
Using the half-angle formula, we can get an unambiguous expression in terms of $a$ and square roots:
$$I_0=-\frac{\pi}{2(3a^2+1)}\left((a-1)\sqrt{a} +\frac{-3a^2+6a+2-2\sqrt{1+a^2}(5a+4)}{3a^2+1}\sqrt{\tfrac{(\sqrt{1+a^2}+a/2)^3}{2}}\right)$$