# How to solve heat equation

Solve the Heat-Eqn. $$u_t=ku_{xx}$$ where $x,t>0$ and $u_x(0,t) =0$ and $u(x,0)=\begin{cases} 1, & 0 < x <2 \\ 0, & 2\leq x \end{cases}$

What are the solution methods?

• Separation of variables?

• Fourier Transform?

I can' t solve it by the separation of variables since $u_x(L,t)$ is ungiven and since $u(x,0)$ is a piecewise function.

Or can we solve by the Fourier Transform? It is a difficult question for me. Please help me.

My attempt:

Using separation of variables, we have $X''(x)-\lambda X(x)=0$ and $T'(t)-\lambda T(t)=0$.

If we select $\lambda=-\mu^2$, we get

$X(x)=Acos\mu x+B sin \mu x$ and $T(t)=C e^{-kt(\dfrac{n \pi}{L})^2}$

• kindly include your attempt. – Siong Thye Goh Oct 11 '17 at 16:34
• You are right, it is $u(x,0)$ – HD239 Oct 11 '17 at 17:00
• @David No, stuff will diffuse out of (0,2) shortly thereafter. – Ian Oct 11 '17 at 17:33
• The usual approach to the heat equation on the semi-infinite rod is to use symmetry to convert to the heat equation on the full infinite rod. You can find this online, for example ocw.mit.edu/courses/mathematics/… Another way to go is to look at a truncated domain $[0,M]$ and then send $M \to \infty$, but to do that you need to be careful to choose the correct boundary condition on the other end of the truncated domain. I think the correct boundary condition will be $u_x(M,t)=0$. – Ian Oct 11 '17 at 17:35
• See this reference for a solution – xidgel Oct 11 '17 at 21:29

For $0<x<2$ , the PDE has conditions $u_x(0,t)=0$ and $u(x,0)=1$ only.

Let $u(x,t)=X(x)T(t)$ ,

Then $X(x)T'(t)=kX''(x)T(t)$

$\dfrac{T'(t)}{kT(t)}=\dfrac{X''(x)}{X(x)}=-s^2$

$\begin{cases}\dfrac{T'(t)}{kT(t)}=-s^2\\X''(x)+s^2X(x)=0\end{cases}$

$\begin{cases}T(t)=c_3(s)e^{-kts^2}\\X(x)=\begin{cases}c_1(s)\sin xs+c_2(s)\cos xs&\text{when}~s\neq0\\c_1x+c_2&\text{when}~s=0\end{cases}\end{cases}$

$\therefore u(x,t)=\int_0^\infty C_1(s)e^{-kts^2}\sin xs~ds+\int_0^\infty C_2(s)e^{-kts^2}\cos xs~ds$

$u_x(x,t)=\int_0^\infty sC_1(s)e^{-kts^2}\cos xs~ds-\int_0^\infty sC_2(s)e^{-kts^2}\sin xs~ds$

$u_x(0,t)=0$ :

$\int_0^\infty sC_1(s)e^{-kts^2}~ds=0$

$C_1(s)=0$

$\therefore u(x,t)=\int_0^\infty C_2(s)e^{-kts^2}\cos xs~ds$

$u(x,0)=1$ :

$\int_0^\infty C_2(s)\cos xs~ds=1$

$C_2(s)=\delta(s)$

$\therefore u(x,t)=\int_0^\infty\delta(s)e^{-kts^2}\cos xs~ds=1$

$u(2,t)=1$

Now for $x\geq2$ , the PDE has conditions $u(2,t)=1$ and $u(x,0)=0$ only.

Similarly, $u(x,t)=\int_0^\infty C_3(s)e^{-kts^2}\sin((x-2)s)~ds+\int_0^\infty C_4(s)e^{-kts^2}\cos((x-2)s)~ds$

$u(2,t)=1$ :

$\int_0^\infty C_4(s)e^{-kts^2}~ds=1$

$C_4(s)=\delta(s)$

$\therefore u(x,t)=\int_0^\infty C_3(s)e^{-kts^2}\sin((x-2)s)~ds+\int_0^\infty \delta(s)e^{-kts^2}\cos((x-2)s)~ds=1+\int_0^\infty C_3(s)e^{-kts^2}\sin((x-2)s)~ds$

$u(x,0)=0$ :

$\int_0^\infty C_3(s)\sin((x-2)s)~ds=-1$

$\mathcal{F}_{s,s\to x-2}\{C_3(s)\}=-1$

$C_3(s)=\mathcal{F}^{-1}_{s,x-2\to s}\{-1\}=-\dfrac{2}{\pi s}$

$\therefore u(x,t)=1-\dfrac{2}{\pi}\int_0^\infty\dfrac{e^{-kts^2}\sin((x-2)s)}{s}~ds=\text{erfc}\left(\dfrac{x-2}{2\sqrt{kt}}\right)$

• This is totally wrong, because $u(2,t)$ will not be $1$ forever. Material will diffuse between the two subdomains and in fact $\lim_{t \to \infty} u(x,t)$ will be $0$ for each fixed $x$. It is possible to proceed in this general manner but then the interior boundary condition at $x=2$ is precisely this "continuous flux between subdomains" boundary condition which is not $u(2,t)=1$. – Ian Oct 12 '17 at 15:38
• I think there should be some simple mistakes somewhere, though I can't immediately tell where it is. I've solved the problem with Mathematica here, you can use that solution for comparison. – xzczd Oct 20 '17 at 12:57