# Evaluate $$\int_{0}^{\infty} \mathrm{e}^{-ax^{2}} \cos(bx) \mathrm{d}x$$

How to evaluate

I = \int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}} \cos(bx) \mathrm{d}x
\tag{1}
\label{eq:20161022-1}

was a question posed at Mathematics Stack Exchange. I encourage readers to follow the link to see solutions that use a rectangular contour to evaluate this integral as an alternative method to the one presented below.

Let
\begin{align}
I_{1} &= \int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}} \mathrm{e}^{ibx} \mathrm{d}x
= \int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}+ibx} \mathrm{d}x \\
&= \mathrm{e}^{-b^{2}/4a} \int\limits_{0}^{\infty} \mathrm{e}^{-a(x-ib/2a)^{2}} \mathrm{d}x \\
\tag{2}
\label{eq:20161022-2}
\end{align}
Here we completed the square and note that $$\mathrm{Re}\,I_{1} = I$$.

Consider the indefinite integral
\begin{align}
\int \mathrm{e}^{-a(x-ib/2a)^{2}} \mathrm{d}x
&= \int \mathrm{e}^{-ay^{2}} \mathrm{d}y \\
&= \frac{1}{\sqrt{a}} \int \mathrm{e}^{-z^{2}} \mathrm{d}z = \frac{1}{2} \sqrt{\frac{\pi}{a}} \mathrm{erf}(z) \\
&= \frac{1}{2} \sqrt{\frac{\pi}{a}} \mathrm{erf}\left(x\sqrt{a} – \frac{ib}{2\sqrt{a}}\right)
\tag{3}
\label{eq:20161022-3}
\end{align}
we used the substitutions, $$y=x- \frac{ib}{2a}$$ and $$z^{2} = ay^{2}$$.

Examining the error function expression, we have

\lim_{x \to 0} \mathrm{erf}\left(x\sqrt{a} – \frac{ib}{2\sqrt{a}}\right)
= \mathrm{erf}\left(- \frac{ib}{2\sqrt{a}}\right)
= -i\,\mathrm{erfi}\left(\frac{b}{2\sqrt{a}}\right)
\tag{4}
\label{eq:20161022-4}

which is a pure imaginary quantity with the assumption that all of the variables in the argument of the imaginary error function are real and $$a \gt 0$$. We also have

\lim_{x \to \infty} \mathrm{erf}\left(x\sqrt{a} – \frac{ib}{2\sqrt{a}}\right) = 1
\tag{5}
\label{eq:20161022-5}

Using equations \eqref{eq:20161022-4} and \eqref{eq:20161022-5} in equation \eqref{eq:20161022-3} we obtain

\mathrm{Re}\left(\int\limits_{0}^{\infty} \mathrm{e}^{-a(x-ib/2a)^{2}} \mathrm{d}x \right) = \frac{1}{2} \sqrt{\frac{\pi}{a}}
\tag{6}
\label{eq:20161022-6}

Combining equations \eqref{eq:20161022-6} and \eqref{eq:20161022-2} yields our final result

\int\limits_{0}^{\infty} \mathrm{e}^{-ax^{2}} \cos(bx) \mathrm{d}x = \frac{1}{2} \sqrt{\frac{\pi}{a}} \,\mathrm{e}^{-b^{2}/4a}