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

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