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$?

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}}$$
