Can you help me with this?
$$\int_{-\infty}^{+\infty} e^{-x^2}\cos x \, dx$$
Can you help me with this?
$$\int_{-\infty}^{+\infty} e^{-x^2}\cos x \, dx$$
Method 1 (Contour integration):
$$f(x)=e^{-x^2}$$
Let $C$ be a contour that is a rectangle with vertices at $-R$,$R$, $R+i/2$ and $-R+i/2$. Letting $R\to\infty$, the integral along the sides disappears, so by Cauchy's Integral Theorem:
$$ 0 = \oint_C f(z) = \\ \int_{-\infty}^\infty f(x)\, dx-\int_{-\infty}^\infty f(x+i/2)\, dx = \\ \sqrt{\pi}-e^{1/4}\int_{-\infty}^\infty e^{-x^2}(\cos(x)+i\sin(x))\, dx $$
Taking the real parts of both sizes, we obtain
$$\int_{-\infty}^\infty e^{-x^2}\cos(x)\,dx = \frac{\sqrt \pi}{\sqrt[4] e}$$
Method 2 (Differentiating under the Integral Sign):
$$I(a) = \int_{-\infty}^\infty e^{-x^2} \cos(a x)\,dx$$ $$I'(a) = -\int_{-\infty}^\infty x e^{-x^2} \sin(a x)\,dx = \frac{1}{2}e^{-x^2} \sin(a x)\bigg|_{-\infty}^\infty-\frac{a}{2}\int_{-\infty}^\infty e^{-x^2}\cos(ax)\,dx = -\frac{a I(a)}{2}$$
Because $I(0)=\sqrt{\pi}$ we have $I(a) = \sqrt \pi e^{-\frac{a^2}{4}}$. Then $I(1) = \frac{\sqrt \pi}{\sqrt[4] e}$ is the answer.
Method 3 (Summation):
$$\cos x = \sum_{n=0}^\infty (-1)^n \frac{x^{2n}}{(2n)!}$$
so
$$ I = \int_{-\infty}^\infty e^{-x^2}\cos x\,dx = \\ \int_{-\infty}^\infty e^{-x^2}\sum_{n=0}^\infty (-1)^n \frac{x^{2n}}{(2n)!}\, dx=\\ \sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}\int_{-\infty}^\infty e^{-x^2} x^{2n}\, dx=\\ \sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}2\int_{0}^\infty e^{-x^2} x^{2n}\, dx \stackrel{x\mapsto \sqrt x}{=}\\ \sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}\int_{0}^\infty e^{-x} x^{n-1/2}\, dx =\\ \sum_{n=0}^\infty \frac{(-1)^n}{(2n)!}\Gamma\left(k+\frac{1}{2}\right)=\\ \sum_{n=0}^\infty \frac{(-1)^n}{(2n)!} \frac{\sqrt{\pi} (2n)!}{4^n n!} = \\ \sqrt \pi \sum_{n=0}^\infty \left(-\frac{1}{4}\right)^n \frac{1}{n!} = \\ \frac{\sqrt \pi}{\sqrt[4] e} $$
Where this is employed and the change of summation and integration must be justified.