Why is the solution of heat equation $f(x,t)= \int_{\mathcal{X}} f_0(x') \sum_{k \geq 1} e^{-t \lambda_k} \phi_k(x) \phi_k(x') \, dx'.$ In my notes, I have the solution of heat equation written as such
$$f(x,t) = e^{-t\,\Delta} f_0(x) \overset{(1)}{=}  \sum_{k \geq 1} \langle f_0, \phi_k \rangle_{L^2{\mathcal{(X)}}} e^{-t \lambda_k} \phi_k(x) \overset{(2)}{=} \int_{\mathcal{X}} f_0(x') \sum_{k \geq 1} e^{-t \lambda_k} \phi_k(x) \phi_k(x') \, dx'.$$
How are (1) and (2) attained? In particular I don't quite get how the inner product arises and why for the last expression, we have $x$ and $x'$?
 A: Using your solution 
$$f(x,t)=\sum_{k} a_{k} e^{- \lambda_{k} t} \phi_{k}$$
where $a_{k}$ are the coefficients, $\lambda_{k}$ the eigenvalues, $e^{-\lambda_{k} t}$ the eigenfunction for time, $\phi_{k}$ the eigenfunction in space, we find
\begin{align}
f(x,0) &= f_{0}(x) \\
&= \sum_{k} a_{k} \phi_{k}
\end{align}
Now, to use orthogonality conditions, we multiply both sides by $\phi_{k'}$ and integrate over the set $\chi$ i.e
\begin{align}
\int_{\chi} f_{0} \phi_{k'} dx &= \sum_{k} a_{k} \int_{\chi} \phi_{k} \phi_{k'} dx
\end{align}
Now, the LHS is just the inner product of $f_{0}$ and $\phi_{k'}$ in some space $\mathbb{T}$ over some domain $\chi$ i.e
$$\int_{\chi} f_{0} \phi_{k'} dx = \langle f_{0}, \phi_{k'} \rangle_{\mathbb{T}(\chi)} \quad (*)$$
and the RHS yields
$$\sum_{k} a_{k} \int_{\chi} \phi_{k} \phi_{k'} dx = \sum_{k} a_{k} \langle \phi_{k}, \phi_{k'} \rangle_{\mathbb{T}(\chi)}$$
which, by orthogonality, is just the inner product that gives the normalisation. On page $126$, it states that this normalising constant in the space $L^{2}(\chi)$ is given by $\langle \phi_{k}, \phi_{k'} \rangle_{L^{2}(\chi)} = \delta_{k k'}$ and so using this we find
\begin{align}
\langle f_{0}, \phi_{k'} \rangle_{L^{2}(\chi)} &= \sum a_{k} \langle \phi_{k}, \phi_{k'} \rangle_{L^{2}(\chi)} \\
&= a_{k} \delta_{k k'} \\
&= a_{k} \quad \text{when $k = k'$}
\end{align}
Replacing the coefficient in your Fourier series with the above yields
\begin{align}
f(x,t) &= \sum \langle f_{0}, \phi_{k} \rangle_{L^{2}(\chi)} e^{- \lambda_{k} t} \phi_{k}
\end{align} 
which is the result you have at $(1)$. The result at $(2)$ is just the same as the result at $(1)$, but using the integral form at $(*)$ instead of the inner product. Also, the integral form is just integrating with respect to the dummy variable $x'$ instead of the dummy variable $x$.
Let me know if you have any questions.
