<s>[INST] Integral residue $\int_{0}^{\infty} {\frac{\cos\left(x\right)}{x^{2} + 2x + 4}}\,{\rm d}x. $ $$
\mbox{I have the integral:}\quad
\int_{0}^{\infty}
{\frac{\cos\left(x\right)}{x^{2} + 2x + 4}}\,{\rm d}x.
$$
I tried to use the residue theorem and semicircle and calculate the integral form minus infinity to infinity, but my function is not even. Do you have any hints $?$.
 [/INST] I suppose you are calculating
$$\int_{-\infty }^{\infty } \frac{\cos (z)}{z^2+2 z+4} \, dz=\frac{e^{-\sqrt{3}} \pi  \cos (1)}{\sqrt{3}}$$
Which can be done by integrating $\frac{e^{i z}}{z^2+2 z+4}$ along large upper semicircular contour, using Jordan's lemma, calculating residue at $-1+\sqrt{3} i$ and taking real part. For your original question,
$$\small \int_{0}^{\infty } \frac{\cos (z)}{z^2+2 z+4} \, dz=-\frac{i \text{Ci}\left(i \sqrt{3}+1\right) \cos \left(1+i \sqrt{3}\right)}{2 \sqrt{3}}+\frac{i \text{Ci}\left(1-i \sqrt{3}\right) \cos \left(1-i \sqrt{3}\right)}{2 \sqrt{3}}-\frac{i \text{Si}\left(i \sqrt{3}+1\right) \sin \left(1+i \sqrt{3}\right)}{2 \sqrt{3}}+\frac{i \text{Si}\left(1-i \sqrt{3}\right) \sin \left(1-i \sqrt{3}\right)}{2 \sqrt{3}}-\frac{\pi  \cos (1) \sinh \left(\sqrt{3}\right)}{2 \sqrt{3}}$$
Which can be done by shifting $z\to z-1$, expanding $\cos(z-1)$ into $\sin/\cos$ and factorizing $\frac{1}{z^2+3}$ into $\frac{1}{z\pm \sqrt{3}i}$ (for partial fractions), using N-L formula based on elementary formula that $\int \frac{\cos (z)}{z-a} \, dz=\cos (a) \text{Ci}(z-a)+\sin (a) \text{Si}(a-z)$ and its sine counterparts. No essential simplification seems to exist for this case, though.
</s>