Solving inhomogeneous heat equation Solve the inhomogeneous heat equation $u_t=c^2u_{xx} +\sin(5\pi x)$ for all $0 < x < 1, t > 0$ subject to homogeneous Dirichlet boundary conditions $u(t,0)=u(t,1)=0$ and initial condition $u(0,x) =4\sin(3\pi x)+9\sin(7\pi x)$.
Solved it as
$$v(x,t)=\sum_{n=1}^{\infty}\bigg[\frac{\int_{0}^{1}[4\sin(3\pi x)+9\sin(7\pi x)]\cdot\sin(n\pi x)dx}{\int_{0}^{1}\sin^2(n\pi x)dx}\cdot e^{-n^2\pi^2c^2t}\cdot\int_{0}^{t}\frac{\int_{0}^{1}\sin(5\pi x)\cdot\sin(n\pi x)dx}{\int_{0}^{1}\sin^2(n\pi x)dx}\cdot e^{n^2\pi^2c^2t}dx\cdot\sin(n\pi x)\bigg]$$

In order to solve non-homogeneous heat equations, assume that $w(x,t)=u(x,t)+\phi(x)$, where $\phi$ is a function yet to be determined.
So, we've $u_{xx} = w_{xx} - \phi''$ and $u_{t} = w_{t}$. If we substitute this in to our equation, then we have to solve the new problem
$\begin{cases}
w_t - c^2 w_{xx} - c^2 \phi'' - \sin{5 \pi x} = 0\\
w(0,t) - \phi(0) = 0\\
w(1,t) = \phi(1) = 0\\
w(x,0) - \phi(x) = 4\sin{3\pi x} + 9\sin{7 \pi x}
\end{cases}
$
So we really want to choose $\phi$ so that $-c^2\phi^2 - \sin{5 \pi x} = 0$, the choice of $\phi = \frac{1}{25 \pi^2 c^2}\sin{5 \pi x}$ works. And so we want to solve the new equation:
$\begin{cases}
w_t - c^2 w_{xx}  = 0\\
w(0,t)  = 0\\
w(1,t)  = 0\\
w(x,0) = 4\sin{3\pi x} +\frac{1}{25 \pi^2 c^2}\sin{5 \pi x} + 9\sin{7 \pi x}
\end{cases}
$
At this point, this should be easy to do, separation of variables yields that the resulting corresponding Fourier series is a sine series, and we can easily match what the coefficients according to our initial condition. We have
$$w(x,t) = \sum_{n=1}^{\infty} b_n e^{-(cn\pi)^2t}\sin{n\pi x}$$
Matching coefficients, we see $b_3 = 4$, $b_5 = \frac{1}{25 \pi^2 c^2}$, and $b_7 = 9$, and $b_n = 0$ otherwise.
Thus we have
$$w(x, t) = 4 e^{-(3c\pi)^2t}\sin{3\pi x} + \frac{1}{25 \pi^2 c^2} e^{-(5c\pi)^2t}\sin{5\pi x} + 9 e^{-(7n\pi)^2t}\sin{7\pi x}$$
Now, remember that $u(x, t) = w(x, t) - \phi(x)$, the full solution is
$$u(x, t) = 4 e^{-(3c\pi)^2t}\sin{3\pi x} + \frac{1}{25 \pi^2 c^2} e^{-(5c\pi)^2t}\sin{5\pi x} + 9 e^{-(7n\pi)^2t}\sin{7\pi x} - \frac{1}{25 \pi^2 c^2}\sin{5 \pi x}$$
