How do you Evaluate $\int_{-\infty}^\infty \frac{\cos(x)}{x^2+1}dx$ Without Using Residue Calculus
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!
Here's a much nicer way using the standard differentiation under the integral sign technique. Let's first consider the general case$$I(a)=\int\limits_{-\infty}^{\infty}\frac {\cos ax}{1+x^2}\, dx$$Through integration by parts on $u=1/(1+x^2)$ and $dv=\cos ax\, dx$, we have$$a\cdot I(a)=2\int\limits_{-\infty}^{\infty}\frac {x\sin ax}{(1+x^2)^2}\, dx$$Differentating with respect to $a$, we obtain$$a\cdot I'(a)+I(a)=2I(a)-2\int\limits_{-\infty}^{\infty}\frac {\cos ax}{(1+x^2)^2}\, dx$$Combining like terms, we realize that the right-hand side is similar to what we obtained before. So differentiating (again), we finally see that$$a\cdot I''(a)=-2\int\limits_{-\infty}^{\infty}\frac {x\sin ax}{(1+x^2)^2}\, dx=a\cdot I(a)$$Solving the simple differential equation that follows, the general solution is $I(a)=C_1e^{a}+C_2e^{-a}$. When we set $a=0$, we see that $C_1=0$ and similarly, $C_2=\pi$ for $a\to\infty$. Therefore, the general solution is$$\int\limits_{-\infty}^{\infty}\frac {\cos ax}{1+x^2}\, dx=\color{blue}{\frac {\pi}{e^{|a|}}}$$
Step 1. Let $s > 0$ and $\beta \in \mathbb{C}$. Then using the gaussian integral $\int_{-\infty}^{\infty} e^{-sx^2} \, dx = \sqrt{\pi/s}$, we have
\begin{align*} \int_{-\infty}^{\infty} e^{-s(x-\beta)^2} \, dx &= \int_{-\infty}^{\infty} \bigg( e^{-sx^2} + \int_{0}^{1} \overbrace{ 2s\beta(x-\beta t) e^{-s(x-\beta t)^2} }^{= \frac{\partial}{\partial t} e^{-s(x-\beta t)^2}} \, dt \bigg) \, dx \\ &= \sqrt{\frac{\pi}{s}} -\beta \int_{0}^{1} \int_{-\infty}^{\infty} (-2s)(x-\beta t) e^{-s(x-\beta t)^2} \, dx dt \quad {\small(\because\text{Fubini})}\\ &= \sqrt{\frac{\pi}{s}} -\beta \int_{0}^{1} \left[ e^{-s(x-\beta t)^2} \right]_{x=-\infty}^{x=\infty} \, dt = \bbox[border:1px dashed green,6px]{ \sqrt{\frac{\pi}{s}} }. \end{align*}
Then plugging $\beta=\pm\mathrm{i}/2s$, we check that
$$ \int_{-\infty}^{\infty} e^{-sx^2}\cos(x) \, dx = \sqrt{\frac{\pi}{s}} e^{-1/4s}. $$
Step 2. Using the previous step,
\begin{align*} I := \int_{-\infty}^{\infty} \frac{\cos x}{x^2+1} \, dx &= \int_{-\infty}^{\infty} \cos x \left( \int_{0}^{\infty} e^{-(x^2+1)s} \, ds \right) \, dx \\ &= \int_{0}^{\infty} \left( \int_{-\infty}^{\infty} e^{-sx^2}\cos(x) \, dx \right) e^{-s} \, ds \quad {\small(\because\text{Fubini})}\\ &= \int_{0}^{\infty} \sqrt{\frac{\pi}{s}} e^{-\left( s + \frac{1}{4s}\right)} \, ds \\ &= \int_{0}^{\infty} \sqrt{2\pi} e^{-\frac{1}{2}\left( t^2 + \frac{1}{t^2}\right)} \, dt. \quad {\small(2s=t^2)} \end{align*}
Finally here is a very slick way of computing the last integral. Applying the substitution $t\mapsto 1/t$ shows that
$$ \int_{0}^{\infty} e^{-\frac{1}{2}\left( t^2 + \frac{1}{t^2}\right)} \, dt = \int_{0}^{\infty} \frac{1}{t^2} e^{-\frac{1}{2}\left( t^2 + \frac{1}{t^2}\right)} \, dt. $$
So averaging,
$$ I = \sqrt{\frac{\pi}{2}} \int_{0}^{\infty} \left(1 + \frac{1}{t^2}\right) e^{-\frac{1}{2}\left( t - \frac{1}{t}\right)^2 - 1} \, dt. $$
Finally, applying the substitution $u = t - \frac{1}{t}$ proves
$$ I = \sqrt{\frac{\pi}{2}} \int_{-\infty}^{\infty} e^{-\frac{u^2}{2} - 1} \, du = \frac{\pi}{e}. $$
Do you know the Fourier inversion theorem ? $$\frac{2}{1+x^2} = \int_{-\infty}^\infty e^{-|t|}e^{i x t}dt$$ where $\frac{d}{dt} e^{-|t|} \in L^1$ thus $$\int_{-\infty}^\infty \frac{2 e^{-i xu}}{1+x^2}dx = \lim_{A \to \infty} \int_{-A}^A e^{-ixu} (\int_{-\infty}^\infty e^{-|t|}e^{i x t}dt)dx=\lim_{A \to \infty}\int_{-\infty}^\infty e^{-|t|} A\frac{\sin(A(t-u))}{A(t-u)}dt$$ which converges to $2\pi e^{-|u|}$ by integration by parts
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!