TITLE: How do you Evaluate $\int_{-\infty}^\infty \frac{\cos(x)}{x^2+1}dx$ Without Using Residue Calculus
QUESTION [7 upvotes]: So I'm having trouble computing this integral:
$$\int_{-\infty}^\infty \frac{\cos(x)}{x^2+1}dx$$
After seeing some other answers on this website, I've realized that many people are using residues to get an answer. However, I know nothing about complex analysis, so I wanted to know if there is a better way of doing it without it.
I started by finding the indefinite integral which is:
$$-\dfrac{\sinh\left(1\right)\left(\operatorname{Si}\left(x+\mathrm{i}\right)+\operatorname{Si}\left(x-\mathrm{i}\right)\right)-\mathrm{i}\cosh\left(1\right)\left(\operatorname{Ci}\left(x+\mathrm{i}\right)-\operatorname{Ci}\left(x-\mathrm{i}\right)\right)}{2}$$
but finding what this function comes out to when finding the limit of it towards $\infty$ and $-\infty$ I get $-\pi\sinh(1)$
Now, I could be very wrong with both the indefinite integral and the value. Am I doing something wrong? Am I forgetting to take into account something I should be? Thanks in advanced!

REPLY [4 votes]: Let $f(a)$ be given by the convergent improper integral
$$f(a)=\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx \tag1$$ 
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 $(1)$ 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\tag2
\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 $(2)$ to obtain
$$f''(a)=\int_0^\infty \frac{\cos(ax)}{x^2+1}\,dx=f(a)\tag 3$$
Solving the second-order ODE in $(3)$ 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$ and exploiting even symmetry yields the coveted result
$$\bbox[5px,border:2px solid #C0A000]{\int_{-\infty}^\infty \frac{\cos(x)}{x^2+1}\,dx=\frac{\pi}{e}}$$
as expected!