TITLE: The solution of the Heat equation.?
QUESTION [6 upvotes]: Let $u(x,t)$ be the solution of the equation 
$$ \frac{\partial{^2u}}{\partial{x^2}}=\frac{\partial{u}}{\partial{t}}$$
which tends to zero as $t\rightarrow\infty$ and has the value $\cos(x)$ when $t=0$.
Then which of the following is true?
$1.\;u=\sum^\infty_{n=1}a_n\sin(nx+b_n)e^{-nt}$, where $a_n,b_n$ are arbitrary constants.
$2.\;u=\sum^\infty_{n=1}a_n\sin(nx+b_n)e^{-n^2t}$, where $a_n,b_n$ are arbitrary constants.
$3.\;u=\sum^\infty_{n=1}a_n\cos(nx+b_n)e^{-nt}$, where $a_n$ are not all zeros and $b_n=0$
$4.\;u=\sum^\infty_{n=1}a_n\cos(nx+b_n)e^{-n^2t}$, where $a_1\neq0,\;a_n=0 \text{ for } n>1,b_n=0 \text{ for } n\geq1$.

REPLY [4 votes]: HINT:
First, show that neither $(1)$ nor $(3)$ satisfies the PDE $u_{xx}=u_t$.
Then, let $t=0$ in Cases $(2)$ and $(4)$ and see which of these proposed solutions satisfies $u(x,0) =\cos x$.

SPOILER ALERT: Scroll over the highlighted area to reveal the solution.

Note that $u$ satisfies the PDE $u_{xx}=u_t$.  For Proposed Solution $(1)$, we have $$u_{xx}=-\sum_{n=1}^{\infty}n^2a_n\sin(nx+b_n)e^{-nt}$$while $$u_{t}=-\sum_{n=1}^{\infty}na_n\sin(nx+b_n)e^{-nt}$$Clearly, $u_{xx}\ne u_t$ for $(1)$.  Similarly, Proposed Solution $(3)$ fails to satisfy the PDE.  Next, we note that for Proposed Solution $(2)$ we have $$u(x,0)=\sum_{n=1}^{\infty}a_n\sin(nx+b_n)$$But, this series cannot equal $\cos x$ for arbitrary $a_n$ and $b_n$.  However, Proposed Solution $(4)$ satisfies the PDE and the initial condition.  Therefore, it is the solution to the problem!