Solving a Partial Differential Equation missing term with Separation of Variables I am having trouble solving the following Partial Differential Equation:
PDE: $$u_t = u_{xx}$$
Boundary Conditions: 
$$u_x(0,t) = 0$$
and
$$u_x(1,t) = 0$$
for $0<t<\infty$
Initial Condition: $$u(x,0) = x$$
When I compute the following IVBP, I am off by a single, constant term. Here is my work:
Assume that $u(x,t) = X(x)T(t)$.
Thus, $u_t = X(x)T'(t)$ and $u_{xx} = X''(x)T(t)$.
Plugging these two terms back into the PDE yields,
$X(x)T'(t) = X''(x)T(t)$ which can then be rearranged into $\frac{T'(t)}{T(t)} = \frac{X''(x)}{X(x)} = -\lambda ^2$ ($\lambda$ is constant since X only depends on x and T only depends on t the ratio must be equal according to the PDE).
Solving for each side of the equation yields, $T(t) = e^{(-\lambda ^2)t}$ and $X(x) = A\sin (\lambda x)+ B\cos (\lambda x)$.(I left the constants in this product)
Finally the PDE is of the form $$u(x,t) = e^{(-\lambda ^2)t}[A\sin (\lambda x)+B\cos (\lambda x)]$$ 
Then I solve the equation using the initial conditions,such that $$u_x(x,t) = e^{(-\lambda ^2)t}[A\lambda \cos (\lambda x)-B\lambda \sin (\lambda x)]$$.
Thus, $u_x(0,t)= 0 = e^{(-\lambda^2)t}[A\lambda \cos (0)-B \lambda \sin (0)] = A = 0$.
Going to the second boundary condition: $u_x(1,t) = e^{(-\lambda ^2)t}[-B\lambda \sin (\lambda)] = \sin (\lambda) = 0$. Consider the nontrivial solution where $B \neq 0$, then $\lambda = n\pi$ where $n$ is in the set of integers greater than 0.
Thus the final form of the solution is $$u(x,t) = Be^{(-\lambda ^2)t}\cos (n\pi x)$$
From here I assumed that if there are many $n$ that satisfy the IVBP, then you can sum all of them. Thus $$u(x,t) = \sum b_n e^{(-\lambda ^2)t}\cos (n\pi x)
$$
To solve for the amplitude I use the concept of orthogonality of cosines, such that $u(x,0)\cos (m \pi x) = x\cos (m \pi x) = \sum b_n \cos (n \pi x) \cos (m \pi x)$ and since $\int_0^1 \cos (m \pi x)\cos (n \pi x)dx$ is equal to 0 when $m \neq n$ and equal to $\frac{1}{2}$ when $m=n$. Thus I have to solve for $\int_0^1x\cos (m \pi x)dx$ which I got $\frac{-2}{m^2\pi ^2}$ when m is even. On the other side, the end result is: $\int_0^1\cos ^2(n\pi x)dx = \frac{1}{2}$. So then finally putting it all together:$u(x,0)\cos (m \pi x) = x\cos (m \pi x) = \sum b_n \cos (n \pi x) \cos (m \pi x)$ is converted into $\frac{-2}{m^2\pi ^2}= \frac{b_n}{2}$ and thus $b_n = \frac{-4}{m^2\pi ^2}$. For my final result, I got $$u(x,t) = \frac{-4}{n^2\pi ^2}\sum e^{(-n\pi)^2t}\cos (n\pi x)$$.
My textbook has a similar but slightly different answer, that is:
$$u(x,t) = \frac{1}{2}-\frac{4}{n^2\pi ^2}\sum e^{(-n\pi)^2t}\cos (n\pi x)$$.
So what exactly am I not getting?? 
 A: Your eigenfunctions are incomplete. The sinusoidal solution is certainly valid for when $\lambda \ne 0$. But what happens when $\lambda = 0$? Your equations reduce to
\begin{align}
X'' &= 0 \\
T' &= 0 
\end{align}
With boundary conditions $X'(0) = X'(1) = 0$. You can determine that a non-trivial solution does exist for this case: $X(x) = 1$ (up to a multiplicative constant).
Therefore, the complete solution space is
$$ u(x,t) = b_0 + \sum_{n=1}^\infty b_n e^{-n^2\pi^2 t}\cos(n\pi x) $$
A: The general solution is
$$
               u(x,t) = \sum_{n=0}^{\infty} b_ne^{-n^2\pi^2 t}\cos(n\pi x).
$$
The set $\{ 1,\cos(\pi x),\cos(2\pi x),\cos(3\pi x),\cdots\}$ is a complete orthogonal subset of $L^2[0,1]$. So the constants $b_n$ are determined by orthogonality. Multiplying $x=u(x,0)=b_0+b_1\cos(\pi x)+b_2\cos(2\pi x)+\cdots$ by $\cos(n\pi x)$ and integrating over $[0,1]$ gives
$$
      \int_0^1 x\cos(n\pi x)dx = b_n\int_0^1 \cos^2(n\pi x)dx \\
       b_n = \frac{\int_0^1 x\cos(n\pi x)dx}{\int_0^1\cos^2(n\pi x)dx}.
$$
For $n=0$,
$$
     b_0 = \frac{\int_0^1 xdx}{\int_0^1 dx}=\frac{1}{2}.
$$
For $n > 0$,
\begin{align}
      b_n &= \frac{\int_0^1 x\cos(n\pi x)dx}{\int_{0}^{1}\cos^2(n\pi x)dx} \\
   &=\frac{x\frac{\sin n\pi x}{n\pi}|_{0}^1-\int_0^1\frac{\sin(n\pi x)}{n\pi}dx}{1/2} \\
   &=-\frac{2}{n\pi}\int_0^1\sin(n\pi x)dx \\
   &=\frac{2}{n^2\pi^2}\cos(n\pi x)|_{x=0}^{1} \\
   &=\frac{2}{n^2\pi^2}((-1)^n-1) = \left\{ \begin{array}{cc}-\frac{4}{n^2\pi^2} & n\;\; \mbox{odd}\\ 0 & n\;\; \mbox{even}\end{array}\right.
\end{align}
Therefore,
$$
     u(x,t)=\frac{1}{2}-\sum_{k=0}^{\infty}\frac{4}{(2k+1)^2\pi^2}e^{-(2k+1)^2\pi^2 t }\cos((2k+1)\pi x).
$$
A: Thanks to @GReyes I was able to discover where I went wrong. I did forget one thing, but I believe @Dylan 's answer is not correct. First off let me state where @Dylan went wrong. They took the trivial solution as being part of the general solution, which is false. By assuming that $X''(x) = T'(t) = 0$. This assumption is not correct because then that means $X'(x) = C = T(t)$. A further assumption was made that said $C=0$ yet again. Then basically X(x) turns out to be some constant $D$, because $C=0$. So this leads to a solution of $u(x,0)=(D)(0)=0$. This is not the initial conditions. 
The solution actually depends on the first amplitude of the answer. The general solution is, $$u(x,t) = \frac{-4}{n^2\pi ^2}\sum e^{(-n\pi)^2t}cos(n\pi x)$$
The problem here comes when evaluating $$\int_0^1cos^2(n\pi x)dx = \frac{1}{2}$$
Here I forgot the case where $m=n=0$. This corresponds to the zero-th amplitude,such that $\int_0^1cos^2(n\pi x)dx =\int_0^1cos^2(0)dx = \int_0^1dx =x|_0^1=1$.
The zero-th amplitude needs to be considered separately, and the other integral becomes, $\int_0^1xcos(m \pi x)dx = \int_0^1xcos(0 \pi x)dx = \int_0^1xdx = \frac{x^2}{2}|_0^1 = \frac{1}{2}$.So putting it all together, $\frac{1}{2} = b_0(1)$. So essentially $$b_0 = \frac{1}{2}$$, which leads to the aforementioned solution. The mistake here was assuming the orthogonality of squared cosines had the same characteristics as that of the squared sines. The orthogonality of cosines, as mentioned above have an extra consideration to make.
