Let $u(x,t)$ be the solution of $u_t(x,t)-u_{xx}(x,t) = \cos(x)$ on the interval $(x,t) \in [0.\pi] \times (0, \infty)$ with boundary conditions 
Let $u(x,t)$ be the solution of $u_t(x,t)-u_{xx}(x,t) = \cos(x)$ on
   the interval $(x,t) \in [0,\pi] \times (0, \infty)$ with boundary
   conditions $u(0,t) = 0$ and $u(\pi,t) = \sin t$ together with initial
   conditions $u(x,0) = \sin(x)$. Expand the solution $u(x,t)$ by the
   Fourier sine series: $$u(x,t) = \sum U_n(t)\sin(nx)$$
Find the ODE for each $U_n(t)$.

I am having some problem intepretating this question. Do I need to solve the inhomogenous diffusion problem first? Then i express the solution as a fourier sine series? Anyone can give me a push in the right direction would be appreciated. As I am reading Strauss PDE book, i see that the question although looks like a diffusion question, however the interval is neither half interval nor full interval... So i am really confused.
 A: Check out this guide for solving inhomogeneous equations.
Since there are two different inhomogeneties, we can split up the solution to two parts $$u(x,t) = v(x,t) + w(x,t)$$
where $w(x,t)$ is a function that only satisfies the inhomogeneous boundary condition. For convenience, we choose a function such that $w_{xx} = 0$, therefore $w(x,t) = \dfrac{x}{\pi}\sin t$
This leaves
$$ v_t - v_{xx} = u_t - u_{xx} - w_t = \cos x - \frac{x}{\pi}\cos t $$
with boundary conditions 
$$v(0,t)=v(\pi,t)=0$$ 
$$v(x,0) = u(x,0) - w(x,0) = \sin x $$
We assume an ansatz of the form
$$ v(x,t) = \sum_{n=1}^{\infty} T_n(t)\sin(nx) $$
This result came from performing separation of variables on the homogeneous equation, and that any function can be expressed as a linear combination of
$$ f(x,t) = \sum f_n(t) X_n(t) $$
where $X_n(x)=\sin(nx)$ are eigenfunctions of the homogeneous problem
Plugging into the equation and the remaining B.C,
$$ v_t - v_{xx} = \cos x - \frac{x}{\pi}\cos t = \sum_{n=1}^{\infty}\big[{T_n}'(t)+n^2T_n(t)\big]\sin(nx) \tag{1} $$
$$ v(x,0) = \sin x = \sum_{n=1}^{\infty} T_n(0)\sin(nx) \tag{2} $$
The Fourier coefficients give a family of ODEs
$$ {T_n}'(t)+n^2T_n(t) = \frac{2}{\pi} \int_0^\pi \left(\cos x - \frac{\cos t}{\pi} x\right)\sin(nx)\ dx $$
$$ T_n(0) = \frac{2}{\pi}\int_0^\pi \sin x\sin(nx) \ dx $$
Solving the integrals, we obtain
$$ {T_1}' + T_1 = -\frac{2}{\pi}\cos t, \qquad T_1(0) = 1 $$
$$ {T_n}' + n^2T_n = \frac{2}{\pi}\left[\big(1+(-1)^n\big)\frac{n}{n^2-1}+\frac{(-1)^n}{n}\cos t \right], \qquad \ T_{n\ge 2}(0) = 0 $$
These are easily solved using undetermined coefficients
$$ T_n = c_n e^{-n^2t} + A_n\sin t + B_n\cos t + D_n $$
