Evaluate the integral $\int\limits_{-\infty}^\infty \frac{\cos(x)}{x^2+1}dx$.
Evaluate the integral $\displaystyle\int\limits_{-\infty}^\infty \frac{\cos(x)}{x^2+1} dx$.
Hint: $\cos(x) = \Re(\exp(ix))$
Hi, I am confused that if I need to use the Residue Theorem in order to solve this, and I am not sure where I should start.
METHODOLOGY $1$: Complex Analysis
Note that the function $\frac{e^{iz}}{z^2+1}$ has poles at $\pm i$. Then, by Cauchy's Integral Formula we have for $R>1$
$$\begin{align} \oint_{C_R}\frac{e^{iz}}{z^2+1}\,dz&=\int_{-R}^R \frac{e^{ix}}{x^2+1}\,dx+\int_0^\pi \frac{e^{iRe^{i\phi}}}{(Re^{i\phi})^1+1}\,iRe^{i\phi}\,d\phi\tag1\\\\ &=2\pi i \frac{e^{i(i)}}{2i}\\\\ &=\pi/e \end{align}$$
As $R\to \infty$, the second integral on the right-hand side of $(1)$ approaches $0$. Therefore, we find that
$$\int_{-\infty}^\infty \frac{e^{ix}}{x^2+1}\,dx=\frac{\pi}{e} \tag2$$
Taking the real part of both sides of $(2)$ and exploiting the even symmetry yields
$$\bbox[5px,border:2px solid #C0A000]{\int_0^\infty \frac{\cos(x)}{x^2+1}\,dx=\frac{\pi}{2e}}$$
METHODOLOGY $2$: Real Analysis
Let $f(a)$ be given by the convergent improper integral
$$f(a)=\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx \tag3$$
Since the integral $\int_0^\infty \frac{x\sin(ax)}{x^2+1}\,dx$ is uniformly convergent for $|a|\ge \delta>0$, we may differentiate under the integral in $(3)$ for $|a|>\delta>0$ to obtain
$$\begin{align} f'(a)&=-\int_0^\infty \frac{x\sin(ax)}{x^2+1}\,dx\\\\ &=-\int_0^\infty \frac{(x^2+1-1)\sin(ax)}{x(x^2+1)}\,dx\\\\ &=-\int_0^\infty \frac{\sin(ax)}{x}\,dx+\int_0^\infty \frac{\sin(ax)}{x(x^2+1)}\,dx\\\\ &=-\frac{\pi}{2}+\int_0^\infty \frac{\sin(ax)}{x(x^2+1)}\,dx\tag4 \end{align}$$
Again, since the integral $\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx$ converges uniformly for all $a$, we may differentiate under the integral in $(4)$ to obtain
$$f''(a)=\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx=f(a)\tag 5$$
Solving the second-order ODE in $(5)$ reveals
$$f(a)=C_1 e^{a}+C_2 e^{-a}$$
Using $f(0)=\pi/2$ and $f'(0)=-\pi/2$, we find that $C_1=0$ and $C_2=\frac{\pi}{2}$ and hence $f(a)=\frac{\pi e^{-a}}{2}$. Setting $a=1$ yields the coveted result
$$\bbox[5px,border:2px solid #C0A000]{\int_0^\infty \frac{\cos(x)}{x^2+1}\,dx=\frac{\pi}{2e}}$$
as expected!
We may also see that $$I=\int_{-\infty}^{\infty}\frac{\cos\left(x\right)}{1+x^{2}}dx=2\int_{0}^{\infty}\frac{\cos\left(x\right)}{1+x^{2}}dx$$ $$ =\int_{0}^{\infty}\frac{e^{ix}+e^{-ix}}{1+x^{2}}dx=\frac{e^{-1}}{2}\left(\int_{0}^{\infty}\frac{e^{1+ix}+e^{1-ix}}{1+ix}dx+\int_{0}^{\infty}\frac{e^{1+ix}+e^{1-ix}}{1-ix}dx\right)$$ $$ =\frac{e^{-1}}{2i}\left(\int_{0}^{\infty}\frac{1}{x}\left(\frac{ixe^{1+ix}}{1+ix}+\frac{ixe^{1-ix}}{1-ix}\right)dx+\int_{0}^{\infty}\frac{1}{x}\left(\frac{ixe^{1-ix}}{1+ix}+\frac{ixe^{1+ix}}{1-ix}\right)dx\right)$$ and now applying the complex version of Frullani's theorem to the functions $$f\left(x\right)=\frac{xe^{1-x}}{1-x},\,g\left(x\right)=\frac{xe^{1-x}}{1+x}$$ we get $$I=\frac{e^{-1}}{i}\log\left(-1\right)=\color{red}{\pi e^{-1}}.$$
Use the Fourier transform: $$\frac{2}{\pi}\int_{-\infty}^{\infty}\frac{e^{i\nu x}}{x^{2}+1}dx=e^{-\left|\nu\right|}$$
Just set $\nu=1$, divide by $\frac{2}{\pi}$, and take the real part of both sides.