Chapter 9 : Partial Differential Equations Section 9.
5 : Solving the Heat Equation
9.5 Solving the Heat Equation
Okay, it is finally time to completely solve a partial differential equation. In the previous section we
applied separation of variables to several partial differential equations and reduced the problem
down to needing to solve two ordinary differential equations. In this section we will now solve those
ordinary differential equations and use the results to get a solution to the partial differential equation.
We will be concentrating on the heat equation in this section and will do the wave equation and
Laplace’s equation in later sections.
The first problem that we’re going to look at will be the temperature distribution in a bar with zero
temperature boundaries. We are going to do the work in a couple of steps so we can take our time
and see how everything works.
The first thing that we need to do is find a solution that will satisfy the partial differential equation
and the boundary conditions. At this point we will not worry about the initial condition. The solution
we’ll get first will not satisfy the vast majority of initial conditions but as we’ll see it can be used to
find a solution that will satisfy a sufficiently nice initial condition.
Example 1
Find a solution to the following partial differential equation that will also satisfy the boundary
conditions.
∂u ∂2u
=k 2
∂t ∂x
u (x, 0) = f (x) u (0, t) = 0 u (L, t) = 0
Solution
Okay the first thing we technically need to do here is apply separation of variables. Even
though we did that in the previous section let’s recap here what we did.
First, we assume that the solution will take the form,
u (x, t) = ϕ (x) G (t)
and we plug this into the partial differential equation and boundary conditions. We separate
the equation to get a function of only t on one side and a function of only x on the other
side and then introduce a separation constant. This leaves us with two ordinary differential
equations.
We did all of this in Example 1 of the previous section and the two ordinary differential
© Paul Dawkins Differential Equations – 520 –
Chapter 9 : Partial Differential Equations Section 9.5 : Solving the Heat Equation
equations are,
dG d2 ϕ
= −kλG + λϕ = 0
dt dx2
ϕ (0) = 0 ϕ (L) = 0
The time dependent equation can really be solved at any time, but since we don’t know what
λ is yet let’s hold off on that one. Also note that in many problems only the boundary value
problem can be solved at this point so don’t always expect to be able to solve either one at
this point.
The spatial equation is a boundary value problem and we know from our work in the previous
chapter that it will only have non-trivial solutions (which we want) for certain values of λ,
which we’ll recall are called eigenvalues. Once we have those we can determine the non-
trivial solutions for each λ, i.e. eigenfunctions.
Now, we actually solved the spatial problem,
d2 ϕ
+ λϕ = 0
dx2
ϕ (0) = 0 ϕ (L) = 0
in Example 1 of the Eigenvalues and Eigenfunctions section of the previous chapter for
L = 2π. So, because we’ve solved this once for a specific L and the work is not all that
much different for a general L we’re not going to be putting in a lot of explanation here and if
you need a reminder on how something works or why we did something go back to Example
1 from the Eigenvalues and Eigenfunctions section for a reminder.
We’ve got three cases to deal with so let’s get going.
λ>0
In this case we know the solution to the differential equation is,
√ √
ϕ (x) = c1 cos λ x + c2 sin λx
Applying the first boundary condition gives,
0 = ϕ (0) = c1
Now applying the second boundary condition, and using the above result of course, gives,
√
0 = ϕ (L) = c2 sin L λ
Now, we are after non-trivial solutions and so this means we must have,
√ √
sin L λ = 0 ⇒ L λ = nπ n = 1, 2, 3, . . .
© Paul Dawkins Differential Equations – 521 –
Chapter 9 : Partial Differential Equations Section 9.5 : Solving the Heat Equation
The positive eigenvalues and their corresponding eigenfunctions of this boundary value
problem are then,
nπ 2 n π x
λn = ϕn (x) = sin n = 1, 2, 3, . . .
L L
Note that we don’t need the c2 in the eigenfunction as it will just get absorbed into another
constant that we’ll be picking up later on.
λ=0
The solution to the differential equation in this case is,
ϕ (x) = c1 + c2 x
Applying the boundary conditions gives,
0 = ϕ (0) = c1 0 = ϕ (L) = c2 L ⇒ c2 = 0
So, in this case the only solution is the trivial solution and so λ = 0 is not an eigenvalue for
this boundary value problem.
λ<0
Here the solution to the differential equation is,
√ √
ϕ (x) = c1 cosh −λ x + c2 sinh −λ x
Applying the first boundary condition gives,
0 = ϕ (0) = c1
and applying the second gives,
√
0 = ϕ (L) = c2 sinh L −λ
√ √
So, we are assuming λ < 0 and so L −λ 6= 0 and this means sinh L −λ 6= 0. We
therefore we must have c2 = 0 and so we can only get the trivial solution in this case.
Therefore, there will be no negative eigenvalues for this boundary value problem.
The complete list of eigenvalues and eigenfunctions for this problem are then,
nπ 2 n π x
λn = ϕn (x) = sin n = 1, 2, 3, . . .
L L
Now let’s solve the time differential equation,
dG
= −kλn G
dt
© Paul Dawkins Differential Equations – 522 –
Chapter 9 : Partial Differential Equations Section 9.5 : Solving the Heat Equation
and note that even though we now know λ we’re not going to plug it in quite yet to keep the
mess to a minimum. We will however now use λn to remind us that we actually have an
infinite number of possible values here.
This is a simple linear (and separable for that matter) 1st order differential equation and so
we’ll let you verify that the solution is,
nπ 2
G (t) = ce−kλ n t = ce−k L
t
Okay, now that we’ve gotten both of the ordinary differential equations solved we can finally
write down a solution. Note however that we have in fact found infinitely many solutions
since there are infinitely many solutions (i.e. eigenfunctions) to the spatial problem.
Our product solution are then,
nπx nπ 2
un (x, t) = Bn sin e−k L
t
n = 1, 2, 3, . . .
L
We’ve denoted the product solution un to acknowledge that each value of n will yield a
different solution. Also note that we’ve changed the c in the solution to the time problem to
Bn to denote the fact that it will probably be different for each value of n as well and because
had we kept the c2 with the eigenfunction we’d have absorbed it into the c to get a single
constant in our solution.
So, there we have it. The function above will satisfy the heat equation and the boundary condition
of zero temperature on the ends of the bar.
The problem with this solution is that it simply will not satisfy almost every possible initial condition
we could possibly want to use. That does not mean however, that there aren’t at least a few that
it will satisfy as the next example illustrates.
Example 2
Solve the following heat problem for the given initial conditions.
∂u ∂2u
=k 2
∂t ∂x
u (x, 0) = f (x) u (0, t) = 0 u (L, t) = 0
πx
(a) f (x) = 6 sin
L
9πx 4πx
(b) f (x) = 12 sin − 7 sin
L L
© Paul Dawkins Differential Equations – 523 –
Chapter 9 : Partial Differential Equations Section 9.5 : Solving the Heat Equation
Solution
πx
(a) f (x) = 6 sin
L
This is actually easier than it looks like. All we need to do is choose n = 1 and B1 = 6
in the product solution above to get,
πx π 2
u (x, t) = 6 sin e−k L t
L
and we’ve got the solution we need. This is a product solution for the first example and
so satisfies the partial differential equation and boundary conditions and will satisfy the
initial condition since plugging in t = 0 will drop out the exponential.
9πx 4πx
(b) f (x) = 12 sin − 7 sin
L L
This is almost as simple as the first part. Recall from the Principle of Superposition that
if we have two solutions to a linear homogeneous differential equation (which we’ve
got here) then their sum is also a solution. So, all we need to do is choose n and Bn
as we did in the first part to get a solution that satisfies each part of the initial condition
and then add them up. Doing this gives,
9πx −k 9π
2 4πx 4π 2
u (x, t) = 12 sin e L
t
− 7 sin e−k L t
L L
We’ll leave it to you to verify that this does in fact satisfy the initial condition and the
boundary conditions.
So, we’ve seen that our solution from the first example will satisfy at least a small number of highly
specific initial conditions.
Now, let’s extend the idea out that we used in the second part of the previous example a little to
see how we can get a solution that will satisfy any sufficiently nice initial condition. The Principle of
Superposition is, of course, not restricted to only two solutions. For instance, the following is also
a solution to the partial differential equation.
M nπx nπ 2
X
u (x, t) = Bn sin e−k L
t
L
n=1
and notice that this solution will not only satisfy the boundary conditions but it will also satisfy the
initial condition,
XM nπx
u (x, 0) = Bn sin
L
n=1
Let’s extend this out even further and take the limit as M → ∞. Doing this our solution now
becomes,
∞ nπx nπ 2
X
u (x, t) = Bn sin e−k L t
L
n=1
© Paul Dawkins Differential Equations – 524 –
Chapter 9 : Partial Differential Equations Section 9.5 : Solving the Heat Equation
This solution will satisfy any initial condition that can be written in the form,
X∞ nπx
u (x, 0) = f (x) = Bn sin
L
n=1
This may still seem to be very restrictive, but the series on the right should look awful familiar to
you after the previous chapter. The series on the left is exactly the Fourier sine series we looked at
in that chapter. Also recall that when we can write down the Fourier sine series for any piecewise
smooth function on 0 ≤ x ≤ L.
So, provided our initial condition is piecewise smooth after applying the initial condition to our
solution we can determine the Bn as if we were finding the Fourier sine series of initial condition.
So we can either proceed as we did in that section and use the orthogonality of the sines to derive
them or we can acknowledge that we’ve already done that work and know that coefficients are
given by,
2 L
Z n πx
Bn = f (x) sin dx n = 1, 2, 3, . . .
L 0 L
So, we finally can completely solve a partial differential equation.
Example 3
Solve the following BVP.
∂u ∂2u
=k 2
∂t ∂x
u (x, 0) = 20 u (0, t) = 0 u (L, t) = 0
Solution
There isn’t really all that much to do here as we’ve done most of it in the examples and
discussion above.
First, the solution is,
∞ nπx nπ 2
X
u (x, t) = Bn sin e−k L
t
L
n=1
The coefficients are given by,
L
40 (1 − (−1)n )
20L (1 − cos (nπ))
Z
2 n πx 2
Bn = 20 sin dx = =
L 0 L L nπ nπ
If we plug these in we get the solution,
∞
X 40 (1 − (−1)n ) nπx nπ 2
u (x, t) = sin e−k L
t
nπ L
n=1
© Paul Dawkins Differential Equations – 525 –
Chapter 9 : Partial Differential Equations Section 9.8 : Vibrating String
9.8 Vibrating String
This will be the final partial differential equation that we’ll be solving in this chapter. In this sec-
tion we’ll be solving the 1-D wave equation to determine the displacement of a vibrating string.
There really isn’t much in the way of introduction to do here so let’s just jump straight into the
example.
Example 1
Find a solution to the following partial differential equation.
∂2u 2
2∂ u
= c
∂t2 ∂x2
∂u
u (x, 0) = f (x) (x, 0) = g (x)
∂t
u (0, t) = 0 u (L, t) = 0
Solution
One of the main differences here that we’re going to have to deal with is the fact that we’ve
now got two initial conditions. That is not something we’ve seen to this point but will not be
all that difficult to deal with when the time rolls around.
We’ve already done the separation of variables for this problem, but let’s go ahead and redo
it here so we can say we’ve got another problem almost completely worked out.
So, let’s start off with the product solution.
u (x, t) = ϕ (x) h (t)
Plugging this into the two boundary conditions gives,
ϕ (0) = 0 ϕ (L) = 0
Plugging the product solution into the differential equation, separating and introducing a
separation constant gives,
∂2
2 ∂
2
ϕ (x) h (t) = c ϕ (x) h (t)
∂t2 ∂x2
2
d h d2 ϕ
ϕ (x) 2 = c2 h (t) 2
dt dx
1 d2 h 1 d2 ϕ
= = −λ
c2 h dt2 ϕ dx2
We moved the c2 to the left side for convenience and chose −λ for the separation constant
so the differential equation for ϕ would match a known (and solved) case.
© Paul Dawkins Differential Equations – 549 –
Chapter 9 : Partial Differential Equations Section 9.8 : Vibrating String
The two ordinary differential equations we get from separation of variables are then,
d2 h d2 ϕ
+ c2 λh = 0 + λϕ = 0
dt2 dx2
ϕ (0) = 0 ϕ (L) = 0
We solved the boundary value problem above in Example 1 of the Solving the Heat Equation
section of this chapter and so the eigenvalues and eigenfunctions for this problem are,
nπ 2 n π x
λn = ϕn (x) = sin n = 1, 2, 3, . . .
L L
The first ordinary differential equation is now,
d2 h nπc 2
+ h=0
dt2 L
and because the coefficient of the h is clearly positive the solution to this is,
nπc t nπc t
h (t) = c1 cos + c2 sin
L L
Because there is no reason to think that either of the coefficients above are zero we then
get two product solutions,
nπc t n π x
un (x, t) = An cos sin
L L
n = 1, 2, 3, . . .
nπc t n π x
un (x, t) = Bn sin sin
L L
The solution is then,
∞ n π x
X nπc t n π x nπc t
u (x, t) = An cos sin + Bn sin sin
L L L L
n=1
Now, in order to apply the second initial condition we’ll need to differentiate this with respect
to t so,
∞ n π x
∂u X nπc nπc t n π x nπc nπc t
= − An sin sin + Bn cos sin
∂t L L L L L L
n=1
If we now apply the initial conditions we get,
∞ h
X n π x n π x i X∞ n π x
u (x, 0) = f (x) = An cos (0) sin + Bn sin (0) sin = An sin
L L L
n=1 n=1
∞
∂u X nπc n π x
(x, 0) = g (x) = Bn sin
∂t L L
n=1
© Paul Dawkins Differential Equations – 550 –
Chapter 9 : Partial Differential Equations Section 9.8 : Vibrating String
Both of these are Fourier sine series. The first is for f (x) on 0 ≤ x ≤ L while the second
is for g (x) on 0 ≤ x ≤ L with a slightly messy coefficient. As in the last few sections we’re
faced with the choice of either using the orthogonality of the sines to derive formulas for An
and Bn or we could reuse formula from previous work.
It’s easier to reuse formulas so using the formulas form the Fourier sine series section we
get,
2 L
Z n πx
An = f (x) sin dx n = 1, 2, 3, . . .
L 0 L
2 L
Z
nπc n πx
Bn = g (x) sin dx n = 1, 2, 3, . . .
L L 0 L
Upon solving the second one we get,
2 L
Z n πx
An = f (x) sin dx n = 1, 2, 3, . . .
L 0 L
Z L
2 n πx
Bn = g (x) sin dx n = 1, 2, 3, . . .
nπc 0 L
So, there is the solution to the 1-D wave equation and with that we’ve solved the final partial
differential equation in this chapter.
© Paul Dawkins Differential Equations – 551 –