Integral evaluation $\int_{-\infty}^{\infty} \frac{cos (ax)}{x^2+x+1} dx$ - not able to evaluate residue Integral evaluation $\int_{-\infty}^{\infty} \frac{cos (ax)}{x^2+x+1}  dx$, 
Here is my attempt: 
Replace cos (ax) with $e^{iaz}$, then take the real part such that: 
$\int_{-\infty}^{\infty} \frac{cos (ax)}{x^2+x+1}  dx = R.P[\int_{c}^{} \frac{e^{iaz}}{z^2+z+1}  dz]$ where c is the upper half circle. 
$\int_{c}^{} \frac{e^{iaz}}{z^2+z+1}  dz = 2\pi i Res[\frac{e^{iaz}}{z^2+z+1}, -1+\frac{i\sqrt{3}}{2}]$ (considering only the poles inside my contour )..
then I got stuck , how can I follow from here? 
 A: In this case, you can take the integral to be
$$\operatorname{Re}{\int_{-\infty}^{\infty} dx \frac{e^{i a x}}{x^2+x+1}} $$ 
Assume $a \gt 0$ for now.  The roots of the denominator are at $x_{\pm} = -\frac12 \pm i \frac{\sqrt{3}}{2} = e^{\pm i 2 \pi/3}$.  
Because we assumed $a \gt 0$, we consider the contour integral
$$\oint_C dz \frac{e^{i a z}}{z^2+z+1} $$
where $C$ is a semicircle in the upper half plane.  By the residue theorem, we need only consider the pole at $x_+$.  As the radius of the semicircle goes to infinity, we find that
$$\int_{-\infty}^{\infty} dx \frac{e^{i a x}}{x^2+x+1} = i 2 \pi \frac{e^{-\sqrt{3} a/2} e^{-i a/2}}{i \sqrt{3}} $$
Thus, when $a \gt 0$,
$$\int_{-\infty}^{\infty} dx \frac{\cos{a x}}{x^2+x+1} = \frac{2 \pi}{\sqrt{3}} e^{-\sqrt{3} a/2} \cos{\left ( \frac{a}{2} \right )} $$
When $a \lt 0$, we must use a contour in the lower-half plane.  In this case, we use the residue at the pole at $x_-$.  Thus, for all values of $a$:

$$\int_{-\infty}^{\infty} dx \frac{\cos{a x}}{x^2+x+1} = \frac{2 \pi}{\sqrt{3}} e^{-\sqrt{3} |a|/2} \cos{\left ( \frac{a}{2} \right )} $$

