Computing $\int_{-\infty}^{\infty}\frac{\cos(x)}{x^2 + x + 2} \, dx$ I wish to compute
$$\int_{-\infty}^{\infty}\frac{\cos(x)}{x^2 + x + 2} \, dx$$
The singularities are $\pm \frac{\sqrt{7}}{2}i  - \frac{1}{2}$
I then make a half-circle contour $C = \{Re^{it}, t \in [0,\pi], R \in [0,\infty) \}$
$$ \int_{-\infty}^{\infty} \frac{\cos(x)}{((x - (-\frac{\sqrt{7}i}{2} - \frac{1}{2}))(x - (\frac{\sqrt{7}i}{2} - \frac{1}{2}))} dx = \int_{C} \frac{\cos(x)}{((x - (-\frac{\sqrt{7}i}{2} - \frac{1}{2}))(x - (\frac{\sqrt{7}i}{2} - \frac{1}{2}))} dx$$
Is this correct so far?
Then we can apply Cauchy Integral Formula yes?
 A: We have $x^2+x+2 = (x+a)(x+b)$, where $a+b=1$ and $ab=2$. Hence, we have
$$\dfrac{\cos(x)}{x^2+x+2} = \dfrac{\cos(x)}{(x+a)(x+b)} = \dfrac1{b-a}\left(\dfrac{\cos(x)}{x+a} - \dfrac{\cos(x)}{x+b}\right)$$
Our integral is of the form
$$I = \dfrac1{b-a}\int_{-\infty}^{\infty}\left(\dfrac{\cos(x)}{x+a} - \dfrac{\cos(x)}{x+b}\right)dx = \dfrac{F(a) - F(b)}{b-a}$$
where $F(y) = \displaystyle\int_{-\infty}^{\infty} \dfrac{\cos(x)}{x+y}dx$. We have
$$F(y) = \int_{-\infty}^{\infty} \dfrac{\cos(t-y)}t dt = \cos(y)\int_{-\infty}^{\infty} \dfrac{\cos(t)}tdt + \sin(y)\int_{-\infty}^{\infty} \dfrac{\sin(t)}tdt$$
Note that the principal value of $\displaystyle \int_{-\infty}^{\infty} \dfrac{\cos(t)}tdt$ is zero, since the integrand is odd. This gives us
$$F(y) = \sin(y) \int_{-\infty}^{\infty} \dfrac{\sin(t)}tdt = \pi \sin(y)$$
Hence, we have
$$I = \pi \cdot \dfrac{\sin(a)-\sin(b)}{b-a}$$
A: No, you need to be more careful here: $\cos{z}$ does not decay on the curved arc, so you will be unable to calculate the integral by taking the radius to infinity. Instead, you'll want to look at the real part of
$$ f(z) = \frac{e^{iz}}{z^2+z+2}. $$
Clearly for $z=x$ real this is just
$$ \frac{\cos{x}}{x^2+x+2}, $$
and Jordan's lemma shows that the integral of $f(z)$ over the curved arc of your semicircle tends to zero. Now you can use the Cauchy integral formula on $f(z)$ on your semicircle to work with something you can calculate.
