# 非齐次方程，与时间有关的非齐次项的热传导方程的分离变量法

\begin{cases}u_t=c^2u_{xx}+f(x,t),& t>0, 0<x<L\\ u(0,t)=0, u(L,t)=0, & t>0\\ u(x,0)=g(x), & 0<x<L\end{cases}

$u(x,t)=\sum_{n=1}^{\infty}u_n(t)\sin\frac{n\pi x}{L}$

$f(x,t)=\sum_{n=1}^{\infty}f_n(t)\sin\frac{n\pi x}{L}, f_n(t)=\frac{2}{L}\int_0^Lf(x,t)\sin\frac{n\pi x}{L}dx$

$u_t=\sum_{n=1}^{\infty}u’_n(t)\sin\frac{n\pi x}{L}, u_{xx}=-\sum_{n=1}^{\infty}u_n(t)\left(\frac{n\pi}{L}\right)^2\sin\frac{n\pi x}{L}$

$\sum_{n=1}^{\infty}u’_n(t)\sin\frac{n\pi x}{L}=-c^2\sum_{n=1}^{\infty}u_n(t)\left(\frac{n\pi}{L}\right)^2\sin\frac{n\pi x}{L}+\sum_{n=1}^{\infty}f_n(t)\sin\frac{n\pi x}{L}$

$\sum_{n=1}^{\infty}\left(u’_n(t)+\left(\frac{cn\pi}{L}\right)^2u_n(t)\right)\sin\frac{n\pi x}{L}=\sum_{n=1}^{\infty}f_n(t)\sin\frac{n\pi x}{L}$

$u’_n(t)+\left(\frac{cn\pi}{L}\right)^2u_n(t)=f_n(t)$

$u_n(t)=e^{-\left(\frac{cn\pi}{L}\right)^2t}\left[\int_0^tf_n(t)e^{\left(\frac{cn\pi}{L}\right)^2t}dt+B_n\right]$

$u(x,t)=\sum_{n=1}^{\infty}u_n(t)\sin\frac{n\pi x}{L}$

$u(x,0)=g(x)=\sum_{n=1}^{\infty}u_n(0)\sin\frac{n\pi x}{L}=\sum_{n=1}^{\infty}B_n\sin\frac{n\pi x}{L}$

$g(x)=\sum_{n=1}^{\infty}B_n\sin\frac{n\pi x}{L}$

$B_n=\frac{2}{L}\int_0^Lg(x)\sin\frac{n\pi x}{L}dx$

$u(x,t)=\sum_{n=1}^{\infty}e^{-\left(\frac{cn\pi}{L}\right)^2t}\left[\int_0^tf_n(t)e^{\left(\frac{cn\pi}{L}\right)^2t}dt+\frac{2}{L}\int_0^Lg(x)\sin\frac{n\pi x}{L}dx\right]\sin\frac{n\pi x}{L}$