Someone posed the following on M.SE:

Consider the heat equation on the half line

$$u_t = ku_{xx},\quad x > 0,\, t > 0,\\ u(x,0) = 0, \,x \in\mathbb{R},\\

u(0,t) = \alpha(t),\, t > 0.

$$

This is a problem illustrated in Fetter and Walecka, but I will illustrate my own solution below.

This is derived by taking a Laplace transform of the original equation:

$$\int_0^{\infty} dt \: \frac{\partial u}{\partial t} \, \exp{(-s t)} = k \int_0^{\infty} dt \: \frac{\partial^2 u}{\partial x^2} \, \exp{(-s t)}$$

The LHS may be simplified by applying integration by parts:

$$\begin{align}\int_0^{\infty} dt \: \frac{\partial u}{\partial t} \, \exp{(-s t)} &= \underbrace{[u(x,t) \, \exp{(-s t)}]_0^{\infty}}_{\text{this is zero}} + s \int_0^{\infty} dt \: u(x,t) \, \exp{(-s t)}\\ &= s \hat{u}(x,s)\end{align}$$

The heat equation is now

$$\frac{\partial^2 }{\partial x^2} \hat{u}(x,s) = \frac{s}{k} \hat{u}(x,s)$$

The general solution to which is

$$\hat{u}(x,s) = A \exp{\left (\sqrt{\frac{s}{k}} x\right )} + B \exp{\left (-\sqrt{\frac{s}{k}} x\right )}$$

We now apply the boundary condition to determine $A$ and $B$. We will have to add a condition that wasn’t stated in the original posting, but is necessary for physical reasons:

$$\lim_{x \rightarrow \infty} u(x,t) = 0 \: \forall t \ge 0$$

This implies that $A=0$. We determine $B$ from the given boundary condition:

$$\hat{u}(0,s) = \hat{\alpha}(s)$$

which means that

$$\hat{u}(x,s) = \hat{\alpha}(s) \exp{\left (-\sqrt{\frac{s}{k}} x \right )}$$

We may now find the solution $u(x,t)$ from an inverse Laplace transform, which produces the result stated.

To illustrate how this all works, I will work a common example where $u$ represents a temperature, and the boundary condition represents the point $x=0$ being held at a fixed temperature $\alpha_0$. Then

$$\hat{\alpha}(s) = \alpha_0 \int_0^{\infty} dt \: \exp{(-s t)} = \frac{\alpha_0}{s}$$

The temperature for all $x$ and $t$ is then

$$u(x,t) = \frac{\alpha_0}{i 2 \pi} \int_{c-i \infty}^{c+i \infty} \: \frac{ds}{s} \exp{\left (-\sqrt{\frac{s}{k}} x \right )} \exp{(s t)}$$

The closed form for this ILT may be derived using Cauchy’s integral theorem, and requires integration in the complex plane. If you are unfamiliar with this, then feel free to skip this derivation, as you already have a practical way of finding a solution to the heat equation as you specified. But, again, this derivation is instructive because it gives rise to several different techniques in both complex and real integration. A similar such complex integration can be found here.

Consider the following integral in the complex $z$ plane:

$$\oint_C \frac{dz}{z} \exp{(-\sqrt{a z})} \exp{(t z)} $$

where $a>0$ and $C$ is the following contour:

We will define $\text{Arg}{z} \in (-\pi,\pi]$, so the branch is the negative real axis. There are $6$ pieces to this contour, $C_k$, $k \in \{1,2,3,4,5,6\}$, as follows.

$C_1$ is the contour along the line $z \in [c-i R,c+i R]$ for some large value of $R$.

$C_2$ is the contour along a circular arc of radius $R$ from the top of $C_1$ to just above the negative real axis.

$C_3$ is the contour along a line just above the negative real axis between $[-R, -\epsilon]$ for some small $\epsilon$.

$C_4$ is the contour along a circular arc of radius $\epsilon$ about the origin.

$C_5$ is the contour along a line just below the negative real axis between $[-\epsilon,-R]$.

$C_6$ is the contour along the circular arc of radius $R$ from just below the negative real axis to the bottom of $C_1$.

We will show that the integral along $C_2$and $C_6$ vanish in the limits of $R \rightarrow \infty$ and $\epsilon \rightarrow 0$.

On $C_2$, the real part of the argument of the exponential is

$$R t \cos{\theta} – \sqrt{a R} \cos{\frac{\theta}{2}}$$

where $\theta \in [\pi/2,\pi)$. Clearly, $\cos{\theta} < 0$ and $\cos{\frac{\theta}{2}} > 0$, so that the integrand exponentially decays as $R \rightarrow \infty$ and therefore the integral vanishes along $C_2$.

On $C_6$, we have the same thing, but now $\theta \in (-\pi,-\pi/2]$. This means that, due to the evenness of cosine, the integrand exponentially decays again as $R \rightarrow \infty$ and therefore the integral also vanishes along $C_6$.

Thus, we are left with the following by Cauchy’s integral theorem (i.e., no poles inside $C$):

$$\left [ \int_{C_1} + \int_{C_3} + \int_{C_4} + \int_{C_5}\right] \frac{dz}{z} e^{-\sqrt{a z}} e^{z t} = 0$$

On $C_4$, note that the integral is finite and nonzero as $\epsilon$ in the limit $\epsilon \rightarrow 0$:

$$\int_{C_4} \frac{dz}{z} \exp{(-\sqrt{a z})} \exp{(t z)} \sim i \int_{\pi}^{-\pi} d\phi = -i 2 \pi $$

On $C_3$, we parametrize by $z=e^{i \pi} x$ and the integral along $C_3$ becomes

$$\int_{C_3} \frac{dz}{z} \exp{(-\sqrt{a z})} \exp{(t z)} = \int_{\infty}^0 \frac{dx}{x} \: e^{-i \sqrt{a x}} e^{-x t}$$

On $C_5$, however, we parametrize by $z=e^{-i \pi} x$ and the integral along $C_5$ becomes

$$\int_{C_5} \frac{dz}{z} \exp{(-\sqrt{a z})} \exp{(t z)} = \int_0^{\infty} \frac{dx}{x} \: e^{i \sqrt{a x}} e^{-x t}$$

We may now write

$$-1 +\frac{1}{i 2 \pi} \int_0^{\infty} \frac{dx}{x} \: e^{- x t} \left ( e^{i \sqrt{a x}} – e^{-i \sqrt{a x}} \right ) + \frac{1}{i 2 \pi} \int_{c-i \infty}^{c+i \infty} \frac{ds}{s} \: e^{-\sqrt{a s}} e^{s t} = 0$$

Therefore, the ILT of $\hat{f}(s) = \frac{e^{-\sqrt{a s}}}{s}$ is given by

$$\begin{align}\frac{1}{i 2 \pi} \int_{c-i \infty}^{c+i \infty} \frac{ds}{s} \: e^{-\sqrt{a s}} e^{s t} &= 1-\frac{1}{i 2 \pi} \int_0^{\infty} \frac{dx}{x} \: e^{- x t} \left ( e^{i \sqrt{a x}} – e^{-i \sqrt{a x}} \right )\\ &=1- \frac{1}{\pi} \int_{-\infty}^{\infty} du \: \,e^{-t u^2} \frac{\sin{\sqrt{a} u}}{u} \end{align}$$

We have reduced the evaluation of the complex integral of the ILT to a single integral:

$$I = \int_{-\infty}^{\infty} du \: \,e^{-t u^2} \frac{\sin{\sqrt{a} u}}{u}$$

It turns out that this integral may be evaluated using an analog of Parseval’s Theorem for Fourier transforms, which states that, given two functions $f$ and $g$, both $\in L^2(-\infty,\infty)$, and their Fourier transforms $F$ and $G$, respectively, the following relation holds:

$$\int_{-\infty}^{\infty} dx \: f(x) \, g^*(x) = \frac{1}{2 \pi} \int_{-\infty}^{\infty} dk \: F(k) \, G^*(k)$$

$$f(x) = e^{-t x^2} \implies F(k) = \sqrt{\frac{\pi}{t}} e^{-\frac{k^2}{4 t}}$$

$$g(x) = \frac{\sin{\sqrt{a} u}}{u} \implies G(k) = \begin{cases}\\ \pi & |k| < \sqrt{a}\\0 & |k| > \sqrt{a}\end{cases}$$

(These are commonly known transforms so I will not be deriving them here. I can however point you to derivations within SE of these transforms.)

Therefore

$$\begin{align}\int_{-\infty}^{\infty} du \: \,e^{-t u^2} \frac{\sin{\sqrt{a} u}}{u} &= \frac{1}{2 \pi} \sqrt{\frac{\pi}{t}} \int_{-\sqrt{a}}^{\sqrt{a}} dk \: \pi e^{-\frac{k^2}{4 t}}\\ &= \pi \frac{2}{\sqrt{\pi}} \int_0^{\frac{1}{2} \sqrt{\frac{a}{t}}} dv \: e^{-v^2} \\ &= \pi\, \text{erf}{\left ( \frac{1}{2} \sqrt{\frac{a}{t}} \right )}\end{align}$$

Now we plug this back into the expression for the ILT, with $a=x^2/k$ and get

$$\frac{\alpha_0}{i 2 \pi} \int_{c-i \infty}^{c+i \infty} \frac{ds}{s} \: e^{-\sqrt{a s}} e^{s t} = \alpha_0 – \frac{\alpha_0}{\pi} \pi \, \text{erf}{\left ( \frac{x}{2 \sqrt{k t}} \right )} = \alpha_0\, \text{erfc}{\left ( \frac{x}{2 \sqrt{k t}} \right )}$$

where erfc is the complementary error function. Here is a plot of the temperature over $x$ for various values of $t$:

Note that the temperature is fixed at $x=0$. Also note that,over time, the heat distributes over $x$ until, eventually, the temperature becomes uniform.

Thanks, it helps me.