Calculate $\int_{-\infty}^{\infty}\frac{\cos^{3}x}{x^2+1}\mathrm{d}x$ with the help of complex function

cauchy-principal-valuecomplex-analysisimproper-integralsresidue-calculus

I have met this improper integral:
$$\int_{-\infty}^{\infty}\frac{\cos^{3}x}{x^2+1}\mathrm{d}x$$

I tried to use residues but it doesn't work. The singularity point of function $f(z)=\frac{\cos^{3}z}{1+z^2}$ is obviously $i$ and $-i$. It is the first time I met this sort of integral. Can I calculate this with Cauchy principal value? Would you please give me some tips? Or what can I do when I meet this kind of integral again?

Best Answer

$$ \begin{align} \int_{-\infty}^\infty\frac{\cos^3(x)}{x^2+1}\,\mathrm{d}x &=\frac18\int_{-\infty}^\infty\frac{e^{3ix}+3e^{ix}+3e^{-ix}+e^{-3ix}}{x^2+1}\,\mathrm{d}x\tag{1a}\\ &=\frac18\int_{H_+}\frac{e^{3iz}+3e^{iz}}{z^2+1}\,\mathrm{d}z+\frac18\int_{H_-}\frac{3e^{-iz}+e^{-3iz}}{z^2+1}\,\mathrm{d}z\tag{1b}\\ &=\frac{2\pi i}8\left(\frac{e^{-3}+3e^{-1}}{2i}\right)-\frac{2\pi i}8\left(\frac{3e^{-1}+e^{-3}}{-2i}\right)\tag{1c}\\ &=\frac\pi4\,\frac{3e^2+1}{e^3}\tag{1d} \end{align} $$ Explanation:
$\text{(1a):}$ $\cos(x)=\frac{e^{ix}+e^{-ix}}2$
$\text{(1b):}$ $H_+=[-R,R]\cup Re^{+\pi i[0,1]}$ (counterclockwise around the upper half-plane)
$\phantom{\text{(1b):}}$ $H_-=[-R,R]\cup Re^{-\pi i[0,1]}$ (clockwise around the lower half-plane)
$\phantom{\text{(1b):}}$ the integrals along the circular arcs vanish as $R\to\infty$
$\text{(1c):}$ account for the residues and directions of the contours around $i$ and $-i$
$\text{(1d):}$ simplify