Computing $\sum_{n=-\infty}^\infty \int_{-\pi}^\pi e^{-x^2} \cos(nx) dx $ I'm trying to find $$ \sum_{n=-\infty}^\infty \int_{-\pi}^\pi e^{-x^2} \cos(nx) dx. $$
About the only thing I can think of is the well-known identity
$$ \sum_{n=-k}^k \cos(nx) = \sum_{n=-k}^k e^{inx} = \frac{\sin\left((k+\frac{1}{2})x\right)}{\sin\left(\frac{x}{2}\right)}. $$
But this doesn't seem to simplify things much.
 A: Because $e^{-x^{2}}$ is an even function, the Fourier series for $e^{-x^{2}}$ is
$$
   e^{-x^{2}}\sim \frac{1}{2\pi}\int_{-\pi}^{\pi}e^{-t^2}dt+\sum_{n=1}^{\infty}\frac{1}{\pi}\int_{-\pi}^{\pi}e^{-t^{2}}\cos(nt)dt\cos(nx).
$$
Evaluating at $x=0$ gives you what you want:
$$
\begin{align}
        1 & = \frac{1}{2\pi}\int_{-\pi}^{\pi}e^{-t^{2}}dt+\frac{1}{\pi}\sum_{n=1}^{\infty}\int_{-\pi}^{\pi}e^{-t^{2}}\cos(nt)dt \\
          & = \frac{1}{2\pi}\sum_{n=-\infty}^{\infty}\int_{-\pi}^{\pi}e^{-x^{2}}\cos(nt)dt
\end{align}
$$
Looks like the answer is $2\pi$.
A: Well, there were two solid answers posted. So, let's try this using the complex Fourier series.
We have 
$$e^{-x^2}=\sum_{n=-\infty}^{\infty}C_ne^{inx}\tag 1$$
where 
$$C_n=\frac{1}{2\pi}\int_{-\pi}^{\pi}e^{-t^2}e^{-int}dt \tag 2$$
Using $(2)$ in $(1)$ with $x=1$ yields 
$$1=\sum_{n=-\infty}^{\infty}\frac{1}{2\pi}\int_{-\pi}^{\pi}e^{-t^2}e^{-int}dt \tag 3$$
whereupon multiplying both sides of $(3)$ by $2\pi$ and exploiting the fact that the sine function is odd reveals 
$$\bbox[5px,border:2px solid #C0A000]{2\pi=\sum_{n=-\infty}^{\infty}\int_{-\pi}^{\pi}e^{-t^2}\cos (nt)\,dt }$$
A: $f(x)=e^{-x^2}$ is a function that belongs to the Schwarz space, and its Fourier series is uniformly converging to $f(x)$. So, if we set:
$$ c_k = \frac{1}{\pi}\int_{-\pi}^{\pi}f(x)\cos(kx)\,dx $$
we have:
$$ e^{-x^2} = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x)\,dx + \sum_{n\geq 1} c_n \cos(nx) $$
and:
$$ \sum_{n\geq 1}\int_{-\pi}^{\pi}f(x)\cos(nx)\,dx = \pi\sum_{n\geq 1}c_n=\pi\, f(0)-\frac{1}{2}\int_{-\pi}^{\pi}f(x)\,dx $$
as well as:
$$ \sum_{n\in\mathbb{Z}}\int_{-\pi}^{\pi}f(x)\cos(nx)\,dx=2\pi\, f(0)=\color{red}{2\pi}.$$
That also follows from the convergence in distribution of the Dirichlet kernel to the Dirac delta function.
