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