$\renewcommand{\Re}{\operatorname{Re}}$
$\renewcommand{\Im}{\operatorname{Im}}$
$\newcommand{\erf}{\operatorname{erf}}$
$\newcommand{\dag}{\dagger}$
$\newcommand{\const}{\mathrm{const}}$
$\newcommand{\arcsinh}{\operatorname{arcsinh}}$
#[Chapter 3. Heat equation in 1D](id:chapter-3)
In this Chapter we consider 1-dimensional heat equation (also known as diffusion equation). Instead of more standard Fourier method (which we will postpone a bit) we will use the method of *self-similar solutions*.
##3.1. 1D Heat equation
----------------
> 1. [Introduction](#sect-3.1.1)
> 2. [Self-similar solutions](#sect-3.1.2)
> 3. [References](#sect-3.1.3)
###Introduction
*Heat equation* which is in its simplest form
\begin{equation} u\_t = ku\_{xx}
\label{eq-3.1.1}
\end{equation}
is another classical equation of mathematical physics and it is very different from wave equation. This equation describes also a diffusion, so we sometimes will refer to it as *diffusion equation*. It also describes random walks (see [Project "Random walks"](./S3.A.html)).
###Self-similar solutions
We want to solve IVP for equation (\ref{eq-3.1.1}) with $t\>0$,
$-\infty\< x \< \infty$. Let us plug
\begin{equation}
u\_{\alpha,\beta,\gamma}(x,t)=\gamma u(\alpha x, \beta t).
\label{eq-3.1.2}
\end{equation}
**Proposition 1.**
If $u$ satisfy (\ref{eq-3.1.1}) then $u\_{\alpha,\beta,\gamma}$ also satisfies (\ref{eq-3.1.1}) provided $\beta =\alpha^2$.
*Proof* is just by calculation. Note that $\beta=\alpha^2$ because
one derivative with respect to $t$ is "worth" of two derivatives with
respect to $x$.
We impose another assumption:
**Condition 1.** Total heat energy
\begin{equation}
I(t):=\int\_{-\infty}^\infty u(x,t)\, dx
\label{eq-3.1.3}
\end{equation}
is finite and does not depend on $t$.
The second part is due to the first one. Really (not rigorous) integrating (\ref{eq-3.1.1}) by $x$ from $-\infty$ to $+\infty$ and assuming that $u\_x (\pm \infty)=0$ we see that $\partial\_t I(t)=0$.
Note that $\int\_{-\infty}^\infty u\_{\alpha,\beta,\gamma} \,dx
= \gamma |\alpha|^{-1} \int\_{-\infty}^\infty u\,dx$ and to
have them equal we should take $\gamma=|\alpha|$ (actually we restrict ourselves by $\alpha\>0$). So (\ref{eq-3.1.2}) becomes
\begin{equation}
u\_{\alpha}(x,t)=\alpha u(\alpha x, \alpha^2 t).
\label{eq-3.1.4}
\end{equation}
This is *transformation of similarity*. Now we are looking for a *self-similar* solution of (\ref{eq-3.1.1}) i.e. solution such that $u\_{\alpha}(x,t)=u(x,t)$ for all $\alpha\>0, x, t\>0$. So we want
\begin{equation}
u(x,t)=\alpha u(\alpha x, \alpha^2 t)\qquad \forall \alpha\>0, t\>0, x. \label{eq-3.1.5}
\end{equation}
We want to get rid off one of variables; so taking $\alpha = t^{-\frac{1}{2}}$ we get
\begin{equation}
u(x,t)=t^{-\frac{1}{2}} u(t^{-\frac{1}{2}} x, 1) =
t^{-\frac{1}{2}} \phi (t^{-\frac{1}{2}} x)
\label{eq-3.1.6}
\end{equation}
with $\phi (\xi ):= u(\xi, 1)$. Equality (\ref{eq-3.1.6}) is equivalent to (\ref{eq-3.1.5}).
Now we need to plug it into (\ref{eq-3.1.1}). Note that
\begin{multline\*}
u\_t = -\frac{1}{2} t^{-\frac{3}{2}}\phi (t^{-\frac{1}{2}}x) +
t^{-\frac{1}{2}}\phi '(t^{-\frac{1}{2}}x)\times
\bigl(-\frac{1}{2}t^{-\frac{3}{2}}x\bigr)= \\\\
-\frac{1}{2} t^{-\frac{3}{2}} \bigl( \phi (t^{-\frac{1}{2}}x) +
t^{-\frac{1}{2}}x \phi' (t^{-\frac{1}{2}}x)\bigr)
\end{multline\*}
and
\begin{equation\*}
u\_x = t^{-1}\phi ' (t^{-\frac{1}{2}}x), \qquad
u\_{xx} = t^{-\frac{3}{2}}\phi '' (t^{-\frac{1}{2}}x)
\end{equation\*} and after multiplication by
$t^{\frac{3}{2}}$
and plugging $t^{-\frac{1}{2}}x=\xi$ we arrive to
\begin{equation}
-\frac{1}{2} \bigl( \phi (\xi) + \xi \phi '(\xi )\bigr)= k\phi '' (\xi). \label{eq-3.1.7}
\end{equation}
Good news: it is ODE. Really good news:
$\phi (\xi) + \xi \phi '(\xi )= \bigl( \xi\phi(\xi)\bigr)'$. Then integrating we get
\begin{equation}
-\frac{1}{2} \xi \phi (\xi)= k\phi ' (\xi).
\label{eq-3.1.8}
\end{equation}
**Remark 1.**
Sure there should be $+C$ but we are looking for a solution fast decaying with its derivatives at $\infty$ and it implies that $C=0$.
Separating in (\ref{eq-3.1.8}) variables and integrating we get
\begin{equation\*}
\frac{d\phi}{\phi}= -\frac{1}{2k}\xi d\xi \implies
\log \phi = -\frac{1}{4k}\xi^2+\log c\implies \phi(\xi)= ce^{-\frac{1}{4k}\xi^2} \end{equation\*}
and plugging
into (\ref{eq-3.1.6}) we arrive to
\begin{equation}
u(x,t)= \frac{1}{2\sqrt {\pi kt}} e^{-\frac{x^2}{4kt}}.
\label{eq-3.1.9}
\end{equation}
**Remark 2.**
We took $c=\frac{1}{2\sqrt {\pi k}}$ to satisfy $I(t)=1$. Really,
\begin{equation\*}
I(t)=c\int\_{-\infty}^{+\infty} t^{-\frac{1}{2}} e^{-\frac{x^2}{4kt}}\,dx =
c\sqrt{4k}\int\_{-\infty}^{+\infty} e^{-z^2}\,dz=
2c\sqrt{k\pi} \end{equation\*} where we changed variable
$x=z/\sqrt{2kt}$ and used the equality
\begin{equation}
J= \int\_{-\infty}^{+\infty} e^{-x^2}\,dx=\sqrt{\pi}.
\label{eq-3.1.10}
\end{equation}
To prove (\ref{eq-3.1.10}) just note that
\begin{equation\*}
J^2= \int\_{-\infty}^{+\infty} \int\_{-\infty}^{+\infty}\
e^{-x^2}\times e^{-y^2}\,dxdy=
\int\_0^{2\pi} d\theta \int\_0^\infty e^{-r^2}rdr =\pi
\end{equation\*}
where we used polar coordinates; since $J\>0$ we get (\ref{eq-3.1.10}).
**Remark 3.**
Solution which we got is a very important one. However we have a problem understanding what is $u|\_{t=+0}$ as $u(x,t)\to 0$ as $t\to +0$ and $x\ne 0$ but $u(x,t)\to \infty$ as $t\to +0$ and $x= 0$ and
$\int\_{-\infty}^\infty u(x,t)\,dx=1$. In fact $u|\_{t=+0}=\delta(x)$ which is *Dirac $\delta$-function* which actually is not an ordinary function but a *distribution*.
To work around this problem we consider
\begin{equation}
U(x,t)=\int\_{-\infty}^x u(x,t)\,dx.
\label{eq-3.1.11}
\end{equation}
We claim that
**Proposition 2.**
1. $U(x,t)$ also satisfies (\ref{eq-3.1.1}).
2. $U(x,0)=\theta(x)=\left\\{\begin{aligned} &0 \qquad &&x\<0,\\\\
&1 && x\>0. \end{aligned}\right.$
*Proof.* Plugging $u=U\_x$ into (\ref{eq-3.1.1}) we see that $(U\_t-kU\_{xx})\_x=0$ and then $(U\_t-kU\_{xx})=\\Phi(t)$. However one can see easily that as $x\to -\infty\ $ $U$ is fast decaying with all its derivatives and therefore $\\Phi(t)=0$ and (a) is proven.
Note that
\begin{equation}
U(x,t)=\frac{1}{\sqrt{4\pi }}
\int\_{-\infty}^{\frac{x}{\sqrt{4kt}}} e^{- z^2}\,dz=:
\frac{1}{2}+\frac{1}{2}\erf \bigl(\frac{x}{\sqrt{4kt}}\bigr)
\label{eq-3.1.12}
\end{equation}
with
\begin{equation}
\erf(z):= \frac{2}{\sqrt{\pi}}\int\_0^z e^{-z^2}\,dz
\label{Erf}\tag{erf}
\end{equation}
and that an upper limit in integral tends to $\mp \infty$ as $t\to+0$ and
$x\lessgtr 0$. Then since an integrand is very fast decaying at $\mp \infty$ we using (\ref{eq-3.1.10}) arrive to (b).
**Remark 4.**
1. One can construct $U(x,t)$ as a self-similar solution albeit with $\gamma=1$.
2. We can avoid analysis of $U(x,t)$ completely just by noting that $u(x,t)$ is a *$\delta$-sequence* as $t\to +0$: $u(x,t)\to 0$ for all $x\ne 0$ but $\int\_{-\infty}^\infty u(x,t)\,dx=1$.
Consider now a smooth function $g(x)$, $g(-\infty)=0$ and note that
\begin{equation}
g(x)=\int \_{-\infty}^\infty \theta (x-y) g'(y)\,dy.
\label{eq-3.1.13}
\end{equation}
Really, the r.h.e. is $\int\_{-\infty}^x g'(y)\,dy=g(x)-g(-\infty)$.
Also note that $U(x-y,t)$ solves the IVP with initial condition
$U(x-y,+0)=\theta (x-y)$. Therefore
$u(x,t)=\int \_{-\infty}^\infty U (x-y,t) g'(y)\,dy$ solves the IVP with initial condition $u(x,+0)=g(y)$. Integrating by parts with respect to $y$ we arrive to $u(x,t)=\int \_{-\infty}^\infty U\_x (x-y,t) g(y)\,dy$ and finally to \begin{equation}
u(x,t)=\frac{1}{2\sqrt{k\pi t}}\int \_{-\infty}^\infty
e^{-\frac{(x-y)^2}{4kt}} g(y)\,dy.
\label{eq-3.1.14}
\end{equation}
So we have proven:
**Proposition 3.**
Formula (\ref{eq-3.1.14}) gives us a solution of
\begin{align}
&u\_t = ku\_{xx}\qquad &&-\infty \