Solve the boundary value problem \begin{cases} u_{t}-2u_{xx}=0 \\ u_{x}(0,t)=u_{x}(\pi,t)=0, \quad x\in[0,\pi], t\geq0 \\ u(x,0)=\cos^{2}(x) \end{cases}
My Attempt
Let $u(x,t)=X(x)T(t)$. Then
\begin{equation} u_{t}-2u_{xx}=0 \iff X(x)T'(t)-2X''(x)T(t)=0 \end{equation} which implies \begin{equation} \frac{T'(t)}{2T(t)}=\frac{X''(x)}{X(x)}=-\lambda^{2} \end{equation} So \begin{equation} X''(x)+\lambda^{2}X(x)=0 \end{equation} where the general solution is given as \begin{equation} X_{n}(x)=A\cos(\lambda_{n}x)+B\sin(\lambda_{n}x) \end{equation} The boundary conditions $X_{x}(0)=X(\pi)=0$, with \begin{equation} X'(x)=-A\lambda_{n}\sin(\lambda_{n}x)+B\lambda_{n}\cos(\lambda_{n} x) \end{equation} gives
\begin{equation} X_{x}(0)=0 \implies B\lambda_{n}=0 \implies B=0 \end{equation} and \begin{equation} X_{x}(\pi)=0 \implies -A\lambda_{n}\sin(\lambda_{n}\pi)=0 \implies \lambda_{n}=n \end{equation} So, we have \begin{equation} T'(t)+2n^{2}T(t)=0 \end{equation} which has the solution \begin{equation} T_{n}(t)=e^{-2n^{2}t} \end{equation}
By superposition, we have \begin{equation} u(x,t)=\sum_{n=1}^{\infty}A_{n}\cos(nx)e^{-2n^{2}t} \end{equation} where the constant term $A_{n}$ is determined by the initial condition $u(x,0)=\cos^{2}(x)$. Here I am lead to believe $T_{1}(0)=\cos(x)$ and $T_{n}(0)=0$ for $n \not =1$. So \begin{equation}u(x,t)=\cos^{2}(x)e^{-2t} \end{equation} But, when I check this result it becomes clear that it is wrong. Where does my argument slip into chaos?