<s>[INST] 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?
 [/INST] 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}$$
</s>