# Show that $\int_0^\infty e^{-x^2/2}\cos(ax)\,dx=\frac 1 2 \sqrt{2 \pi} e^{-a^2/2}$ for $a\in \mathbb{R}$.

In my course of complex analysis I am asked to solve the following exercise:

Show that $\displaystyle \int_0^\infty e^{-x^2/2}\cos(ax) \, dx = \frac 1 2 \sqrt{2 \pi} e^{-a^2/2}$ for $a\in \mathbb{R}$.

I have tried using the integration methods by means of integration contours but I make many errors and I can not get the result.

HINT:

Write

\begin{align} e^{-x^2/2}\cos(ax)&=\text{Re}\left(e^{-x^2/2+iax}\right)\\\\ &=e^{-a^2/2}\text{Re}\left(e^{-\frac12(x-ia)^2}\right)\tag 1 \end{align}

Exploit the evenness of the integrand, use $(1)$, translate the argument by enforcing the substitution $x-ia \to x$, deform the contour back to the real line exploiting Cauchy's Integral Theorem, evaluate the resulting Gaussian integral, and take the real part.

SPOILER ALERT: Scroll over the highlighted area to reveal the solution

Therefore, \begin{align}\int_0^\infty e^{-x^2/2}\cos(ax)\,dx&=\frac12 e^{-a^2/2} \int_{-\infty}^\infty \text{Re}\left(e^{-\frac12(x-ia)^2}\right)\,dx\\\\&=\frac12 e^{-a^2/2} \text{Re}\left(\int_{-\infty}^\infty e^{-\frac12(x-ia)^2}\,dx\right)\\\\&=\frac12 e^{-a^2/2} \text{Re}\left(\int_{-\infty-ia}^{\infty-ia} e^{-\frac12 x^2}\,dx\right)\\\\&=\frac12 e^{-a^2/2} \text{Re}\left(\int_{-\infty}^{\infty} e^{-\frac12 x^2}\,dx\right)\\\\&=\frac12 \sqrt{2\pi }e^{-a^2/2}\end{align}as was to be shown!

You can also use Feynman's trick, if you let: $$I(a)=\int_0^{\infty} e^{-\frac{x^2}{2}} \cos(ax)dx.$$ Then we have that, $$I'(a)=-\int_0^{\infty} xe^{-\frac{x^2}{2}} \sin(ax)dx.$$ Now using parts with $dv=xe^{\frac{-x^2}{2}}dx$ so $v=-e^{-\frac{x^2}{2}}$ and $u=\sin(ax)$ so $du=a\cos(ax)dx$ we have $$-(-\sin(ax)e^{\frac{-x^2}{2}} |_0^{\infty}+a\int_0^{\infty}\cos(ax)e^{\frac{-x^2}{2}}dx)=-aI(a).$$ Now we have the following differential equation: $$I'(a)=-aI(a).$$ To get a initial condition note that, $I(0)$ is the usual gaussian, $I(0)=\sqrt{\frac{\pi}{2}}.$ So solving gives: $$ln|I(a)|=-\frac{a^2}{2}+C$$ or $$I(a)=Ce^{\frac{-a^2}{2}}.$$ Plugging in the initial condition gives the desired result:$$I(a)=\sqrt{\frac{\pi}{2}}e^{\frac{-a^2}{2}}.$$