Analytic solution of the heat equation with a source term I have the heat equation with Dirichlet boundary conditions
$$u_t(t,x)=u_{xx}(t,x)+\sin(x)$$
$$u(t,0)=u(t,2\pi)=0$$
$$u(0,x)=u_0(x)$$
Now, without the source term I could write the solution as
$$u(t,x) = \sum_{n=1}^\infty B_n \sin(n\pi x)e^{-n^2\pi^2t}$$
where
$$B_n=2\int_0^{2\pi}u_0(x)\sin(n\pi x)dx$$
but I'm not sure what it looks like with a source term. I had a problem set question which assumed knowledge of the solution to show it converges to it's stationary form, so I'm guessing it can be derived using the homogenous equation.
 A: Hint:
the $\sin x$ source term is time independent: what happens if you add $t \sin x$ to your solution?
does it respect the PDE ? and the boundary conditions ?
A: Note that since you're on $[0,2\pi]$, the appropriate argument of the eigenfunctions is not $n \pi x$. This is not just a minor technicality since it affects how you must deal with the forcing.
Once you get that straight, consider the evolution equation for the $n$th Fourier coefficient (obtained by multiplying both sides by the $n$th eigenfunction and integrating, and pulling the time derivative out of the first term). You should find that all but one of them are just of the form $\frac{d}{dt} \hat{u}_n + \lambda_n u_n = 0$ (which is what you see in the homogeneous heat equation) while the $n=1$ equation is of the form $\frac{d}{dt} \hat{u}_1 + \lambda_1 u_1 = c$. This latter ODE is simple enough that you can just solve it.
A: Notice that $f(x) = \sin x$ solves
\begin{align}
f_{xx}+\sin x = 0,
\end{align}
with the given boundary conditions, that is, $f$ is a stationary solution to the above problem.
Next, consider the function $v=u-f$ where $u$ solves the above heat equation. Then, we see that
\begin{align}
v_t-v_{xx} = u_t-u_{xx}+f''= \sin x+f'' = 0.
\end{align}
Here, we see that $v$ measures how $u$ deviates from the stationary solution $f$. The above calculation demonstrates that the deviation satisfies a heat equation that converges to zero given the boundary conditions. In short, $u$ converges to $f$ as $t\rightarrow \infty$.
