Chapter 5. Separation of Variables: 4.1 The Heat Equation
Chapter 5. Separation of Variables: 4.1 The Heat Equation
Chapter 5. Separation of Variables: 4.1 The Heat Equation
Separation of Variables
At this point we are ready to now resume our work on solving the three
main equations: the heat equation, Laplace’s equation and the wave equa-
tion using the method of separation of variables.
XT 0 = X 00 T,
T0 X 00
= , (4.4)
T X
implying that
T 0 = λT, X 00 = λX, (4.5)
where λ is a constant. From (4.2) and (4.3), the boundary conditions be-
comes
X(0) = X(1) = 0. (4.6)
2 Chapter 5. Separation of Variables
Integrating the X equation in (4.5) gives rise to three cases depending on
the sign of λ but as seen in the last chapter, only the case where λ = −k2
for some constant k is applicable which we have as the solution
which leads to
At this point, we recognize that we have a Fourier sine series and that the
coefficients bn are chosen such that
Z 1
bn = 2 (x − x2 ) sin nπx dx
0
· µ ¶ ¸¯1
1 − 2x x2 − x 2 ¯
= 2 cos nπx + − 3 3 cos nπx ¯¯
n2 π 2 nπ n π 0
4
= (1 − (−1)n ).
n π3
3
subject to
u(x, 0) = x − x2 , u x (0, t) = u x (1, t) = 0. (4.12)
Integrating the X equation in (4.14) gives rise to again three cases depend-
ing on the sign of λ but as seen earlier, only the case where λ = −k2 for
some constant k is relevant. Thus, we have
which leads to
2 π2 t
T(t) = c3 e−n ,
∞
2 2
u(x, t) = ∑ an e−n π t cos nπx,
n=0
∞
2
u(x, 0) = x − x = ∑ an cos nπx
n=0
∞
a0
= + ∑ an cos nπx.
2 n=1
We again recognize that we have a Fourier cosine series and that the coef-
ficients an are chosen such that
Z 1 ¸¯1
·
2 x2 x3 ¯¯ 1
a0 = 2 (x − x ) dx = 2 − ¯ = ,
0 2 3 0 3
Z 1
an = 2 (x − x2 ) cos nπx dx
0
· µ ¶ ¸¯1
1 − 2x x2 − x 2 ¯
= 2 sin nπx − − 3 3 sin nπx ¯¯
n2 π 2 nπ n π 0
2
= − 3 3 (1 + (−1)n ).
n π
∞
1 2 (−1)( n + 1) − 1 −n2 π2 t
u(x, t) = + 3
3 π ∑ n3
e cos nπx. (4.19)
n=1
0.3 y 0.3 y
t=0 t=0
0.2 0.2
t = .05
t = 0.1
0.1 0.1
t = .025
t = 0.2
0.0 0.0
0.0 0.5
x 1.0 0.0 0.5
x 1.0
Figure 1. The solution of the heat equation with the same initial condition with
fixed and no flux boundary conditions.
Example 2
Solve
ut = u xx , 0 < x < 2, t>0 (4.20)
subject to
(
x if 0 < x < 1,
u(x, 0) = u(0, t) = u x (2, t) = 0. (4.21)
2−x if 1 < x < 2,
gives rise to
T 0 = λT, X 00 = λX, (4.23)
Integrating the X equation in (4.23) with λ = −k2 for some constant k gives
which leads to
π 3π 5π (2n − 1)π
c2 = 0, cos 2k = 0 ⇒ k = , , ,..., ,
4 4 4 4
for integer n. From (4.23), we then deduce that
(2n−1)2 2
T(t) = c3 e− 16 π t
,
Figure 2 shows the solution both in short time t = 0, 0.1, 0.2 and long time
t = 10, 20, 30.
4.1. The heat equation 7
2 y 0.8 y
t=0 t = 10
t=2 t = 20
1 0.4
t = 30
t=1
x
0 0.0
x
0 1 2 0 1 2
Figure 2. Short time and long time behavior of the solution (4.26).
Example 3
Solve
ut = u xx , 0 < x < 2, t>0 (4.27)
subject to
In this problem, we have a fixed left endpoint and a radiating right end
point. Assuming separable solutions
gives rise to
T 0 = λT, X 00 = λX, (4.30)
Integrating the X equation in (4.30) with λ = −k2 for some constant k gives
c1 sin 0 + c2 cos 0 = 0, ⇒ c2 = 0
8 Chapter 5. Separation of Variables
It is very important that we recognize that the solutions of (4.33) are not
equally spaced as seen in earlier problems. In fact, there are an infinite
number of solutions of this equation. Figure 3 shows graphically the curves
y = −k and y = tan 2k. The first three intersection points are the first three
solutions of (4.33).
0 1 2 3 4
k
−2
k k3
1
−4
k 2
Therefore, we have
X(x) = c1 sin k n x. (4.34)
2
T(t) = c3 e−kn t (4.35)
4.1. The heat equation 9
y
1.0 t = 0
0.5
t = 1
t = 2
0.0
x
0 1 2
Example 4
Solve
ut = u xx , 0 < x < 3, t>0 (4.40)
subject to
u(x, 0) = 4x − x2 u(0, t) = 0, u(3, t) = 3. (4.41)
u = v + x. (4.44)
We notice that under the transformation (4.44), the original equation doesn’t
change form, i.e.
ut = u xx ⇒ vt = v xx
v(x, 0) = 3x − x2 .
subject to
v(x, 0) = 3x − x2 v(0, t) = 0, v(3, t) = 3. (4.46)
nπ
X(x) = c1 sin x, (4.48)
3
and
n2 π 2
T(t) = c3 e− 9 t
12 Chapter 5. Separation of Variables
Z
2 3 nπ
bn = (3x − x2 ) sin x dx
3 0 3
· ¸¯3
6(2x − 3) nπ 3(n2 π 2 x2 − 3n2 π 2 x − 18) nπ ¯¯
= − sin x+ cos x ¯
n2 π 2 3 n3 π 3 3 0
32(1 − (−1) ) n
= .
n3 π 3
This gives
∞
32 (1 − (−1)n ) − n2 π2 t nπ
v(x, t) =
π3 ∑ n 3
e 9 sin
3
x.
n=1
and since u = v + x, we obtain the solution for u as
∞
32 (1 − (−1)n ) − n2 π2 t nπ
u(x, t) = x +
π3 ∑ n 3
e 9 sin
3
x. (4.49)
n=1
4
y
t = 0
t = 1
2 t = 2
x
0
0 1 2 3
Example 5
Solve
ut = u xx , 0 < x < 1, t>0 (4.50)
subject to
u(x, 0) = 0 u x (0, t) = −1, u x (1, t) = 0. (4.51)
4.1. The heat equation 13
noting now
ut = u xx , ⇒ vt = v xx . (4.54)
subject to
1
v(x, 0) = x − x2 , v x (0, t) = v x (1, t) = 0 (4.57)
2
A separation of variables v = XT leads to X 00 = −k2 X and T 0 = −k2 T
from which we obtain
c1 = 0, k = nπ, (4.59)
and further
2 π2 t
T(t) = c3 e−n . (4.61)
Finally we arrive at
∞
a0 2 2
v(x, t) = + ∑ an e−n π t cos nπx.
2 n=1
Figure 6 shows plots at time t = 0.01, 0.5, 1.0 and 1.5. It is interesting to
note that at the left boundary u x = −1 and since the flux φ = −ku x implies
that φ = k > 0 which gives that the flux is position and that heat is being
added at the left boundary. Hence the profile increase at the left while
insulated at the right boundary (no flux).
4.1. The heat equation 15
2 y
t = 1.5
1
t = 1.0
t = 0.5
t = 0.1
0
x
0.0 0.5 1.0
The new initial condition doesn’t pose a problem but how do we solve the
heat equation with a term added to the equation.
where
16(1 − (−1)n ) − n2 π2 t
Tn (t) = e 4 (4.71)
n3 π 3
We note that even if this Tn wasn’t known, we could find it as substitution
of (4.70) into the heat equation and isolating coefficients of sin nπx
2 , would
lead to
n2 π 2
Tn0 (t) = − Tn (t),
4
leading to the solution (4.71). For the problem with a source term we look
for solutions of the same form i.e. (4.70). However, in order that this tech-
nique works, it is necessary to expand the source term also in terms of a
Fourier sine series, i.e.
∞
nπx
Q(x) = ∑ qn sin 2
. (4.72)
n=1
For (
x if 0 < x < 1,
Q(x) = (4.73)
2−x if 1 < x < 2,
4.1. The heat equation 17
where
Z 2
nπx
qn = Q(x) sin dx.
0 2
Z 1 Z 2
nπx nπx
= x sin dx + (2 − x) sin dx,
0 2 x 2
· ¸¯
4 nπx nπx ¯¯1
= sin − 2xnπ cos
n2 π 2 2 2 ¯0
· ¸¯
4 nπx 2x4 nπx ¯¯2
+ − 2 2 sin + cos ,
n π 2 nπ 2 ¯1
8 nπx
= sin . (4.74)
n2 π 2 2
Substituting both (4.70) and (4.72) into (4.69) gives
∞
nπx ∞ ³ nπx ´2 nπx ∞
nπx
∑ Tn0 (t) sin = ∑− Tn (t) sin + ∑ qn sin ,
n=1
2 n=1
2 2 n=1
2
n2 π 2
Tn0 (t) + Tn (t) = qn , (4.75)
4
a linear ODE in Tn (t)! On solving (4.75) we obtain
4 nπ 2
Tn (t) = qn + bn e−( 2 ) t ,
n2 π 2
giving the final solution
∞ µ ¶
4 −( nπ )2 t nπx
u(x, t) = ∑ 2
n π 2
q n + bn e 2 sin
2
. (4.76)
n=1
If we set
4
cn = qn + bn ,
n2 π 2
then we have
∞
2 nπx
2x − x = ∑ cn sin 2
.
n=1
18 Chapter 5. Separation of Variables
where qn and cn are given in (4.74) and (4.77), respectively. Typical plots
are given in figure 7 at times t = 0, 1, 2 and 3.
1.0 y
t = 0
t = 1
0.5
t = 2
t = 3
0.0
x
0 1 2
and ask “Is is possible to find A such that the source term in (4.83) can be
removed?” Substituting of (4.84) in (4.83) gives
Avt + At v = Av xx + 2A x v x + A xx v + αAv,
20 Chapter 5. Separation of Variables
Figure 8 shows plots at times t = 0, 0.1 and 0.2 when α = 5 and 12. It
is interesting to note that in the case where α = 5, the diffusion is slower
in comparison with no source term (i.e α = 0 see Figure 1) and there is no
diffusion at all when α = 12.
t = 0.2
0.3 0.4 y
t= 0
t = 0.1
0.2 t= 0
t = 0.1
0.2
t = 0.2
0.1
0.0 0.0
x x
0.0 0.5 1.0 0.0 0.5 1.0
Figure 8. The solution (4.88) of the heat equation with a source (4.83) with α = 5
and α = 12.
Example 6
Solve
and so the insulted boundary conditions also remain insulated! Thus, the
problem (4.90) becomes
where
Z 2 · ¸¯2
2 3 x4 ¯¯
2
a0 = (4x − x ) dx = 2x − = 4,
2 0 4 ¯0
Z
2 2 nπ
an = (4x − x3 ) cos x dx (4.95)
2 0 2
·µ ¶ µ ¶ ¸¯2
2(4x − x3 ) 48 nπ 4(4 − 3x2 ) 96 nπ ¯¯
= + 3 3 sin x+ + 4 4 cos x ¯
nπ n π 2 n2 π 2 n π 2 0
µ ¶ µ ¶
16 96 6 48 nπ 4 96 nπ
= − 2 2− 4 4+ + 3 3 sin + 2 2
+ 4 4 cos .
n π n π nπ n π 2 n π n π 2
where an is given in (4.95). Figure 9 show plots at t = 0, 0.2, 0.4 and 0.6
when α = −2 and 2. It is interesting to note that the sign of α will deter-
mine whether the solution will grow or decay exponentially.
4.1. The heat equation 23
y y
3 t= 0 8
t = 0.6
6
2
t = 0.4
4
t = 0.2
t = 0.2
1 t = 0.4
2
t = 0.6
t= 0
0 x 0
x
0 1 2
0 1 2
Figure 9. The solution (4.96) of the heat equation with a source (4.90) with no
flux boundary condition with α = −2 and α = 2.
and ask “Is is possible to find A such that the convection term can be re-
moved?” Substituting of (4.98) in (4.97) gives
Avt + At v = Av xx + 2A x v x + A xx v + β (Av x + A x v) ,
24 Chapter 5. Separation of Variables
2A x + βA = 0, A xx − At + βA x = 0. (4.100)
1
From the first we obtain that A(x, t) = C(t)e− 2 βx and from the second
β2 1 2
we obtain C 0 + 4 C = 0 which has the solution C(t) = A0 e− 4 β t for some
constant A0 . This then gives
1 1 2
A(x, t) = A0 e− 2 βx− 4 β t
(4.101)
1 1 2
∞
2 2
u(x, t) = e− 2 βx− 4 β t
∑ bn e−n π t sin nπx, (4.109)
n=1
For β = −12
Z 1
bn = 2 (x − x2 )e−6x sin nπx dx
0
7n2 π 2 + 108 + (5n2 π 2 + 324)e−6 cos nπ
= 2nπ . (4.111)
(36 + n2 π 2 )3
1 1 2
u(x, t) = 4πe− 2 βx− 4 β t (4.112)
∞ 2 2 2 2 3
27 + n π + 2n π e cos nπ −n2 π2 t
× ∑n e sin nπx,
n=1
(9 + n2 π 2 )3
1 1 2
u(x, t) = 2πe− 2 βx− 4 β t (4.113)
∞ 2 2 2 2 −6
7n π + 108 + (5n π + 324)e cos nπ −n2 π2 t
× ∑n 2 π 2 )3
e sin nπx.
n=1
(36 + n
0.3 y 0.3 y
t= 0 t= 0
t = 0.025
0.2 0.2
t = 0.05
t = 0.05
0.1 t = 0.1 0.1
0.0 x 0.0 x
0.0 0.5 1.0 0.0 0.5 1.0
Figure 10. The solution (4.112) of the heat equation with convection with fixed
boundary conditions with β = 6 and β = −12.
Example 7
As a final example, we consider
subject to
u(x, 0) = 4x − x3 u x (0, t) = 0, u x (2, t) = 0. (4.115)
1 1 2 β − 1 βx− 1 β2 t
u x = e− 2 βx− 4 β t v x − e 2 4 v, (4.116)
2
and so
β
u x (0, t) = 0 ⇒ v x (0, t) − v(0, t) = 0, (4.117)
2
β
u x (2, t) = 0 ⇒ v x (2, t) − v(2, t) = 0. (4.118)
2
4.2. Laplace’s equation 27
u xx + uyy = 0 (4.120)
We will show that a separation of variables also works for this equation
As an example consider the boundary conditions
X 00 Y + XY 00 = 0. (4.123)
4(1 − (−1)n )
an = . (4.135)
n3 π 3 sinh nπ
Thus, the solution to Laplace’s equation with the boundary conditions
given in (4.121) is
∞
4 1 − (−1)n sinh nπy
u(x, y) = 3
π ∑ n 3
sin nπx
sinh nπ
. (4.136)
n=1
y u
1.0 0.2
u = 0.2
u = 0.1
0.1
0.5
u = 0.05
u = 0.025 0.0
u = 0.001 0.5
1.0
0.0 1.0
x
0.0 0.5 1.0
y
x
Figure 11. The solution (4.120) with the boundary conditions (4.121)
subject to
is nπy
∞
nπx sinh Ly
u = ∑ bn sin , (4.139)
n=1
L x sinh nπ
Ly
30 Chapter 5. Separation of Variables
where Z Lx
2 nπx
bn = f (x) sin dx. (4.140)
Lx 0 Lx
Example 8
Solve
u xx + uyy = 0, (4.141)
subject to
X 00 Y + XY 00 = 0. (4.144)
X 00 Y 00
+ = 0, (4.145)
X Y
X 00 Y 00
= λ, = −λ (4.146)
X Y
16
An = (1 − cos nπ), (4.155)
n3 π 3
32 Chapter 5. Separation of Variables
and further that the solution to Laplace’s equation with the boundary con-
ditions given in (4.141) subject to (4.186) is
∞
4 1 − (−1)n sinh nπx
u= 3
π ∑ n3 sinh nπ
sin nπy. (4.156)
n=1
Figure 12 show both a top view and a 3 − D view of the solution. In com-
paring the solutions (4.136) and (4.156) shows that if we interchange x and
y they are the same. This should not be surprising because if we con-
sider Laplace equations with the boundary conditions given in (4.121) and
(4.186), that if we interchange x and y, the problems are transformed to
each other.
In general, using separation of variables, the solution of
subject to
u(x, 0) = 0, u(x, 1) = 0
u(0, y) = 0, u(1, y) = g(y).
is
∞ sinh nπx
Lx nπy
u= ∑ bn sinh nπ sin
Ly
(4.159)
n=1 Lx
where Z Ly
2 nπy
bn = g(y) sin dy (4.160)
Ly 0 Ly
Example 9
Solve
u xx + uyy = 0 (4.161)
subject to
leads to
X 00 Y + XY 00 = 0, (4.164)
noting that the last boundary condition is different than the boundary con-
dition considered at the beginning of this section (i.e. Y(0) = 0). The re-
maining boundary condition in (4.162a) will be used later. In order to solve
the X equation in (4.166) subject to the boundary conditions (4.167), it is
necessary to set λ = −k2 . The X equation (4.166) as the general solution
subject to
is
nπ(1−y)
∞
nπx sinh Ly
u = ∑ bn sin (4.180)
n=1
Lx sinh nπ
Ly
where Z Lx
2 nπx
bn = f (x) sin dx (4.181)
Lx 0 Lx
Example 10
As the final example, we consider
u xx + uyy = 0 (4.182)
subject to
subject to
u(x, 0) = 0, u(x, 1) = 0
u(0, y) = g(y), u(1, y) = 0.
36 Chapter 5. Separation of Variables
is
∞ sinh nπ(1−x)
Ly nπy
u= ∑ bn sinh nπ sin
Ly
. (4.187)
n=1 Ly
where Z Ly
2 nπy
bn = g(y) sin dy (4.188)
Ly 0 Ly