How to do this integral $\int_{-\infty}^{\infty}{\rm e}^{-x^{2}}\cos\left(\,kx\,\right)\,{\rm d}x$ How to do this integral
$$\int_{-\infty}^{\infty}{\rm e}^{-x^{2}}\cos\left(\,kx\,\right)\,{\rm d}x$$
for any $k > 0$ ?.
I tried to use gamma function, but sometimes the series doesn't converge.
 A: The integral equals $\sqrt{\pi}e^{-k^2/4}$. To show this, just consider that:
$$ I =\Re\int_{-\infty}^{+\infty}e^{ikx-x^2}\,dx = e^{-k^2/4}\cdot \Re\int_{-\infty}^{+\infty}e^{-(x-ik/2)^2}\,dx $$
and prove that the complex shift does not affect the value of the integral:
$$\int_{-\infty}^{+\infty}e^{-(x-ik/2)^2}\,dx = \int_{-\infty-ik/2}^{+\infty-ik/2}e^{-x^2}\,dx = \int_{-\infty}^{+\infty}e^{-x^2}\,dx = \sqrt{\pi}.$$
This happens because $e^{-z^2}$ is an entire function whose absolute value when $|\Re(z)|\to +\infty$ and $\Im(z)$ stays bounded goes to zero really fast.
A: We assume
$$F(k)=\int_{-\infty}^{\infty}e^{-x^2}\cos kxdx$$
Consider $F'(k)$, we have
$$F'(k)=\int_{-\infty}^{\infty}-xe^{-x^2}\sin kxdx$$
$$=\frac{1}{2}(e^{-x^2}\sin kx|_{-\infty}^{\infty}-\int_{-\infty}^{\infty}ke^{-x^2}\cos kxdx)$$
$$=-\frac{1}{2}kF(k)$$
Then we solve the ordinary differential equation with $F(0)=\sqrt\pi$, and we get
$$F(k)=\sqrt\pi e^{\frac{-k^2}{4}}$$
A: Write
$$\cos kx = \frac{e^{ikx}+e^{-ikx}}{2}.$$
Using the identity that for $a>0$ and $b\in\mathbb{R}$,
$$\int_{-\infty}^{\infty}e^{-ax^2+ibx}dx=\sqrt{\frac{\pi}{a}}e^{-\frac{b^2}{4a}},$$that can be obtained completing squares, we find for $a=1$ and $b=k$ that
$$\int_{-\infty}^{\infty}e^{-x^2}\cos kx dx=\int_{-\infty}^{\infty}e^{-x^2} \frac{e^{ikx}+e^{-ikx}}{2} dx=\sqrt{\pi}e^{-\frac{k^2}{4}}.$$
