TITLE: Calculating the integral $\int_0^\infty \frac{\cos x}{1+x^2}\, \mathrm{d}x$ without using complex analysis
QUESTION [109 upvotes]: Suppose that we do not know anything about the complex analysis (numbers). In this case, how to calculate the following integral in closed form?
$$\int_0^\infty\frac{\cos x}{1+x^2}\,\mathrm{d}x$$

REPLY [2 votes]: I am surprised nobody has written about Schwinger's method, which can be used to evaluate loop integrals in quantum field theory, and which nicely computes this integral in combination with Glasser's master theorem. First notice that the integral can be re-written as
$$\int_0^\infty \cos(x)\int_0^\infty e^{-u(1+x^2)}\,du\,dx.$$
Now, switch the order of integration and extend the range of one of the integral to the entire real line, gaining  a factor of $1/2$:
$$\frac{1}{2}\int_0^\infty e^{-u}\int_{-\infty}^\infty e^{-x^2+ix}\,dx\,du.$$
Complete the square in the exponential, and evaluate the now Gaussian integral (use the analyticity of $e^{-z^2}$ to bring the line of integration back to the real line) to obtain
$$\sqrt{\pi}\int_0^\infty \frac{du}{2\sqrt{u}}\,\exp-\left(u-\frac{1}{4u}\right).$$
The time is ripe for a substitution $x=\sqrt{u}$, bringing us to
$$\frac{\sqrt{\pi}}{2}e^{-1}\int_{-\infty}^\infty dx\, \exp-\left(x-\frac{1}{2x}\right)^2.$$
Glasser's master theorem  now tells us how to compute this last integral, reducing it to a Gaussian, and the original integral is just
$$\frac{\pi}{2}e^{-1}.$$