# Solving integral using complex analysis

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?

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.
• Ah, yea, you're right, didnt realise that the cosine function is not bounded by $(-1,1)$ in the complex plane. When i rewrite the cosine function the numerator is $$e^{iRe^{i\phi}}+e^{-iRe^{i\phi}}=e^{...}+e^{-iR(cos\phi+i\sin{\phi})}$$ and the $e^{R\sin{\phi}}$ part blows up, i see it now. – Michal Dvořák Apr 2 '18 at 13:38
• You might find it helpful to google Louville's theorem - in fact no everywhere differentiable functions are bounded on $\mathbb{C}$ – Patrick Apr 2 '18 at 13:41