Solve the 1-dimensional heat equation with separation of variables Solve the 1-dimensional heat equation subject to the boundary and the initial condition given by
$$\frac{\partial u}{\partial t}=\frac{\partial ^2u}{\partial x^2}, 0<x<1,t>0\\ u(0,t)=0, u( 1,t)=1, t>0\\u(x,0)=1-x , 0<x<1$$
Let $u(x,t)=X(x)T(t)$ then the given pde into
$X(x)T'(t)=X''(x)T(t)\implies \frac{X''(x)}{X(x)}=\frac{T'(t)}{T(t)}=k\\
X''(x)-kX(x)=0, T'(t)-kT(t)=0$
now $u(0,t)=X(0)T(t)=0\implies X(0)=0$ and
$u(1,t)=X(1)T(t)=1$
sorry I'm unable follow from here, any help?
 A: To solve it using method of separation of variables, seek a particular solution of the form $u_{p}(x,t) = (1-0)x + 0 = x$ and consider the related homogeneous problem
$$ \frac{\partial v}{\partial t} = \frac{\partial^{2}v}{\partial x^{2}}, 0<x<1,t>0 $$
$$ v(0,t)=v(1,t)=0, t>0 $$
$$ v(x,0) = 1-x - u_{p}(x,0) = 1-2x, 0<x<1 .$$
Then the solution to given PDE will be $u(x,t) = u_{p}(x,t)+v(x,t).$
$\textbf{Full Solution:}$
Let $v(x,t) = X(x)T(t)$, then you will get
$$ X'' - kX=0, T'-kT=0. $$
Because $v(0,t)=v(1,t)=0$, implies $X(0)=X(1)$ otherwise we will get only trivial solution. Now, there will be three cases $k<0,k=0,k>0$. You can easily neglect two cases $k=0,k>0$ as only trivial solution will exist in these cases. So, take $k=-\lambda^2$ for $\lambda$ positive, then you will get
$$ X(x) = C_{1} \cos(\lambda x) + C_{2} \sin(\lambda x) $$ and using $X(0)=X(1)=0$, you will get $X_{n}(x) = a_{n} \sin(n \pi x).$ and $T_{n}(t) = b_{n}e^{-(n \pi)^{2}t}$. Therefore, $$v_{n}(x,t) =c_{n} \sin(n \pi x)e^{-(n \pi)^{2}t}. $$ Now, by principle of superposition
$$ v(x,t) = \sum_{n=1}^{\infty} c_{n} \sin(n \pi x)e^{-(n \pi)^{2}t}.$$ Because $v(x,0) = 1-2x = \sum_{n=1}^{\infty} c_{n} \sin(n \pi x) .$
$$ \implies c_{n} = 2 \int_{0}^{1}(1-2x) \sin(n \pi x) dx = 2\frac{(1+(-1)^n)}{n \pi}. $$ So, we have
$$ u(x,t) = \sum_{n=1}^{\infty} 2\frac{(1+(-1)^n)}{n \pi} e^{-(n \pi)^{2}t}\sin(n \pi x) + x. $$
