Gaussian-like integral : $\int_0^{\infty} e^{-x^2} \cos( a x) \ \mathrm{d}x$

Prove that :

$$ \frac{\sqrt{\pi}}{2} e^{-\frac{a^2}{4} } =\int_0^{\infty} e^{-x^2} \cos( a x) \ \mathrm{d}x$$


the only thing I can think of is differentiating the RHS and trying to get :

$$ -2 f'(a) =a f(a) $$ But I couldn't do it. Can anyone show me how to do this ?


Differential Equation Approach

Note that since the integrand is even we have $$ \int_0^\infty e^{-x^2}\cos(ax)\,\mathrm{d}x =\frac12\int_{-\infty}^\infty e^{-x^2}\cos(ax)\,\mathrm{d}x\tag1 $$ Then differentiating with respect to $a$ yields $$ \begin{align} \frac{\mathrm{d}}{\mathrm{d}a}\int_{-\infty}^\infty e^{-x^2}\cos(ax)\,\mathrm{d}x &=-\int_{-\infty}^\infty e^{-x^2}x\sin(ax)\,\mathrm{d}x\tag{2a}\\ &=\frac12\int_{-\infty}^\infty\sin(ax)\,\mathrm{d}e^{-x^2}\tag{2b}\\ &=-\frac12\int_{-\infty}^\infty e^{-x^2}\,\mathrm{d}\sin(ax)\tag{2c}\\ &=-\frac a2\int_{-\infty}^\infty e^{-x^2}\cos(ax)\,\mathrm{d}x\tag{2d}\\ \end{align} $$ $\text{(2a)}$: differentiate
$\text{(2b)}$: prepare to integrate by parts
$\text{(2c)}$: integrate by parts
$\text{(2d)}$: $\mathrm{d}\sin(ax)=a\cos(ax)\,\mathrm{d}x$

Since $f'(a)=-\frac a2f(a)$ has the solution $f(a)=ce^{-a^2/4}$ and $f(0)=\int_0^\infty e^{-x^2}\,\mathrm{d}x=\frac{\sqrt\pi}2$, $$ \int_0^\infty e^{-x^2}\cos(ax)\,\mathrm{d}x=\frac{\sqrt\pi}{2}\,e^{-a^2/4}\tag3 $$


Contour Integral Approach

$$ \begin{align} \int_0^\infty e^{-x^2}\cos(ax)\,\mathrm{d}x &=\frac12\int_{-\infty}^\infty e^{-x^2}\cos(ax)\,\mathrm{d}x\tag{4a}\\ &=\frac12\int_{-\infty}^\infty e^{-x^2}e^{iax}\,\mathrm{d}x\tag{4b}\\ &=\frac12e^{-a^2/4}\int_{-\infty}^\infty e^{-\left(x-ia/2\right)^2}\,\mathrm{d}t\tag{4c}\\[3pt] &=\frac{\sqrt\pi}2\,e^{-a^2/4}\tag{4d} \end{align} $$ $\text{(4a)}$: symmetry
$\text{(4b)}$: $\sin(ax)$ is odd in $x$
$\text{(4c)}$: complete the square
$\text{(4d)}$: Cauchy's Integral Theorem and $\int_{-\infty}^\infty e^{-x^2}\,\mathrm{d}t=\sqrt\pi$


$\newcommand{\+}{^{\dagger}} \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle} \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace} \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack} \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,} \newcommand{\dd}{{\rm d}} \newcommand{\down}{\downarrow} \newcommand{\ds}[1]{\displaystyle{#1}} \newcommand{\expo}[1]{\,{\rm e}^{#1}\,} \newcommand{\fermi}{\,{\rm f}} \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,} \newcommand{\half}{{1 \over 2}} \newcommand{\ic}{{\rm i}} \newcommand{\iff}{\Longleftrightarrow} \newcommand{\imp}{\Longrightarrow} \newcommand{\isdiv}{\,\left.\right\vert\,} \newcommand{\ket}[1]{\left\vert #1\right\rangle} \newcommand{\ol}[1]{\overline{#1}} \newcommand{\pars}[1]{\left(\, #1 \,\right)} \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}} \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,} \newcommand{\sech}{\,{\rm sech}} \newcommand{\sgn}{\,{\rm sgn}} \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}} \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert} \newcommand{\wt}[1]{\widetilde{#1}}$ $\ds{\int_{0}^{\infty}\expo{-x^{2}}\cos\pars{ax}\,\dd x:\ {\large ?}}$

\begin{align} &\color{#66f}{\large\int_{0}^{\infty}\expo{-x^{2}}\cos\pars{ax}\,\dd x} =\half\Re\int_{-\infty}^{\infty}\expo{-x^{2}}\expo{\ic\verts{a}x}\,\dd x \\[5mm]&=\half\Re\int_{-\infty}^{\infty} \expo{-\pars{x -\ic\verts{a}/2}^{2} - a^{2}/4}\,\dd x =\half\,\expo{-a^{2}/4} \Re\int_{-\infty - \verts{a}\,\ic/2}^{\infty - \verts{a}\,\ic/2} \expo{-x^{2}}\,\dd x \\[5mm]&=\half\,\expo{-a^{2}/4}\ \underbrace{\int_{-\infty}^{\infty}\expo{-x^{2}}\,\dd x}_{\ds{=\ \color{#c00000}{\root{\pi}}}}\ =\ \color{#66f}{\large{\root{\pi} \over 2}\,\expo{-a^{2}/4}} \end{align}


Notice that $$ a f(a) + 2 f^\prime(a) = \int_0^\infty \exp(-x^2) \left( a \cos(a x) - 2 x \sin(a x) \right) \mathrm{d} x = \int_0^\infty \frac{ \mathrm{d}}{\mathrm{d}x} \left( \mathrm{e}^{-x^2} \sin\left(a x\right) \right) \mathrm{d} x = 0 $$ It now only remains to find $f(0) = \int_0^\infty \exp(-x^2) \mathrm{d}x = \frac{1}{2} \int_{-\infty}^\infty \exp(-x^2) \mathrm{d}x = \frac{\sqrt{\pi}}{2} $.