I have solved the heat equation and have gotten to the stage of getting a general solution $$u(x,t)=x+\sum^\infty_{n=1} c_n \sin(\pi n x)e^{-\pi^2 n^2 t}$$
And I have the initial condition $$u(x,0)=x+\sin(\pi x)$$
How do I incorporate the initial condition to get the particular solution of $$u(x,t)=x+\sin(\pi x)e^{-\pi^2 t}$$
Set $t=0$ and you get
$$u(x,0)=x+\sum_{n=1}^\infty c_n\sin(\pi nx)=x+\sin(\pi x)\\ g(x):=u(x,0)-x=\sum_{n=1}^\infty c_n\sin(\pi nx)=\sin(\pi x)$$
But since $\int_0^1 \sin(\pi nx)\sin(\pi mx)\,dx=\begin{cases}\frac 1 2&\text{if }n=m\\0 &\text{if }n\neq m\end{cases}$
And since $g(x)$ is a $L^2[0,1]$ function, it must hold
$$c_n=2\int_0^1 g(x)\sin(\pi nx)\,dx=2\int_0^1 \sin(\pi x)\sin(\pi nx)\,dx=\begin{cases}1&\text{if }n=1\\0&\text{if not}\end{cases}$$