How do you Evaluate $\int_{-\infty}^\infty \frac{\cos(x)}{x^2+1}dx$ Without Using Residue Calculus

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|}}}$$


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


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}. $$