Calculating $\int_{-\infty}^{\infty}\frac{\cos x}{x^2+x+1}dx$ using the Residue Theorem

I am suposed to evaluate $$\int_{-\infty}^{\infty}\frac{\cos x}{x^2+x+1}dx$$ using $$f(z)=\frac{e^{iz}}{z^2+z+1}$$ My idea was to define a contour $$\gamma = [-R,R] \cup \alpha$$ where $$\alpha$$ is the upper semicircumference of radius $R$. But I am stuck here.


Solution 1:

For sufficiently large $R>0$, your contour encloses exactly one pole, namely the $\Im z>0$ root of $z^2+z+1$. Call it $w$, so the other root is $w^\ast$. Since$$\lim_{z\to w}\frac{z-w}{z^2+z+1}=\lim_{z\to w}\frac{1}{z-w^\ast}=\frac{1}{2i\Im w},$$the residue theorem implies the integral is$$2\pi i\frac{1}{2i\Im w}\Re\exp(iw)=\frac{\pi}{\Im w}\exp(-\Im w)\cos(\Re w),$$as long as we first prove one condition. This is the hard part: prove$$\lim_{R\to\infty}\int_0^\pi f(Re^{i\theta})iRe^{i\theta}d\theta=0.$$You should try that part on your own, but note it suffices to show$$\lim_{R\to\infty}\int_0^\pi R|f(Re^{i\theta})|d\theta=0.$$

Solution 2:

Some hints:

The polynomial $z^2+z+1$ has roots at $r_1=\frac{-1 + \sqrt{3}i}{2}$ and $r_2=\overline{r}_1$. If you are using the upper semicircle, then you need the residue at $r_1$. The idea is to take $$ z\mapsto \frac{e^{iz}}{(z-r_1)(z-r_2)} $$ and cancel out the $(z-r_2)$ term. This can be done if you expand $e^{iz}$ about $z=r_2$. In other words, write $e^{iz}=e^{ir_2}e^{i(z-r_2)}$. Then expand the power series and you end up with the residue of $r_1$.