Given $f (x,t) = \sum_{n=1}^{\infty} a_{n}e^{-n^2t}\phi_{n}(x)$ with $\phi_{n}(x) =\sqrt{\frac{2}{\pi}}\sin(nx)$ and $a_n = \int_{0}^{\pi} f_0(x)\phi_{n}(x)dx$ is the Fourier solution to the heat equation $f_t - f_{xx} = 0$ on $(0,\pi)$ with Dirichlet condition $f(0,t) = f(\pi, t) = 0$ and initial condition $f(x,0) = f_{0}(x)$. In addition, assume $|a_{n}|\leq M$ for all $n$.
Question: Prove that $f(x,t)$ is $C^{\infty}$ in $x$ for each $t > 0$.
My attempt: I was able to show that at each $t = t_0$ ($t_0$ is fixed), $f(x,t_0)$ converges uniformly in $x$, thus $f(x,t)$ is $C^0$. But when I differentiate with respect to $x$, I got $f_x = \sum_{n=1}^{\infty} a_{n}e^{-n^2t_0}\sqrt{\frac{2}{\pi}}\ n\cos(nx)$. But I can't see how to show $\sum_{n=1}^{\infty} n\cos(nx) e^{-n^2t_0}$ converges, as the extra term $n$ causes me big trouble in bounding this series by a convergent series to apply the Weirstrass M-test. The more I differentiate, the higher degree of the term $n$ I would get.
Can anyone please help prove the later case (1st and 2nd derivative) to show that $f(x,t_0)$ is $C^{1}$ and $C^{2}$ in $x$?
For any fixed $t_0>0$, the exponential decay induced by $e^{-n^2 t_0}$ eats up any polynomial weight that arises from differentiation (of any order) in $x$. This can be expressed formally by an inequality such as the following: $$\lvert n^k e^{-n^2 t_0}\rvert\le C_{t_0, k}\,e^{-n^2 \frac{t_0}2}. $$ In particular, the series for $\partial^k_x f$ converges uniformly in $x$ for any $k$.