Solve as a series the equation $u_t = u_{xx}, u_x {(0,t)}=0 , u{(1,t)} =1, u{(x,0)} = x^2$. This question is from section 5.6 of Partial Differential Equations: An Introduction 2nd Edition by Walter Strauss 2008.  I have approached this question by using the separation of variables $u(x,t) = X(x)T(t)$
This leads to solving 2 ODEs which are $$X''=-\lambda X$$ and $$T' = -\lambda T$$
after applying boundary conditions we get $$X_n(x) = \cos ( (n + 1/2)\pi x ), \ \ \ \ T_n(t) = e^{ (n + 1/2)^2  \pi^2  t}$$ 
I assume I have to compute the Fourier coefficients $$A_n = \{x^2, \cos ( (n + 1/2)\pi x )\}$$
My answer does not match with the book's answer which is 
$$A_n = (-1)^{(n+1)} \cdot 4 \cdot ((n + 1/2)\pi)^{-3}$$
The full series from the answers is $$1 + \sum_{n=0}^\infty A_n \cos ( (n + 1/2)\pi x )  e^{ -(n + 1/2)^2 \pi^2 t}$$
Can someone advise how I can proceed? Or if there is a flaw in my method then please correct me.
The related section in the textbook does not explain how to handle mixed boundary conditions. In this question, only one boundary condition $$u(1,t) = 1$$ is given while the other condition is a Neumann condition. What confuses me the most is how to handle these questions where you are given mixed boundary conditions.
 A: Minor point: there is a sign error in $T_n$. The exponential terms in the solution of heat equation should decay, not blow up (apart from some weird cases considered in section 4.3). 
Main point: we need  homogeneous boundary conditions for the separation of variables to work. Indeed, a basic idea of the method is that functions satisfying boundary conditions form a linear space, for which we find a convenient basis (i.e., eigenfunctions of the operator $d^2/dx^2$). The functions satisfying an inhomogeneous boundary condition, such as $u(1,t)=1$, do not form a linear space. 
What to do: make it homogeneous. Introduce $v(x,t)= u(x,t) -1$, which satisfies the same PDE with 
$$v_t = v_{xx}, v_x {(0,t)}=0 , v(1,t) =0 , v(x,0) = x^2-1$$
Then proceed as you were, except that
$$A_n = \{x^2-1, \cos ( (n + 1/2)\pi x )\}$$
To minimize writing, set $\omega=\pi(n+1/2)$ and integrate the product of $x^2-1$ with $\cos( \omega x)$  using the tabular method: 
$$\begin{array}{| c | c |} \hline x^2-1  & \cos \omega x \\ \hline 2x & \omega^{-1} \sin \omega x \\   \hline 2 & -\omega^{-2} \cos \omega x \\ \hline 0 & -\omega^{-3} \sin \omega x \\ \hline\end{array}$$
$$\int x^2 \cos \omega x\,dx = (x^2-1) (\omega^{-1} \sin \omega x) - 2x (-\omega^{-2} \cos \omega x) + 2 (-\omega^{-3} \sin \omega x)  +C $$
Plugging the limits, you get  $$   2 \omega^{-2} \cos \omega  - 2  \omega^{-3} \sin \omega  $$ Since the cosine vanishes at half-integer multiples of $\pi$, the only thing that remains is $- 2  \omega^{-3} \sin \omega$.
