Interchanging integration and differentiation in heat equation I'm trying to solve the following problem:

Assume that we are given $f(t,x) \in C^{\infty}(\mathbb R \times \mathbb R^n)$ such that $f(t, \cdot) \in \mathcal S(\mathbb R^n)$ for all $t>0$ (where $\mathcal S(\mathbb R^n)$ is Schwartz space). Assume furthermore that $f$ is a solution to the heat equation on $\mathbb R^n$ with
  $$
\begin{align}
\partial_tf(t,x) &= \Delta f(t,x) \qquad t>0 \\
\lim_{t\to 0} f(t,x) &= g(x)
\end{align}
$$
  for some $g\in \mathcal S(\mathbb R^n)$. 
I want to show that under these conditions we must have $f(t,x) = (K_t\ast g)(x)$, where $\ast$ denotes convolution and 
  $$ K_t(x) = \frac{1}{(4\pi t)^{n/2}}e^{-\langle x, x\rangle/4t}$$
  is the heat kernel.

What I'm having trouble with is the following: The idea is to consider the Fourier transform $\hat f$ of $f$ and to derive the ordinary differential equation
$$\partial_t \hat f(t,k) = - k^2 \hat f(t,k)$$
But how do I even know that $\hat f(t,k)$ is differentiable with respect to $t$? What I would like to do is differentiate under the integral sign here:
$$\partial_t \hat f(t,k) =\partial_t \int_{\mathbb R^n} f(t,x)e^{-ikx}\, dx$$
But I don't know how to justify it. Could anyone help me out?
Thanks a lot! =)
 A: You cannot, in general, interchange the differentiation and the integration here. I take the following example from this MO answer. Let $\phi(x)$, $x\in\mathbb{R}$, be an arbitrary bump function ($\phi \in C^\infty_c(\mathbb{R})$). Consider the function $f(x,t)$ defined to be identically 0 if $t \not\in (-\pi/2,\pi/2)$ and $f(x,t) = \phi(x - \tan t)$ otherwise. One checks that this function is indeed $C^\infty(\mathbb{R}^2)$: for each $|t| \geq \pi/2$, and for any $x$, one can find a small neighborhood of $(x,t)$ such that $f$ vanishes identically there. And $f(x,t)$ is a composition of smooth functions on $(-\pi/2,\pi/2)\times \mathbb{R}$. 
Notice also that for any $k$, the function $\partial_t^kf(t,x)$, restricted to a fixed time slice $t = t_0$, is Schwartz (and in fact has compact support). 
Now, taking the spatial Fourier transform you get that $\hat{f}(t,\xi) = e^{i \tan(t) \xi} \hat{\phi}(\xi)$ for $t\in (-\pi/2, \pi/2)$. Computing the time derivative you get 
$$ |\frac{d}{dt} \hat{f}(t,\xi)| = |\xi| \sec^2(t) |\hat{\phi}(\xi)| $$
which is not continuous at $t = \pm \pi/2$. 

As a side remark, in Stein and Shakarchi's Fourier Analysis, the analogous statement to the one you want to prove is given with the additional assumption that the restrictions $f(t,x)$ to $t$ are uniformly Schwartz, which then imply that one can interchange the differentiation with integral. 
