You are on page 1of 10

Industrial Mathematics

Worksheet 1.1 – Analytical Solutions of Diffusion


Equations
Dr Ben Goddard
b.goddard@ed.ac.uk
20th September 2021

This worksheet is designed to introduce you to analytical solutions of the diffusion (or
heat) equation in 1D, on a finite domain. You should feel free to attempt the questions in
any order, although one approach to Questions 4–6 is to reuse results from Questions 1–3,
so you may want to attempt those first.

You will note that all of the questions are posed on the interval [0, 1], with diffusion
coefficient 1, and with simple boundary and initial conditions. Note that this is not what
you should expect from an industrial problem. Such problems will generally be posed on
physically-relevant intervals, with essentially arbitrary parameters, and possibly more com-
plicated boundary and initial conditions. You will see some of these problems in the first
Project. Later in the course we will also discuss non-dimensionalisation.

This will result in you having mastered (at least) two different approaches to solving these
real-world problems:
i) Repeat the sort of analysis used in the problems here, but in the more general case in-
cluding an arbitrary interval [a, b], diffusion coefficient D0 and boundary conditions. You can
then insert the relevant values from the industrially-motivated problem;
ii) Non-dimensionalise the industrially-motivated problem so that it lies on [0, 1], with diffu-
sion coefficient 1, and ‘simple’ boundary conditions. Use the solutions from this worksheet
to solve the problem, and then convert back to the physical dimensions.

Hopefully it’s obvious that the two approaches should give the same results. As such, you
should consider the problems here as model ones, which will allow you to appreciate the gen-
eral techniques necessary to find analytical solutions to (simplified versions of) the problems
in the Project. This is to mimic the idea that at University you are taught ‘sanitised’ version
of problems, generally with nice solutions that are tractable in a reasonable amount of time
(e.g., during an exam). Real-world problems tend to be (far) more complex, but often the
techniques you have learnt in your courses can be used to make a good attempt at a slightly
simplified version.

1
We will cover some examples of advection-diffusion equations later in the course. This
worksheet focusses on the separation of variables approach. There are many other ways to
solve these diffusion equations, for example through Fourier transform methods, although the
method presented here is probably the simplest. As well as solutions of ‘standard’ ODEs, you
will need to know the basics of Fourier series (here presented in sine and cosine expansions),
although really everything you need for this was covered in Video 1.6.
The problems focus on the following boundary conditions:
1. Zero Dirichlet;

2. Zero Neumann;

3. Zero mixed (one Dirichlet, one Neumann);

4. Inhomogeneous (non-zero) Dirichlet;

5. Inhomogeneous Dirichlet with a specific initial condition;

6. Zero Neumann with a specific initial condition;

7. Whatever you like!


Note: In the cases where we give an arbitrary f as an initial condition you may assume
that f is as ‘nice’ as you like in terms of differentiability, integrability, etc. You may also
assume that the solution is non-zero on (0, 1) (in fact, it is possible to show this rigorously
for any initial condition which is non-zero on a set of positive measure).
1: Zero Dirichlet
[Note that this question is identical to the one solved in Video 1.6]
Find an analytical solution for the equation

∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)


u(0, t) = 0;
u(1, t) = 0;
u(x, 0) = f (x).

Solution:
We proceed by the method of separation of variables and write u(x, t) = X(t)T (t). This
results in ∂t u(x, t) = X(x)T 0 (t) and ∂xx u(x, t) = X 00 (x)T (t). Note that here, and throughout,
a prime (0 ) on a function of only one variable denotes differentiation with respect to that
variable.
Hence we have, from the PDE,

X(x)T 0 (t) = X 00 (x)T (t), x ∈ (0, 1)

and, since we are assuming that the solution is non-zero gives


X 00 (x) T 0 (t)
= .
X(x) T (t)

2
Now note that the function on the left depends only on x whereas the one on the right
depends only on t. Hence both functions must be independent of both x and t (otherwise
changing one of the variables changes only one side of the equality). We therefore have, for
some constant −λ,
X 00 (x) T 0 (t)
= = −λ.
X(x) T (t)
The reason for the choice to include a minus sign will become clear later.
We now have two ODEs to solve, one in x and one in t. Let’s start with the t equation:

T 0 (t) = −λT (t),

which has solution


T (t) = C exp(−λt).
We will return to this once we’ve identified the possible choices of λ. these turn out to depend
on the boundary conditions for the spatial equation.
We consider three cases for λ, namely λ < 0, λ = 0, and λ > 0. First, however, we recall
that T (t) 6= 0 and so the boundary conditions become

X(0) = X(1) = 0.

i) For λ < 0 we set λ = −k 2 and wish to solve

X 00 (x) = k 2 X(x).

It is easy to check that the general solution to this equation is

X(x) = a exp(kx) + b exp(−kx).

where the constants a and b are determined by the initial and boundary conditions.
Applying the boundary conditions gives

X(0) = 0 = a + b
X(1) = 0 = aek + be−k .

From the first equation we have b = −a and hence the second equation becomes a(ek −e−k ) =
0. Hence we have a = 0 or ek − e−k = 0. The case a = 0 gives only the trivial (constantly
zero) solution, which is unlikely to match any given initial condition (and we’ve assumed the
solution is non-zero). Hence we must have ek − e−k = 0, but this only holds when k = 0,
which contradicts the assumption λ < 0. Hence the only solution with λ < 0 is the trivial
solution.
ii) For λ = 0 we have
X 00 (x) = 0 ⇒ X(x) = ax + b.
Applying the boundary conditions gives

X(0) = 0 = b ⇒ b = 0
X(1) = 0 = a + b ⇒ a = 0.

3
Hence we once again only have the trivial solution.
iii) For λ > 0 we set λ = k 2 and wish to solve

X 00 (x) = −k 2 X(x).

It is easy to check that the general solution to this equation is

X(x) = a cos(kx) + b sin(kx).

where, once again, the constants a and b are determined by the initial and boundary condi-
tions.
Applying the boundary conditions gives

X(0) = a = 0

and hence also


X(1) = b sin k = 0.
Hence we have either b = 0 or k = 0. If b = 0 this means that u(x, t) ≡ 0, which is both
a boring solution and unlikely to agree with any given initial condition. We must therefore
have
sin k = 0 ⇒ k = nπ, n ∈ N.
Note that we have excluded negative values of n as sin(nπx) = − sin(−nπx). Hence we have
an infinite number of allowable values of λ, which we denote

λn = (nπ)2 .

These correspond so solutions of the PDE with the form

un (x, t) = Xn (x)Tn (t) = cn sin(nπx) exp(−n2 π 2 t).

The challenge now is to find a solution u which satisfies the initial condition u(x, 0) = f (x).
Here we use the linearity of the problem. In particular, if u and v are both solutions to the
PDE (including the boundary conditions and a given initial condition), then u + v is also a
solution, but with a different initial condition. We may therefore write a general solution as

X
u(x, t) = cn sin(nπx) exp(−n2 π 2 t).
n=1

The question remaining is how to find the cn to satisfy the initial condition.
To start with we have ∞
X
u(x, 0) = cn sin(nπx).
n=1

We will now use some properties of the functions sin(nπx), which are easily checked. In
particular we find that they are orthogonal on [0, 1]:
Z 1 (
0 n 6= m
sin(nπx) sin(mπx)dx =
0 1/2 n = m.

4
Taking our expansion of the initial condition, multiplying by sin(mπx) and integrating
over [0, 1] therefore gives

X
u(x, 0) = f (x) = cn sin(nπx)
n=1
∞ Z
X 1 Z 1
⇒ cn sin(nπx) sin(mπx)dx = f (x) sin(mπx)dx
n=1 0 0
Z 1
⇒ cm /2 = f (x) sin(mπx)dx.
0

So we finally have an analytic solution



X
u(x, t) = cn sin(nπx) exp(−n2 π 2 t)
n=1
Z 1
cn = 2 f (x) sin(nπx)dx.
0

We will see how to calculate cn explicitly for a given f in Question 5.


2: Zero Neumann
Find an analytical solution for the equation

∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)


∂x u(0, t) = 0;
∂x u(1, t) = 0;
u(x, 0) = f (x).

Solution:
We proceed through separation of variables as in Question 1 and find, once again, for some
constant −λ,
X 00 (x) T 0 (t)
= = −λ.
X(x) T (t)
The t equation again has solution

T (t) = C exp(−λt).

The key difference here lies in the boundary conditions. Once again, consider the three
cases λ > 0, λ = 0, and λ > 0. The x equation is given by

X 00 (x) = −λX(x).

i) λ < 0. Once again this results in only the trivial solution (check this yourself!).
ii) λ = 0. Here we find something other than the trivial solution. We have, as before,
X(x) = ax + b, with X 0 (x) = a. The boundary conditions give

X 0 (0) = X 0 (1) = a = 0

5
and hence there is a solution X(x) = b = c0 , for some constant to be determined.
iii) λ > 0. As before, we set λ = k 2 and wish to solve

X 00 (x) = −k 2 X(x).

which (still) has general solution

X(x) = a cos(kx) + b sin(kx).

Differentiating X (in order to be able to apply the boundary conditions) gives

X 0 (x) = −ak sin(kx) + bk cos(kx).

Hence the solution must satisfy

X 0 (0) = bk = 0 ⇒ b = 0
X 0 (1) = −ak sin(k) = 0 ⇒ k = nπ,

where once again we have excluded the trivial solution with a = 0.


As before we find an infinite set of solutions

Xn (x) = an cos(nπx), n ∈ N.

A similar argument as before (in terms of the othogonality of cos(nπx) gives


Z 1 (
0 n= 6 m
cos(nπx) cos(mπx)dx =
0 1/2 n = m.

and so

X
u(x, t) = c0 + cn cos(nπx) exp(−n2 π 2 t)
n=1
Z 1
c0 = f (x)dx
0
Z 1
cn = 2 f (x) cos(nπx)dx, n > 0.
0

3: Zero Mixed
Find an analytical solution for the equation

∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)


u(0, t) = 0;
∂x u(1, t) = 0;
u(x, 0) = f (x).

6
Solution:
We focus only on the x equation with λ > 0; the t equation is the same as before and the
other cases for λ give the trivial solution.
As before, we have
X(x) = a cos(kx) + b sin(kx)
X 0 (x) = −ak sin(kx) + bk cos(kx).
The boundary conditions require

X(0) = 0 = a
X 0 (1) = 0 = bk cos(kx) ⇒ cos(kx) = 0.
Where, as always, we exclude the trivial solution. This corresponds to
k = (n + 1/2)π, n = 0, 1, 2, . . . .
Using that (
1
n 6= m
Z
0
sin((n + 1/2)πx) sin((m + 1/2)πx)dx =
0 1/2 n = m.
gives

X
u(x, t) = cn sin((n + 1/2)πx) exp(−(n + 1/2)2 π 2 t)
n=0
Z 1
cn = 2 f (x) sin((n + 1/2)πx)dx.
0

4: Inhomogeneous Dirichlet
Find an analytical solution for the equation
∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)
u(0, t) = 0;
u(1, t) = 1;
u(x, 0) = f (x).
Hint: use linearity of the solution.
Solution:
To tackle this problem, we are going to use a very general approach, hinted at in the solution
to Question 1. Namely, if u and v are two solutions to the PDE with
∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)
u(0, t) = u0 ;
u(1, t) = u1 ;
u(x, 0) = fu (x).

7
and

∂t v(x, t) = ∂xx v(x, t), x ∈ (0, 1)


v(0, t) = v0 ;
v(1, t) = v1 ;
v(x, 0) = fv (x),

then w = u + v is a solution with

∂t w(x, t) = ∂xx w(x, t), x ∈ (0, 1)


w(0, t) = u0 + v0 ;
w(1, t) = u1 + v1 ;
w(x, 0) = fu (x) + fv (x).

The idea is therefore to find any function v that satisfies the PDE and boundary conditions
v(0, t) = 0, v(1, t) = 1, with initial condition fv (x). We look at a function w = u − v which
must satisfy

∂t w(x, t) = ∂xx w(x, t), x ∈ (0, 1)


w(0, t) = 0;
w(1, t) = 0;
w(x, 0) = f (x) − fv (x).

So how do we find such a solution? Well, we’ve essentially already seen how to obtain it
when we looked at the case λ = 0, which corresponded to a solution X(x) = ax+b. Choosing
a = 1 and b = 0 gives the solution

v(x, t) = x, v(0, t) = x.

We must therefore solve the equation

∂t w(x, t) = ∂xx w(x, t), x ∈ (0, 1)


w(0, t) = 0;
w(1, t) = 0;
w(x, 0) = f (x) − x.

This corresponds to (see Question 1)



X
w(x, t) = cn sin(nπx) exp(−n2 π 2 t)
n=1
Z 1
cn = 2 [f (x) − x] sin(nπx)dx.
0
R1
Note that it is possible to compute 0
x sin(nπx)dx explicitly, but since f is arbitrary we
postpone this to a later question.

8
It remains to reconstruct u = w + v, and so

X
u(x, t) = cn sin(nπx) exp(−n2 π 2 t) + x
n=1
Z 1
cn = 2 [f (x) − x] sin(nπx)dx.
0

5: Inhomogeneous Dirichlet with Initial Condition


Find an analytical solution for the equation
∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)
u(0, t) = 0;
u(1, t) = 1;
u(x, 0) = 2.
In this case determine all coefficients explicitly.
Note that the initial condition is not compatible with the boundary conditions, but it
will turn out that this doesn’t matter (essentially because the solutions are different only on
a set of measure zero).
Solution:
This is a special case of Question 4 with f (x) = 2 and so the solution is
X∞
u(x, t) = cn sin(nπx) exp(−n2 π 2 t) + x
n=1
Z 1
cn = 2 [2 − x] sin(nπx)dx.
0
It remains to determine the cn explicitly, which is a case of evaluating some standard integrals.
In particular (
Z 1
0 n even
sin(nπx)dx = 2
0 nπ
n odd,
and
1
(−1)n+1
Z
x sin(nπx)dx =
0 nπ
and so (
2(−1)n

n even
cn = 2(−1)n 8

+ nπ
n odd,

6: Zero Neumann with Initial Condition


Find an analytical solution for the equation
∂t u(x, t) = ∂xx u(x, t), x ∈ (0, 1)
∂x u(0, t) = 0;
∂x u(1, t) = 0;
u(x, 0) = x.

9
In this case determine all coefficients explicitly.
Note that the initial condition is not compatible with the boundary conditions, but it
will turn out that this doesn’t matter (essentially because the solutions are different only on
a set of measure zero).
Solution:
This is the same as Question 2 with a specific choice of x. We therefore have a solution

X
u(x, t) = c0 + cn cos(nπx) exp(−n2 π 2 t)
n=1
Z 1
c0 = f (x)dx
0
Z 1
cn = 2 f (x) cos(nπx)dx, n > 0.
0

with f (x) = x and we must compute


Z 1
c0 = xdx = 1/2,
0

and, for n > 0, (


1
0 n even
Z
cn = 2 x cos(nπx)dx = 4
0 − (nπ)2 n odd,

7: Make Your Own Question


Choose a set of boundary conditions and an initial condition and see what happens! For
example, you may want to reverse the boundary conditions in Question 3 and choose a
specific initial condition.
After next week you should have the computational tools to check your solutions numer-
ically.
Solution:
N/A

10

You might also like