Heat equation with time dependent boundary conditions?

Solution 1:

Let's back up a little bit and provide a comprehensive answer to these types of problems.

Suppose $u(x,t)$ solves \begin{align} u_t&=u_{xx}, \qquad 0 < x < \ell,\ t>0,\\ u(0,t)&=f(t),\\ u(\ell, t)&=g(t),\\ u(x,0)&=h(x). \end{align} In the subsequent work, we will impose whatever smoothness conditions on the initial and boundary data we need to get convergence of the involved series.

First, standard separation of variables shows that the solution to the problem with homogeneous BCs is $$u(x,t)=\sum_{n=1}^\infty b_n\sin(\sqrt{\lambda_n}\,x)e^{-\lambda_n t},$$ where $\lambda_n=(n\pi/\ell)^2$, $n=1,2,\dots$ In other words, for each fixed $t>0$, $$u(x,t)=\sum_{n=1}^\infty u_n(t)\sin(\sqrt{\lambda_n}\,x)\quad\text{where}\quad u_n(t)={2\over \ell}\int_0^\ell u(x,t)\sin(\sqrt{\lambda_n}\,x)\,dx.$$ (This is a key observation. I hope the notation isn't confusing: $u_n$ represents the coefficients in the series for $u$, not a partial derivative.)

Then, differentiating the series above, define $v_n(t)$ and $w_n(t)$ as the coefficients in the series for ${\partial u\over \partial t}$ and ${\partial^2 u\over \partial x^2}$, respectively:

\begin{align} {\partial u\over \partial t}&=\sum_{n=1}^\infty v_n(t)\sin(\sqrt{\lambda_n}\,x) \quad\text{where}\quad v_n={2\over \ell}\int_0^\ell {\partial u\over \partial t}\sin(\sqrt{\lambda_n}\,x)\,dx={du_n\over dt},\\ {\partial^2 u\over \partial x^2}&=\sum_{n=1}^\infty w_n(t)\sin(\sqrt{\lambda_n}\,x) \quad\text{where}\quad w_n={2\over \ell}\int_0^\ell {\partial^2 u\over \partial x^2}\sin(\sqrt{\lambda_n}\,x)\,dx. \end{align}

Integrating the $w_n(t)$ by parts, simplifying the trig terms, and applying the BCs, we get \begin{align} w_n(t)&=-{2\over \ell}\int_0^{\ell} \lambda_n u(x,t)\sin(\sqrt{\lambda_n}\,x)\,dx\\ &\qquad\qquad+{2\over \ell}\left[u_x(x,t)\sin(\sqrt{\lambda_n}\,x)-\sqrt{\lambda_n}\,u(x,t)\cos(\sqrt{\lambda_n}\,x)\right]\Bigg|_{x=0}^{x=\ell}\\ &=-\lambda_nu_n(t)+\underbrace{{2\sqrt{\lambda_n}\over \ell}\left[f(t)+(-1)^{n+1}g(t)\right]}_{F(t)}. \end{align}

From the PDE, $$u_t=u_{xx}\implies v_n(t)=w_n(t)\implies {du_n\over dt}=-\lambda_n u_n(t)+F(t),$$ and thus the coefficients $u_n(t)$ we seek are found by solving the (ODE!) initial-value problem \begin{align} {du_n\over dt}+\lambda_nu_n(t)&=F(t),\\ u_n(0)&={2\over \ell}\int_0^\ell h(x)\sin(\sqrt{\lambda_n}\,x)\,dx, \end{align} by the method of your choice.

This is called the method of eigenfunction expansions. Transform methods are also available, but that is a separate post.

Hope that helps.