# example of solving the heat equation

Let a .  Determine the temperature function  $(x,\,y)\mapsto u(x,\,y)$  on the plate, when the faces of the plate are .

The equation of the heat flow (http://planetmath.org/HeatEquation) in this case is

 $\displaystyle\nabla^{2}u\;\equiv\;u^{\prime\prime}_{xx}+u^{\prime\prime}_{yy}% \;=\;0$ (1)

under the boundary conditions

 $u(0,\,y)=0,\qquad u(\pi,\,y)=0,\qquad u(x,\,\pi)=C,\qquad u^{\prime}_{y}(x,\,0% )=0.$

We first try to separate the variables, i.e. seek the solution of (1) of the form

 $u(x,\,y)\;:=\;X(x)\,Y(y).$

Then we get

 $u^{\prime}_{x}=X^{\prime}Y,\qquad u^{\prime\prime}_{xx}=X^{\prime\prime}Y,% \qquad u^{\prime}_{y}=XY^{\prime},\qquad u^{\prime\prime}_{yy}=XY^{\prime% \prime},$

and thus (1) gets the form

 $\displaystyle X^{\prime\prime}Y+XY^{\prime\prime}\;=\;0$ (2)

and the boundary conditions

 $X(0)\;=\;X(\pi)\;=\;0,\quad X(x)\;=\;\frac{C}{Y(\pi)},\quad Y^{\prime}(0)\;=\;0.$

We separate the variables in (2):

 $\frac{X^{\prime\prime}}{X}\;=\;-\frac{Y^{\prime\prime}}{Y}$

This equation is not possible unless both sides are equal to a same negative $-k^{2}$, which implies for  $X^{\prime\prime}=-k^{2}X$  the solution

 $X\;:=\;C_{1}\cos{kx}+C_{2}\sin{kx}$

and for  $Y^{\prime\prime}\;=\;k^{2}Y$  the solution

 $Y\;:=\;D_{1}\cosh{ky}+D_{2}\sinh{ky}.$

The two first boundary conditions give  $0=X(0)=C_{1}$,  $0=X(\pi)=0+C_{2}\sin{k\pi}$,  and since  $C_{2}\neq 0$,  we must have  $\sin{k\pi}=0$,  i.e.

 $0\;<\;k\;:=\;n\;=\;1,\,2,\,3,\,\ldots$

Therefore

 $X(x)\;:=\;C_{2}\sin{nx},\quad Y^{\prime}(y)\;\equiv\;nD_{1}\sinh{ny}+nD_{2}% \cosh{ny}.$

The fourth boundary condition now yields that  $0=Y^{\prime}(0)=nD_{2}$;  thus  $D_{2}=0$  and  $Y(y):=D_{1}\cosh{ny}.$  So (1) has infinitely many solutions

 $\displaystyle u_{n}\;:=\;C_{2}D_{1}\sin{nx}\cosh{ny}\;=\;A_{n}\sin{nx}\cosh{ny}$ (3)

with  $n\in\mathbb{Z}_{+}$  and they all satisfy the boundary conditions except the third.  Because of the linearity of (1), also the sum

 $u\;:=\;\sum_{n=1}^{\infty}A_{n}\sin{nx}\cosh{ny}$

of the functions (3) satisfy (1) and those boundary conditions, provided that this series converges.  The third boundary condition requires that

 $C\;=\;u(x,\,\pi)\;=\;\sum_{n=1}^{\infty}A_{n}\sin{nx}\cosh{n\pi}\;=\;\sum_{n=1% }^{\infty}(A_{n}\cosh{n\pi})\sinh{nx}$

on the interval$0\leqq x\leqq\pi$.  But this is the Fourier sine series of the constant function  $x\mapsto C$  on the half-interval  $[0,\,\pi]$,  whence

 $A_{n}\cosh{n\pi}\;=\;\frac{2}{\pi}\int_{0}^{\pi}C\sin{nx}\,dx\;=\;\frac{2C}{n% \pi}(1\!-\!(-1)^{n})\quad\forall n\in\mathbb{Z}_{+}.$

The even (http://planetmath.org/EvenNumber) $n$’s here give 0 and the odd (http://planetmath.org/EvenNumber) give

 $A_{2m+1}\;:=\;\frac{4C}{(2m\!+\!1)\pi\cosh(2m\!+\!1)\pi}\quad(m=0,\,1,\,2,\,\ldots)$

Thus we obtain the solution

 $u(x,\,y)\;:=\;\frac{4C}{\pi}\sum_{m=0}^{\infty}\frac{\sin(2m\!+\!1)x\cosh(2m\!% +\!1)y}{(2m\!+\!1)\cosh(2m\!+\!1)\pi}.$

It can be shown that this series converges in the whole of the plate.

## Visualization of the solution

Remark.  The function $u$ has been approximated in the plot by computing a partial sum of the true infinite-series solution.  However, there is substantial numerical error in the approximate solution near  $y=\pi$,  evident in the small oscillations observed in the surface plot, that should not be there in .  This phenomenon is actually inevitable given that the boundary conditions are actually discontinuous at the corners  $(0,\,\pi)$  and  $(\pi,\,\pi)$.

More precisely, observe that when  $y=\pi$,  the for  $u(x,\,y)$  reduces to the Fourier series

 $\frac{4C}{\pi}\left(\sin{x}+\frac{\sin{3x}}{3}+\frac{\sin{5x}}{5}+\cdots\right)$

for the discontinuous function on  $[-\pi,\,\pi]$:

 $x\mapsto\begin{cases}C\,,&0

That means the Fourier will necessarily be subject to the Gibbs phenomenon.  Of course, the series also cannot converge absolutely; in other of the series decay too slowly in magnitude, adversely affecting the numerical solution.

• http://gold-saucer.afraid.org/math/planetmath/ExampleOfSolvingTheHeatEquation/heat.pyPython program to compute  $u(x,\,y)$  and produce the two figures

 Title example of solving the heat equation Canonical name ExampleOfSolvingTheHeatEquation Date of creation 2014-09-28 17:02:21 Last modified on 2014-09-28 17:02:21 Owner pahio (2872) Last modified by pahio (2872) Numerical id 25 Author pahio (2872) Entry type Example Classification msc 35Q99 Synonym stationary example of heat equation Related topic LaplacesEquation Related topic BlackScholesPDE Related topic AnalyticSolutionOfBlackScholesPDE Related topic SolvingTheWaveEquationByDBernoulli Related topic TimeDependentExampleOfHeatEquation Related topic ExampleOfSummationByParts