# How to do this integral $\int_{-\infty}^{\infty}{\rm e}^{-x^{2}}\cos\left(\,kx\,\right)\,{\rm d}x$ [duplicate]

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.

• Yes.${}{}{}{}{}{}{}{}$ – Pedro Tamaroff Sep 4 '14 at 1:27
• You need to use Gaussian integrals after changing the cos function in terms of the exponential and completing the squares. see here. – Mhenni Benghorbal Sep 4 '14 at 1:35
• This looks like a duplicate of this question. – robjohn Sep 4 '14 at 1:53
• @PedroTamaroff There are a few improper integrals there... but this one? – user147263 Sep 4 '14 at 4:02

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.
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}}$$
• Is it not just differentiation under the integral sign, since the integrand is $C^1$ in both $x$ and $k$? Regardless though, just wanted to point out that I thought it was a neat trick to apply here. – msteve Sep 4 '14 at 1:50
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}}.$$