---
title: "Heat Equation"
type: concept
related: [Damped Heat Equation, Two Dimensional Heat Equation]
source: https://www.jemoka.com/posts/kbhheat_equation/
confidence: high
status: active
---

see also two-dimensional heat equation the following relates to 1d
heat distributes by &ldquo;diffusing&rdquo;; this is heat \(u\) diffusing across a plate
\begin{equation} \pdv{u}{t} = \pdv[2]{u}{x} \end{equation}
we have, with Dirichlet Conditions:
\begin{equation} u_{k}(t,x) = \sum b_{k} e^{ - \frac{k^{2} \pi^{2}}{l^{2}} t } \sin \qty( \frac{k \pi x}{l}) \end{equation}
and with Neumann Conditions:
\begin{equation} u_{k}(t,x) = \sum b_{k} e^{ - \frac{k^{2} \pi^{2}}{l^{2}} t } \cos \qty( \frac{k \pi x}{l}) \end{equation}
with infinite boundaries:
\begin{equation} U(t,x) =\frac{1}{\sqrt{4 \pi \alpha t}} \int_{\mathbb{R}} f(y) e^{-\frac{(x-y)^{2}}{4\alpha t}} \dd{y} \end{equation}
general system:
\begin{equation} \begin{cases} A&rsquo;(t) = \lambda A(t) \\ B&rsquo;&rsquo;(x) = \lambda B(x) \end{cases} \end{equation}
Removing a constant Consider a function:
\begin{equation} t = c \tau \end{equation}
you can remove the constant by finanglisng because the constant drops out when scaled (i.e. you can just scale your results back TODO check this).
damping damped heat equation
Solving Heat Equation Consider the one dimensional heat equation:
\begin{equation} \pdv{u}{t} = \pdv[2]{u}{x} \end{equation}
&ldquo;well posed-ness&rdquo; of to this problem requires two sets of initial conditions: one &ldquo;boundary condition&rdquo;
Initial Condition Because the expression is linear by time, we need one initial condition; let&rsquo;s say its some function in \(x\):
\begin{equation} f_{0}(x) \end{equation}
Solving Let&rsquo;s make an educated guess:
\begin{equation} u(t,x) = A(t) B(x) \end{equation}
Consider:
\begin{equation} \pdv{u}{t} = A&rsquo;(t)B(x) \end{equation}
\begin{equation} \pdv[2]{u}{x} = A(t) B&rsquo;&rsquo;(x) \end{equation}
This results in:
\begin{equation} A&rsquo;(t) B(x) = A(t) B&rsquo;&rsquo;(X) \end{equation}
meaning, we can rearrange and integrate:
\begin{equation} \frac{A&rsquo;(t)}{A(t)} = \frac{B&rsquo;&rsquo;(x)}{B(x)} \end{equation}
You will note that taking a derivative by \(t\) on one side tells us that the right side is \(0\), and taking derivative of \(x\) on the other results in left side is \(0\). This tell us that this function is constant in both \(t\) and \(x\). Meaning:
\begin{equation} \frac{A&rsquo;(t)}{A(t)} = \frac{B&rsquo;&rsquo;(x)}{B(x)} = \lambda \end{equation}
This results in a renewed system:
\begin{equation} \begin{cases} A&rsquo;(t) = \lambda A(t) \\ B&rsquo;&rsquo;(x) = \lambda B(x) \end{cases} \end{equation}
Solving using Dirichlet Conditions Finding \(\lambda\) using Boundary Conditions
Now, recall from our system:
\begin{equation} B&rsquo;&rsquo;(x) = \lambda B(x) \end{equation}
Its solutions are
\begin{equation} B(x) = c_1 e^{\sqrt{\lambda}x} + c_2 e^{-\sqrt{\lambda}x} \end{equation}
Recall Dirichlet Conditions:
\begin{equation} u(t,0) = u(t, l)= 0 \end{equation}
This tells us that \(B(0) = 0\), \(B(l) = 0\).
At \(B(0)\), this gives us that \(c_1 + c_2 = 0\), meaning \(c_2 = -c_1\)
At \(B(l) = 0 = c_1 \qty( e^{\sqrt{\lambda}l} - e^{-\sqrt{\lambda}l})\). Dividing \(c_1\) to both sides, we obtain \(e^{2\sqrt{\lambda} l} = 1\).
We finally can obtain \(\lambda\). One obvious answer is \(\lambda = 0\). But, there are other fun things we can do:
Aside:
Recall, if we desire
\begin{equation} e^{i\theta} = \cos \theta + i \sin \theta = 1 \end{equation}
This gives:
\begin{equation} \theta = 2\pi k \end{equation}
Therefore, recall that we obtained \(e^{2\sqrt{\lambda}l}\), we obtained:
\begin{equation} 2\sqrt{\lambda}l = 2\pi k i \end{equation}
Solving for \(\lambda\), we finally get solutions:
\begin{equation} \lambda_{k} = \frac{-k^{2}\pi^{2}}{l^{2}} \end{equation}
for \(k = 0, 1, 2, 3\); this condition called &ldquo;quantization&rdquo;
Solving Again
Now that we know \(\lambda\), we can say:
\begin{equation} \begin{cases} A&rsquo;(t) = \frac{-k^{2}\pi^{2}}{l^{2}} A(t) \\ B&rsquo;&rsquo;(x) = \frac{-k^{2}\pi^{2}}{l^{2}} B(x) \end{cases} \end{equation}
And then we can proceed to solve everything again. [a little lost, but in theory \(\cos(x)\) drops out after solving].
This Gives us eventually:
\begin{equation} A(t) = e^{-\frac{k^{2}\pi^{2}}{l^{2}} t} \end{equation}
and
\begin{equation} B(x) = \sin \frac{k\pi x}{l} \end{equation}
sin Recall that \(U = AB\), this means, with all generality:
\begin{equation} u_{k} = e^{-\frac{k^{2}\pi^{2}}{l^{2}} t}\sin \frac{k\pi x}{l} \end{equation}
Initial Conditions
Suppose we have initial condition:
\begin{equation} f_{0}(x) = \sum a_{n} \sin \qty( \frac{k\pi x}{l}) \end{equation}
because the PDE is linear, we obtain:
\begin{equation} u_{k}(t,x) = \sum a_{k} e^{-\frac{k^{2}\pi^{2}}{l^{2}}t} \sin \qty( \frac{k \pi x}{l}) \end{equation}
again quantized over \(k\).
This is because each individual terms corresponds to a solution \(a_{n} \sin \qty(\frac{k\pi x}{l})\), and at boundary condition \(f_{0}(x)\), the left term of the general solution drops out, to obtain:
\begin{equation} a_{n}\frac{k \pi x}{l} = f_{0}(x) = u(0, x) = e^{0} \sin \qty(\frac{k \pi x}{l}) = a_{k} \sin \qty(\frac{k \pi x}{l}) \end{equation}
so we can just match terms.
The good news is that, because exists, any initial condition that&rsquo;s a well-formed function can be written a sum of sines. This also converges really quickly (because \(e^{-k^{2}}\)). Further, given some \(f_{0}(x)\), we obtain a specific \(k\) and will obtain a specific solution.
Solving using Neumann Conditions Go through the derivation, this gives:
\begin{equation} u_{k}(t,x) = \sum b_{k} e^{ - \frac{k^{2} \pi^{2}}{l^{2}} t } \cos \qty( \frac{k \pi x}{l}) \end{equation}
