# 齐次方程，非齐次边界条件与时间有关的分离变量法

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

$u=v+w, v(0,t)=\phi(t), v(L,t)=\psi(t)$

$v(x,t)=\frac{\psi(t)-\phi(t)}{L}x+\phi(t)$

$u_t=v_t+w_t=\frac{\psi'(t)-\phi'(t)}{L}x+\phi'(t)+w_t$

$u_{xx}=v_{xx}+w_{xx}=w_{xx}$

\begin{cases}w_t=c^2w_{xx}-\frac{\psi'(t)-\phi'(t)}{L}x-\phi'(t),& t>0, 0<x<L\\ w(0,t)=0, w(L,t)=0, & t>0\\ w(x,0)=g(x)-\frac{\psi(0)-\phi(0)}{L}x+\phi(0), & 0<x<L\end{cases}

$w(x,0)=g(x)-\frac{g(L)-g(0)}{L}x+\phi(0), 0<x<L$

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

$w_n(t)=e^{-\left(\frac{cn\pi}{L}\right)^2t}\left[\int_0^tf_n(\tau)e^{-\left(\frac{cn\pi}{L}\right)^2\tau}d\tau+C_n\right]$

$f_n(t)=\frac{2}{L}\int_0^L\left(\frac{\psi(t)-\phi(t)}{L}x+\phi(t)\right)\sin\frac{n\pi x}{L}dx$

$C_n=\frac{2}{L}\int_0^L\left(g(x)-\frac{\psi(0)-\phi(0)}{L}x+\phi(0)\right)\sin\frac{n\pi x}{L}dx$

$u=v+w=\frac{\psi(t)-\phi(t)}{L}x+\phi(t)+\sum_{n=1}^{\infty}w_n(t)\sin\frac{n\pi x}{L}$