[Math] Solving integral using complex analysis

complex-analysiscontour-integrationdefinite integrals

I am looking to solve
$$I=\int_{-\infty}^{\infty}\frac{\cos{x}}{x^2+1}dx$$
To do so i defined a function of complex variable as follows:
$$f(z)=\frac{\cos{z}}{z^2+1}$$ Then i make a closed countour $C$ by uniting a semicircle (denoted $\gamma_R$) above the origin and a line connecting points $-R$ and $R$ on the real axis.
$$\oint_Cf(z)dz=\int_{-R}^{R}f(x)dx+\int_{\gamma_R}f(z)dz$$
The only pole within the contour is at $z=i$. By the residue theorem
$$\oint_Cf(z)dz=2\pi i\cdot \operatorname{Res}[f]_{z=i}$$
I use the definition of complex cosine:
$$\cos{z}=\frac{e^{iz}+e^{-iz}}{2}$$
$$\operatorname{Res}[f]_{z=i}=\lim_{z\to i}\bigg\{(z-i)\frac{e^{iz}+e^{-iz}}{2(z-i)(z+i)}\bigg\}=\frac{1/e+e}{4i}$$
My calculation then becomes:
$$I=\pi\frac{1/e+e}{2}-\int_{\gamma_R}f(z)dz$$
Now:
$$\int_{\gamma_R}f(z)dz=\int_{-R}^{R}f(Re^{i\phi})dRe^{i\phi}=\int_{-R}^{R}\frac{\cos{(Re^{i\phi})}}{R^2e^{2i\phi}+1}d\phi$$
as $R\to\infty$ this integral goes to zero (Jordan's Lemma??). I can conclude $$I=\pi\frac{e+1/e}{2}$$
But the answer should be $$\frac{\pi}{e}$$
I can't seem to find the mistake. I am pretty new to complex analysis, would anyone give me hint, what did i do wrong please?

Best Answer

The reason your method does not work is that the integral over $\gamma_R$ does not tend to zero as $R$ tends to infinity because $e^{-iz}$ blows up.

There is a standard trick here. Consider $\cos(\theta) = \operatorname{Re}(e^{i\theta})$ and integrate $\frac{e^{iz}}{1+z^2}$ instead. The integral of this over $\gamma_R$ is zero because $e^{iz}$ is bounded.

Related Question