Evaluate $\int_{0}^{\infty} \frac{x^2+x+1}{x^6+x^4+1} dx$
Without complex analysis.
From a formal point of view, there is closed form solution.
Let $(a,b,c)$ to be the roots of $y^3+y^2+1=0$; one is real and negative (say $a$) and the other two $(b,c)$ are complex conjugate. $$\frac{x^2+x+1}{x^6+x^4+1}=\frac{x^2+x+1}{(x^2-a)(x^2-b)(x^2-c)}$$ Now, using partial fraction decomposition, the rhs write $$-\frac{1}{(a-b) (a-c) (b-c)}\left(\frac{(x+a+1) (c-b)}{x^2-a}+\frac{(b-a) (x+c+1)}{x^2-c}+\frac{(a-c) (x+b+1)}{x^2-b} \right)$$ So, we face three integrands of the form $$\frac{A+B x}{x^2-d}=\frac{A}{x^2-d}+\frac B 2\frac {2x}{x^2-d }$$ $$\int_0^t \frac{A+B x}{x^2-d}\,dx=-\frac{A}{\sqrt{d}}\tanh ^{-1}\left(\frac{t}{\sqrt{d}}\right)+\frac B 2 \log \left(1-\frac{t^2}{d}\right)$$ Now, the problem is to make $t\to \infty$ and to simplify.
The real solution is given by $$a=-\frac{1}{3} \left(1+2 \cosh \left(\frac{1}{3} \cosh ^{-1}\left(\frac{29}{2}\right)\right)\right)$$ I prefer to avoid typing the explicit solutions of$(b,c)$.
$\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)$$