# Heat Equation with boundary conditions

I have the following PDE:

$$\begin{cases} u_t = u_{xx}, \ x\in (0, 2), \ t>0 \\[6pt] u(x, 0) = \sin\frac{\pi x}{2}, \ x \in [0, 2] &(i)\\[6pt] u(0, t) = 1, \ t>0 &(ii)\\[6pt] u(2, t) = 0, \ t>0 &(iii)\\[6pt] \end{cases}$$

I know how to solve boundary problems by using the method of separation of variables (and Fourier Series), but in this case I have trouble with the last condition.

Given that I have obtained the solution of the first ODE in the form of $$X(x) = c_1\cos(px) + c_2\sin(px)$$ (where $$p$$ is $$\lambda = -p^2$$), from the first boundary condition I will get that $$c_1=1$$.

By plugging it in the second boundary condition I obtain the following: $$\cos(2p) + c_2\sin(2p) = 0$$ I am looking for a hint on how to proceed from here. Do I need to express $$p$$ in terms of $$c_2$$ and continue from there? And if so, how can I proceed with finding the coefficients? Thanks.

• Any reason you choose $\lambda = -p^2$ vs $\lambda = p^2$? – Cuhrazatee Feb 20 '19 at 20:24
• @Cuhrazatee, because when $\lambda$ is positive, the only solution is the trivial one, if I'm not mistaken – aniri Feb 20 '19 at 20:29
• Yeah, that's right. I didn't see that at first sight. – Cuhrazatee Feb 20 '19 at 22:25

You can't immediately proceed with separation of variables since the boundary conditions aren't homogeneous. To "fix" this, break up the solution into $$u(x,t) = w(x) + v(x,t)$$. Here, $$w(x)$$ is the steady-state solution that exactly matches the boundary conditions:

$$\begin{cases} w_{xx} = 0 \\ w(0) = 1 \\ w(2) = 0 \end{cases}$$

Solving the above gives $$w(x) = \frac12(2-x)$$. Then, it remains to solve

$$\begin{cases} v_t = v_{xx} \\ v(0,t) = v(2,t) = 0 \\ v(x,0) = \sin \dfrac{\pi x}{2} - \frac12(2-x) \end{cases}$$

which can be done with separation of variables. The general solution is

$$v(x,t) = \sum_{n=1}^\infty c_n\sin\left(\frac{n\pi x}{2}\right)e^{-n^2\pi^2 t/4}$$

You can take it from here.

• thank you for the help! – aniri Feb 21 '19 at 14:41