How to calculate $\int_{-\infty}^\infty\frac{x^2+2x}{x^4+x^2+1}dx$? I want to calculate the following integral: $$I:=\displaystyle\int_{-\infty}^\infty\underbrace{\frac{x^2+2x}{x^4+x^2+1}}_{=:f(x)}dx$$ Of course, I could try to determine $\int f(x)\;dx$ in terms of integration by parts. However, I don't think that's the way one should do this. So, what's the trick to calculate $I$?
 A: Notice $$\frac{x^2+2x}{\color{blue}{x^4+x^2+1}}
= \frac{x(x+2)}{\color{blue}{(x^2+1)^2-x^2}} =
\frac12\left(\frac{x+2}{x^2-x+1} - \frac{x+2}{x^2+x+1}\right)\\
= \frac12\left(\frac{(x-\frac12)+\frac52}{(x-\frac12)^2+\frac34}
- \frac{(x+\frac12)+\frac32}{(x+\frac12)^2+\frac34}
\right)
$$
Plug this into original integral will split it into two pieces.
Change variables to $y = x \mp \frac12$ for the two new integrals.
After throwing away terms that will get cancel out due to symmetry, i.e. the $y$ term in the numerators, we get
$$\int_{-\infty}^\infty \frac{x^2+2x}{x^4+x^2+1}
=\frac12\left(\frac52-\frac32\right)\int_{-\infty}^{\infty} \frac{dy}{y^2+\frac34} =
\frac12\frac{\pi}{\sqrt{\frac34}} = \frac{\pi}{\sqrt{3}}$$
A: As noted in the comments, the integral is:
$$I=\int_{-\infty}^{\infty} \frac{x^2}{x^4+x^2+1}\,dx=2\int_0^{\infty} \frac{x^2}{x^4+x^2+1}\,dx\,\,\,(*)$$
With the change of variables $x\mapsto 1/x$, 
$$I=2\int_{0}^{\infty} \frac{1}{x^4+x^2+1}\,dx\,\,\,\,\,\,(**)$$
Add $(*)$ and $(**)$ i.e
$$2I=2\int_0^{\infty} \frac{1+x^2}{x^4+x^2+1}\,dx \Rightarrow I=\int_0^{\infty} \frac{1+\frac{1}{x^2}}{x^2+\frac{1}{x^2}+1}\,dx$$
Rewrite the denominator as $\left(x-\dfrac{1}{x}\right)^2+3$ and use the substitution $x-\dfrac{1}{x}=t$,
$$\Rightarrow I=\int_{-\infty}^{\infty} \frac{dt}{t^2+3}=\boxed{\dfrac{\pi}{\sqrt{3}}}$$
A: $$\int_{-\infty}^\infty\frac{x^2+2x}{x^4+x^2+1}dx$$
$$f(x)=\frac{x^2+2x}{x^4+x^2+1}$$
$$\int_{-\infty}^\infty\frac{x^2+2x}{x^4+x^2+1}dx=2\pi i\sum_{\Im x_i>0} \text{Res}(f(x);x_i)$$
$$x_i=\left\{\sqrt[3]{-1},(-1)^{2/3}\right\}$$
so we get $$\left\{\frac{1}{12} \left(3-5 i \sqrt{3}\right),\frac{1}{4} i \left(\sqrt{3}+i\right)\right\}$$ as two residues.
$$
\therefore 2\pi i*-\frac{i}{2 \sqrt{3}}=\dfrac{\pi}{\sqrt{3}}
$$
