CUST 2023-2024
Maths for Physics 2
Session 10
Separation of variables
Summary
In this session we discuss a particular method that proves to be very useful to solve
partial differential equations (PDEs): the method of separation of variables. For
clarity and concreteness, we discuss this method on a particular example, namely
the diffusion equation at 1D. We first give the general idea that underlies the method,
and show how the problem of solving a PDE can be transformed into a problem of
solving ordinary differential equations (ODEs). We then solve these ODEs, and use
these solutions to construct the solution of the PDE.
NOTATIONS: PDEs = Partial Differential Equations
ODEs = Ordinary Differential Equations
i
Contents
1 General idea of the method of separation of variables 1
1.1 Separable solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Transforming the PDE into ODEs . . . . . . . . . . . . . . . . . . . . 3
2 Solutions of the differential equations 6
2.1 Finding X and λ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.2 Finding T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Constructing the general solution from the separable solutions . . . . 9
ii
Chapter 1
General idea of the method of
separation of variables
In order to illustrate the general idea that underlies the method of separation of
variables, here we consider a particular example of a linear second-order PDE: the
diffusion equation at 1D.
Therefore, let’s consider a function u(x, t) of the two variables x (position) and
t (time). We assume that this function obeys the 1D diffusion equation
∂u ∂ 2u
− D 2 = 0, (1.1)
∂t ∂x
where D is a constant. For instance, physically speaking, the function u can rep-
resent the concentration of some chemical substance (in which case D could be
called the diffusion constant) or the temperature (in which case the equation (1.1)
would then be referred to as the heat equation, and the constant D as the thermal
diffusivity).
Now, let’s also assume that the variables x and t are restricted to take values
such that
x ∈ [0, L] and t ⩾ 0, (1.2)
where L > 0 is some positive constant (this models for instance a 1D rod of length
L). Furthermore, we complement the PDE (1.1) with boundary conditions and
an initial condition: namely, we require that the solution u of the PDE (1.1) also
satisfies the boundary conditions1
u(0, t) = u(L, t) = 0 , ∀t , (1.3)
1
We have two boundary conditions because the PDE (1.1) has a second derivative with respect
to position x.
1
CHAPTER 1. GENERAL IDEA OF THE METHOD. . . 2
which, because the imposed value of u is zero, are thus homogeneous boundary
conditions, as well as the initial condition2
u(x, 0) = p(x) , ∀x , (1.4)
where p(x) is some prescribed function of x.
Therefore, combining the PDE (1.1) with the boundary conditions (1.3) and the
initial condition (1.4) defines the following problem, which we want to solve:
2
∂u
∂t
− D ∂∂xu2 = 0 , x ∈ [0, L] , t ⩾ 0
u(0, t) = u(L, t) = 0 , ∀t . (1.5)
u(x, 0) = p(x) , ∀x
Our approach to solve this problem is to use the method of separation of variables,
as we now discuss.
1.1 Separable solutions
The method of separation of variables aims at searching solutions of the PDE (1.1)
that are of the form
u(x, t) = X(x)T (t) , (1.6)
where X is some function of the single variable x, while T is some function of the
single variable t. The very structure of the solutions (1.6) hence gives its name to
the method. Indeed, we look for those solutions of the PDE (1.1) for which the
two independent variables x and t are separated into two different single-variable
functions: one function X for the variable x, and one function T for the variable
t. For this reason, we call a solution of the form (1.6) a separable solution of the
PDE (1.1).
Remark: let’s emphasize straight away that a solution of the form (1.6) (assuming
that it actually exists of course) can a priori only give us a particular solution of the
PDE (1.1): indeed, not only should such a function be solution of the PDE (1.1),
but it must also satisfy the additional constraint that it must be of the separa-
ble form (1.6). This additional constraint of separability is quite strong, and the
general solution of the PDE (1.1) can by no means be required to satisfy such a
strong additional constraint. But: this doesn’t mean that the particular separable
solutions (1.6) are not interesting in view of obtaining the general solution of the
2
We have one initial condition because the PDE (1.1) has a first derivative with respect to time
t.
CHAPTER 1. GENERAL IDEA OF THE METHOD. . . 3
PDE (1.1). As a matter of fact, it’s actually quite the contrary! Indeed, we’ll exploit
the superposition principle that applies to a homogeneous equation of the form (1.1):
any linear combination of solutions of (1.1) is itself a solution. Therefore, we’ll ac-
tually be able to construct a general solution of (1.1) merely by superposing (i.e.
adding) the different separable solutions of the form (1.6).
1.2 Transforming the PDE into ODEs
A great advantage of looking for separable solutions of the form (1.6) is that it allows
to turn the PDE (1.1) into ODEs, which are much easier to solve!
To see how this works, let’s substitute our separable solutions (1.6) into the
PDE (1.1), we have
∂ ∂2
[X(x)T (t)] − D 2 [X(x)T (t)] = 0 . (1.7)
∂t ∂x
Now we exploit the structure of the separable solutions (1.6): by construction, the
function X(x) is independent of t, while the function T (t) is independent of x.
Therefore, the PDE (1.7) yields
dT d2 X
X(x) − DT (t) 2 = 0 , (1.8)
dt dx
where indeed we no longer need to have partial derivatives. We then get from (1.8)
dT d2 X
X(x) = DT (t) 2 ,
dt dx
and thus we get, upon dividing both sides by DX(x)T (t),
1 1 dT 1 d2 X
= . (1.9)
D T (t) dt X(x) dx2
Now, let’s have a look at what this equation (1.9) tells us: it tells us that the
left-hand side, which is a function of t only (i.e. independent of x), must be equal
to the right-hand side, which is a function of x only (i.e. independent of t). This is
only possible if the left-hand side and the right-hand side are actually both constant,
i.e. independent of both x and t! Indeed, let’s imagine e.g. that the left-hand side
in (1.9) is not constant: since this is a function of t, this would mean that by
changing the value of t, we also mandatorily change the value of this function. But
now, since the right-hand side in (1.9) is independent of t, its value will thus not
change as we change the value of t! This means that it could then no longer be equal
to the left-hand side for these different values of t. Therefore, we must conclude that
the left-hand side is actually a constant, independent of t. The same argument can
CHAPTER 1. GENERAL IDEA OF THE METHOD. . . 4
then be repeated for the right-hand side, which must thus be independent of x.
Therefore, let’s call −λ this constant3 : we can thus write (1.9) as
1 1 dT 1 d2 X
= −λ = . (1.10)
D T (t) dt X(x) dx2
Because this constant −λ arises from separating the variables x and t, it is commonly
referred to as the separation constant.
We can now readily see that the first equation in (1.10) gives us the equation
dT
+ λDT (t) = 0 , (1.11)
dt
which is a homogeneous first-order ODE: we actually know how to solve this! Fur-
thermore, let’s now see what we get from the second equation in (1.10): we have
d2 X
+ λX(x) = 0 , (1.12)
dx2
which is a homogeneous second-order ODE with constant coefficients: we also know
how to solve this actually!
This is precisely the main power of the method of separation of variables: to turn
a PDE, which is possibly rather complicated to solve (even numerically), into a set
of ODEs, which are typically simpler to solve (and which, even from the numerical
point of view, are easier to deal with, for a simple reason: numerically, it’s less
expensive to deal with functions of single variables as compared to functions of
many variables).
Conclusion: starting from the PDE
∂u ∂ 2u
− D 2 = 0, (1.13)
∂t ∂x
and looking for a particular set of solutions of the form
u(x, t) = X(x)T (t) , (1.14)
known as separable solutions because the variables x and t have been separated, we
obtain the two ODEs
(
dT
dt
+ λDT (t) = 0
d2 X
, (1.15)
dx2
+ λX(x) = 0
in terms of a constant λ known as the separation constant.
3
The minus sign in −λ is introduced just to make the ODE obtained in the sequel look nicer.
CHAPTER 1. GENERAL IDEA OF THE METHOD. . . 5
Before we proceed to solve the ODEs (1.15), let’s give two remarks here:
1) At this point, the separation constant λ is unknown and can a priori take any
value. In order to determine the possible values of λ, the differential equation itself
is not enough: we need some additional constraints. This is precisely where the
boundary conditions (1.3) imposed on the solution u at x = 0 and x = L will come
into play: by imposing these boundary conditions on the function X(x), this will
allow us to determine what are the values of λ that are allowed by these boundary
conditions. But, since our aim is still to find the general4 solution u of the PDE (1.1),
we’ll not impose the initial condition (1.4) on the function T (t): rather, we’ll wait
until we construct the general solution of (1.1) as a linear combination of separable
solutions (as a consequcne of the superposition principle). It is this superposition
of separable solutions that will be required to satisfy the initial condition.
2) Let’s conclude here with a remark on terminology. Note that the two ODEs
in (1.15) can both be written in the form
Lf = λf , (1.16)
with L a differential operator and f a function5 , while λ is some constant. In other
words, we want to answer the question: what are the functions f and constants λ
for which the action of the differential operator L on f returns simply the function
itself multiplied by the constant λ? This should remind us the following question:
what vector v, when acted upon by a matrix M , returns the vector itself multiplied
by a constant λ? That is,
M v = λv . (1.17)
Because of this similar mathematical structure in both (1.16) and (1.17), we call the
equation (1.16) an eigenvalue equation. In this case, we hence call λ the eigenvalue,
while the function f is called the eigenfunction associated with the eigenvalue λ.
4
By general here we mean the solution u that does not have to satisfy the extra condition (1.6)
of separability.
5
For instance, if L = −D−1 d/dt and f = T (t), we get the first equation in (1.15).
Chapter 2
Solutions of the differential equations
Let’s first recall that we want to solve the following problem:
2
∂u
∂t
− D ∂∂xu2 = 0 , x ∈ [0, L] , t ⩾ 0
u(0, t) = u(L, t) = 0 , ∀t , (2.1)
u(x, 0) = p(x) , ∀x
where D is a constant while p(x) is a prescribed function of x. To this end, the
method of separation of variables aims at first determining the separable solutions
u(x, t) = X(x)T (t) . (2.2)
This yields the two following ODEs, which are commonly called eigenvalue equations,
dT
+ λDT (t) = 0 (2.3)
dt
and
d2 X
+ λX(x) = 0 , (2.4)
dx2
in terms of an arbitrary constant (or eigenvalue) λ.
Here we want to determine the functions T and X, as well as the values of λ
that are allowed by the boundary conditions. We’ll then construct the solution u of
the problem (2.1) as a linear combination of the allowed separable solutions (2.2)
for all allowed values of λ. Finally, we’ll impose the remaining initial condition on
the latter superposition to get the solution u to the problem (2.1).
6
CHAPTER 2. SOLUTIONS OF THE DIFFERENTIAL. . . 7
2.1 Finding X and λ
Let’s first impose the boundary conditions [i.e. the second equation in (2.1)] on the
separable solutions (2.2), we get first at x = 0
u(0, t) = X(0)T (t) = 0 , ∀t ,
which is only possible if T (t) = 0, ∀t (which would thus yield the trivial solution,
which we don’t care about), or if
X(0) = 0 , (2.5)
and then at x = L
u(L, t) = X(L)T (t) = 0 , ∀t ,
so that we readily see that we must have
X(L) = 0 . (2.6)
Therefore, let’s combine the ODE (2.4) with the two boundary conditions (2.5)
and (2.6): this gives us the following problem
(
d2 X
dx2
+ λX(x) = 0 , x ∈ [0, L]
. (2.7)
X(0) = X(L) = 0
Solving this problem will give us the valid solutions X(x) and the allowed values of
the eigenvalue λ: for this reason, we can call the problem (2.7) an eigenproblem.
Now, let’s first write down the form of the solution X(x) to the ODE in the
problem (2.7). Since this ODE is a linear second-order homogeneous ODE with
constant coefficients, we know how to solve it, and we can readily say that the
solution X(x) is of the form
√ √
X(x) = A cos λx + B sin λx , (2.8)
as can be explicitly checked.
Let’s now impose the boundary conditions (2.5) and (2.6) on the solution (2.8).
First, at x = 0 we get
X(0) = A cos(0) + B sin(0) = A = 0 , (2.9)
CHAPTER 2. SOLUTIONS OF THE DIFFERENTIAL. . . 8
so that we can rewrite (2.8) as
√
X(x) = B sin λx . (2.10)
Then, at x = L we must have
√
X(L) = B sin λL = 0 ,
which is only possible if either B = 0 (which would then yield the trivial solution,
which we don’t care about) or if
√
sin λL = 0 , (2.11)
which is then the condition that must be satisfied. This is precisely the condition
that constrains the possible values of the eigenvalue λ: indeed, (2.11) requires that1
√
λL = nπ , n = 1, 2, . . . , (2.12)
that is we must have
λL2 = n2 π 2 ,
and thus
n2 π 2
λ= , n = 1, 2, . . .
L2
Therefore, let’s call λn these allowed values of the eigenvalue λ, we have
n2 π 2
λn = , n = 1, 2, . . . (2.13)
L2
These allowed values of λ hence also yield the possible eigenfunctions X: let’s call Xn
the eigenfunction associated with the eigenvalue λn , we have from (2.10) and (2.13)
p nπ
Xn (x) = Bn sin λn x = Bn sin x , n = 1, 2, . . . , (2.14)
L
where Bn is some arbitrary constant (to be fixed later on).
Now that we found the allowed λ and X, let’s determine the other function T (t).
1
restrict to positive integers n, since we already implicitly considered λ to be positive
In (2.12) we√
when we wrote λ [actually, we can show that if λ is negative, there is no solution other than the
trivial solution X = 0 that satisfies both the ODE (2.4) and the√two boundary conditions (2.5)
and (2.6)]. Furthermore, we don’t consider n = 0, since otherwise λx = 0, ∀x, which would again
yield the trivial solution.
CHAPTER 2. SOLUTIONS OF THE DIFFERENTIAL. . . 9
2.2 Finding T
Since the ODE (2.3) satisfied by T (t) is a linear first-order homogeneous ODE, its
solution is easily computed (e.g. using an integrating factor). Since we saw above
that λ only takes the values λn , let’s denote by Tn (t) the eigenfunction associated
with λn , i.e. the solution of the ODE
dTn
+ λn DTn (t) = 0 . (2.15)
dt
We easily solve this and find the following family of allowed functions Tn (t):
n2 π 2
Tn (t) = βn e−λn Dt = βn e− L2
Dt
, n = 1, 2, . . . , (2.16)
where βn is some arbitrary constant (to be fixed later on).
Therefore, combining the expression (2.14) of Xn (x) and (2.16) of Tn (t) yields
the following set of separable solutions of the form (2.2), which we denote by un (x, t)
and which are given by
un (x, t) = Xn (x)Tn (t) , n = 1, 2, . . . , (2.17)
that is
nπ n2 π2
un (x, t) = αn sin x e− L2 Dt , n = 1, 2, . . . , (2.18)
L
where αn is some arbitrary constant (to be fixed later on).
2.3 Constructing the general solution from the sep-
arable solutions
Now that we constructed the set (2.18) of separable solutions un (x, t) that are al-
lowed by the boundary conditions, we can use the superposition principle: any
linear combination of solutions of the PDE in (2.1) is itself a solution of this PDE.
Therefore, the function
∞
X
u(x, t) = γn un (x, t) , (2.19)
n=1
that is in view of the expression (2.18) of un
∞
X nπ n2 π2
u(x, t) = cn sin x e− L2 Dt , (2.20)
n=1
L
CHAPTER 2. SOLUTIONS OF THE DIFFERENTIAL. . . 10
where cn are arbitrary coefficients, is by construction a solution of the PDE in (2.1).
It is now to this solution (2.20) that we impose our remaining additional condition,
namely the initial condition [i.e. the third equation in (2.1)].
Imposing this initial condition to (2.20) hence yields
∞
X nπ
u(x, 0) = p(x) = cn sin x , (2.21)
n=1
L
which hence fixes the form of the coefficients cn : indeed, since the function p(x) is a
fixed, prescribed function in our problem, the equation (2.21) can only be satisfied
if the coefficients cn take on specific values. Actually, the expression in the right-
hand side of (2.21) is nothing but the Fourier series expression of the function p(x)
on the interval x ∈ [0, L]: the coefficients cn in the present case are hence Fourier
coefficients, that can be determined from the function p(x) using the usual method
from Fourier series. Note that, since by construction un (0, t) = un (L, t) = 0, we
readily see from (2.19) that we also have u(0, t) = u(L, t) = 0, i.e. the solution (2.21)
satisfies, by construction, the boundary conditions.
Conclusion: the method of separation of variables allowed us to show that the
solution u(x, t) of the problem
2
∂u
∂t
− D ∂∂xu2 = 0 , x ∈ [0, L] , t ⩾ 0
u(0, t) = u(L, t) = 0 , ∀t (2.22)
u(x, 0) = p(x) , ∀x
can be written as the series
∞
X nπ n2 π2
u(x, t) = cn sin x e− L2 Dt , (2.23)
n=1
L
where the coefficients cn are the Fourier coefficients of the function p(x). The
sum (2.23) is commonly referred to as an eigenfunction expansion.