Eigenfunction expansion to solve non homogenous heat equation I've been really struggling to figure out how to solve this problem using Eigenfunction expansion, I can solve it using seperation of variables. 
So this the problem is:
$$
\begin{cases}
u_t(x,t)=u_{xx}(x,t)+(t-1)\sin(\pi x), & 0<x<1\quad t>0\\
\qquad u(0,t)=0,\quad u(1,t)=0,& t>0\\
\qquad\qquad u(x,0)=x &0<x<1
\end{cases}
$$
My understanding is to first solve the homogenous part: this means searching the solution in the form:
$$ u(x,t) = T(t)X(x)$$
Then using the initial conditions we can say that:
$$ X'' + \lambda^2 X = 0$$
$$ X(0) = 0 $$
$$ X(1) = 0 $$
Thus the solution is:
$$ X(x) = A\sin(\lambda x) + B\cos(\lambda x)$$
Thus $\lambda_n = n\pi$ and $X_n(x) = \sin(n \pi x)$.
Now I know that the non-homogenous part can be written as
$$ f_n(t) = 2 \int_0^1 (t-1)\sin(\pi x)\sin(n \pi x) dx$$
From here on, I'm really confused about how to proceed. Been trying to read several resources but they don't seem very clear to me. Any guidance on where to go from here would be greatly appreciated. Thank you.
 A: You can look at the separation of variables problem in $x$ for the homogeneous problem, which leads to $X''+\lambda X=0$ with $X(0)=X(1)=0$. The associated eigenfunctions are
$$
           X_n(x)=\sin(n\pi x),\;\; n=1,2,3,\cdots.
$$
This set will be an orthonormal basis of $L^2[0,1]$, which means that your solution $u(x,t)$ can be expanded in such functions for each fixed $t$:
$$
                  u(x,t)= \sum_{n=1}^{\infty}A_n(t)\sin(n\pi x).
$$
The functions $A_n(t)$ are determined by the equation and by the initial conditions. You need,
$$
             \sum_{n=1}^{\infty}A_n'(t)\sin(n\pi x) = -\sum_{n=1}^{\infty}A_n(t)n^2\pi^2\sin(n\pi x)+(t-1)\sin(\pi x).
$$
That gives equations for $A_n$:
$$
                  A_1'(t)=-\pi^2A_1(t)+(t-1) \\
                         A_n'(t)=-n^2\pi^2 A_n(t),\;\;\; n=2,3,\cdots.
$$
The initial value problems for $A_n(t)$ have endpoint conditions at $t=0$ determined by the initial conditions:
$$
             x = u(x,0) = \sum_{n=1}^{\infty}A_n(0)\sin(n\pi x)
$$
So, $A_n(0)$ are the Fourier coefficients given by
$$
                  A_n(0)= \frac{\int_{0}^{1}x\sin(n\pi x)dx}{\int_0^1 \sin^2(n\pi x)dx}
$$
Finally,
$$
                    A_n(t) = A_n(0) e^{-n\pi t},\;\; n=2,3,4,\cdots .
$$
The equation for $A_1$ I leave to you.
