Originally Posted by brenorocha
$\displaystyle \int_0^\infty \frac{\cos x}{x^2+a^2}\,dx$
Let $\displaystyle a>0.$

Define $\displaystyle x=au,$ the integral becomes to $\displaystyle \frac{1} {a}\int_0^\infty {\frac{{\cos au}} {{u^2 + 1}}\,du} .$

Let $\displaystyle f(a) = \int_0^\infty {\frac{{\cos au}} {{u^2 + 1}}\,du} \implies f'(a) = - \int_0^\infty {\frac{{u\sin au}} {{u^2 + 1}}\,du} .$

Now

$\displaystyle \int_0^\infty {e^{ - \varphi u} \cos \varphi \,d\varphi } = \text{Re} \int_0^\infty {e^{ - (u - i)\varphi } \,d\varphi } = \text{Re} \,\frac{1} {{u - i}} = \frac{u} {{u^2 + 1}}.$

So

$\displaystyle \int_0^\infty {\frac{{u\sin au}} {{u^2 + 1}}\,du} = \int_0^\infty {\int_0^\infty {e^{ - \varphi u} \sin (au)\cos \varphi \,d\varphi } \,du} .$

Reverse integration order, so we have to find

$\displaystyle \int_0^\infty {e^{ - \varphi u} \sin (au)\,du} = \text{Im} \int_0^\infty {e^{ - (\varphi - ai)u} \,du} = \text{Im} \,\frac{1} {{\varphi - ai}} = \frac{a} {{\varphi ^2 + a^2 }}.$

From here $\displaystyle \int_0^\infty {\frac{{u\sin au}} {{u^2 + 1}}\,du} =\int_0^\infty {\frac{{a\cos \varphi }} {{\varphi ^2 + a^2 }}\,d\varphi } .$

One more substitution defined by $\displaystyle \varphi=a\tau,$

$\displaystyle \int_0^\infty {\frac{{a\cos \varphi }} {{\varphi ^2 + a^2 }}\,d\varphi } = \int_0^\infty {\frac{{\cos a\tau }} {{\tau ^2 + 1}}\,d\tau } = f(a).$

Then we have the following differential equation $\displaystyle f'(a)=-f(a),$ which is separable and easy to solve, so from here $\displaystyle f(a)=ke^{-a},$ where $\displaystyle k$ is a constant.

From the initial condition $\displaystyle f(0)=\frac\pi2,$ we have $\displaystyle k=\frac\pi2\implies f(a)=\frac{\pi e^{-a}}2.$

Since $\displaystyle f(a)=f(-a)\implies f(a)=\frac{\pi e^{-|a|}}2.$

And finally $\displaystyle \int_0^\infty \frac{\cos x}{x^2+a^2}\,dx=\frac{\pi e^{-|a|}}{2a}\,\blacksquare$