One dimensional heat equation with multiple eigenfunctions To solve the heat equation $u_{t}=u_{xx} \,\, (!)$ which is defined for $x\in[0,1]$ and $t>0$. I want to find the solution which satisfies the boundary conditions $u_{x}(0, t)=u_{x}(1,t)=0$ and initial conditions $u(x,0)=3x^{2}$. I have attempted to find a solution in the form $u(x, t) = P(x)Q(t)$, then substituting this into $(!)$ we get $$P(x)\dot{Q}(t)=P''(x)Q(t) \iff \frac{\dot{Q}(t)}{Q(t)} = \frac{P''(x)}{P(x)} = \lambda = \text{ const.}$$ Thus we have separated this problem into two odes \begin{align}(1)&\colon \dot{Q}(t)=\lambda\,Q(t)\iff Q(t)=Ae^{\lambda t}\\ \\(2)&\colon P''(x)=\lambda\,P(x)\end{align} We solve $(2)$ as an eigenvalue problem using the boundary conditions $P'(0)=P'(1)=0$ thus for $\lambda>0$, we have the solutions $P(x)=Be^{\sqrt{k}x}+Ce^{-\sqrt{k}x}$, from boundary conditions we find the only solution is when $B=C=0$ thus there are no eigenfunctions for $\lambda>0$. Now consider when $\lambda=0$, $P(x) = B+Cx$, from boundary conditions we find that $B=0$ and $A\in\mathbb{R}$, so $P_{1}(x)=A$, hence we have the eigenvalue $\lambda_{n}=\lambda=0$ with corresponding eigenfunction $\phi_{n}(x)=1$. When $\lambda<0$, let $\lambda=-\omega^{2}$, $\omega>0$, which has solution $P(x)=B\cos{\omega x}+C\sin{\omega x}$, from boundary conditions we find that $B=0$ and that there is a non-trivial solution when $\omega=n\pi$ for $n\in\mathbb{Z}^{+}$ so we have the solution $P_{2}(x)=A\cos{(n\pi x)}$. Thus for $\lambda<0$ we have eigenvalues $\lambda_{n}=-n^{2}\pi^{2}$ with corresponding eigenfunctions $\phi_{n}(x)=\cos{(n\pi x)}$.
Thus we have two sets of eigen-pairs, now my question is how do I put this back into my guessed solution $u(x,t)=P(x)Q(t)$? Am I correct is saying the solution therefore has the form \begin{align}u(x,t) &= P_{1}(x)Q_{1}(t)P_{2}(x)Q_{2}(t)\\ &= (A_{1})(A_{2}e^{0\cdot t})(A_{3}\cos{(n\pi x)})(A_{4}e^{-n^{2}\pi^{2}t})\\ &=A\cos{(n\pi x)}e^{-n^{2}\pi^{2} t}\end{align}
Or do we write it in another form?
 A: The quick and dirty answer is that you now use superposition to build a solution to your equation which satisfies the desired initial condition. The philosophy is that since your equation is $Lu=0$ for a linear operator $L$, any linear combination of solutions is also a solution. 
For $n \in \mathbb{N}_0$, define $\phi_n(t,x) = \cos(n \pi x) \exp(-n^2 \pi^2 t)$ and $\psi_n(x) = \phi_n(0,x)=\cos(n \pi x)$. (Note that $\phi_0 \equiv 1$, so I've really included all the eigenfunctions you mentioned.) Then your initial condition can be represented in terms of $\psi_n$ as
$$f(x) = \sum_{n=0}^\infty \frac{\int_0^1 \psi_n(x) f(x) dx}{\int_0^1 \psi_n^2(x) dx} \psi_n(x) \equiv c_n \psi_n(x).$$
This is just a Fourier series, and in this special case you can do all the integrals explicitly. Then the solution to your heat equation is given by
$$u(t,x) = \sum_{n=0}^\infty c_n \phi_n(t,x).$$
For any $t \geq 0$ this will converge in the sense of $L^2$, since $f \in L^2$ and $|\phi_n(t,x)| \leq |\psi_n(x)|$. Checking whether it converges pointwise is a more delicate matter. At $t=0$ it probably doesn't, since the initial condition does not have a continuous periodic extension. Also note that your solution is necessarily rather weak, because your initial condition doesn't satisfy the boundary condition.
Addendum: I made an error; because the initial condition doesn't satisfy the boundary condition, the series above will not converge to $f$ even in $L^2$. But this means that you need to reformulate the problem anyway, because you have a problem with explaining what the equation means when the initial condition doesn't satisfy the boundary condition. This problem is not insurmountable (you just need the weak formulation of the problem), but it is essential to address it. In particular, it is actually rather special that the weak formulation of this problem makes sense, because the weak formulation of the corresponding homogeneous Dirichlet problem does not make sense (since the initial condition doesn't satisfy a homogeneous Dirichlet condition, either).
