Alex Dowad Computes
Explorations in the world of code

Understanding the Heat Equation

As the name suggests, the Heat Equation describes how heat travels through some material; say, a metal bar with one end thrust into a fire. In its simplest form, the equation is:

Where is the temperature of a small piece of the metal bar at location , and time . Using subscripts to denote taking derivatives of a function, we could also write it this way:

To keep this discussion as simple as possible, I am only presenting the one-dimensional version of the equation; that’s the one which applies (approximately) to long, thin objects, like a strand of thin wire.[1] Also, there should really be a constant of proportionality in the equation, which depends on the units you are using, the thermal conductivity of the material, and its heat capacity. However, to keep things simpler, let’s imagine everything works out so that the constant is 1 (and can thus be ignored).[2]

Even if you know calculus, this equation might seem puzzling at first; it certainly was puzzling to me. It basically says: The rate at which temperature changes over time at any fixed point in the metal bar, equals the rate of change of the rate of change of temperature as you move up or down the bar from that fixed point. What a mouthful!

This article tries to impart intuition for why the heat equation is what it is, including where the “rate of change of the rate of change” comes in. If I succeed, should seem perfectly obvious when you reach the end. This is the strategy:

  1. Present a discrete model of heat conduction through the metal bar, where we divide the bar into many thin slices and pretend temperature doesn’t vary between different parts of the same slice; i.e. at any moment in time, each slice has a constant temperature. We will also divide time into discrete steps.
  2. Examine a simulation of the discrete model to build familiarity with it.
  3. Show that the behavior we observe in the simulation is reminiscent of the behavior of a second derivative.
  4. Prove mathematically that as we make the slices thinner and thinner, and time steps shorter and shorter, our discrete model becomes equivalent to the differential equation .

A Simple Model of Heat Conduction

Divide our metal bar into slices of thickness , and divide time into steps of length . How can we approximate the changes in temperature caused by heat conduction between slice and slice in a single time step?

Basic physics tells us that the rate of heat conduction between two objects is proportional to their temperature difference. Also, the amount of heat energy which conducts from one object to another is also proportional to the amount of time which passes, and inversely proportional to the distance which the heat energy needs to travel. Further, as the slices get smaller, the thermal mass of each slice becomes less, so its temperature changes faster for the same gain or loss of heat energy. So, if we are only interested in two neighbouring slices at positions and , a very simple model is:

In other words, at each time step, take the difference in temperature between each slice and its neighbour, multiply the difference by , then add that number to the temperature of the colder slice and subtract it from the hotter slice. Of course, we should do this for all pairs of neighbouring slices, not just for two of them.

If we include the effects of heat transfer to or from both neigbours, then our formula becomes:

And here’s a computer simulation:

Analyzing the Model

After playing with the above simulation a bit, can you summarize which parts of the bar get hotter and which get colder at any particular moment? Well, obviously the parts which are hotter than average tend to get colder eventually, and the parts which are colder than average tend to get hotter, eventually. That describes the long-term change; but can you be a bit more precise about what happens at any particular moment? (Click or tap below to reveal a possible answer.)

To start connecting this model back to the heat equation, we will now think about the geometrical properties of second derivatives. tells us that the rate at which temperature changes at any fixed point is determined by a second partial derivative of the function . So what does the graph of a second derivative look like?

Students of calculus learn early on that the second derivative measures the “curvature” of a function’s graph. If the graph of curves upward, then its second derivative will be positive; if curves downward, then will be negative. Or, if is a straight line, then will be zero.

Doesn’t that remind you of how we summarized the behavior of our heat conduction model just now? As an example, I said that if a slice is 10 degrees hotter than its left neighbour and 10 degrees colder than its right neighbour (meaning the temperature graph is a straight line at that point), then its temperature won’t change at that time step (second derivative is zero). I also said that if a slice is colder than both its neighbours (temperature graph is concave, opening upwards), its temperature will increase (second derivative is positive). Let me not belabor this, but hopefully you can see that the same connection holds for other cases, such as when a slice is hotter than both its neighbours.

Proving the Connection Between the Model and Original Equation

Don’t get scared; this is a very straightforward proof. It’s basically just a direct application of the limit definitions of derivatives.

The derivative of a function can be defined this way:

Here’s a visualization. Notice that the slope of the blue line is , which is the same as the value of the derivative. Make smaller and smaller, and notice that the slope of the blue line becomes the same as the slope of the function graph at that point.

For the derivatives on the right-hand side of the heat equation, I will use this alternative definition, which is equivalent as long as the graph has no “kinks” (sharp corners):

Here’s a visualization of that:

A second derivative is a derivative of a derivative. We can directly apply the above definition of a derivative, to a derivative, to get this:

Then insert the definition of into the definition of :

Now we need to extend the above definitions to cover partial derivatives. A partial derivative is where we take the above concept, and apply it to a function which depends on more than one variable. It measures how quickly the value of the function changes when one particular variable changes. The partial derivative of with respect to is:

We can take the definition of a second derivative from just above, and adjust it just a bit to get the second partial derivative of with respect to :

Again, the heat equation is . Substitute the above two limit definitions of those partial derivatives into the heat equation to get it into a new form:

I will abuse the limit notation and apply it to the heat equation as a whole, rather than to an expression:

Now we just need a small rearrangement of those terms:

Ta-dah!! Compare that to the formula which we used earlier to define our discrete model. It’s the same; the only difference is that we take the limit as and go to zero!

So there you have it; the heat equation is really just telling us that “each tiny piece of an object tends to get hotter if it’s colder than its neighbours (on average), or get colder if it’s hotter than its neighbours (on average)”.

Outro

In my next post, I will take this intuitive understanding of the Heat Equation, and apply it to a very similar and equally important differential equation: the Wave Equation. See you then!

[1] The two-dimensional heat equation, for objects similar to a thin, flat plate, is . The three-dimensional version is .

[2] If our units are seconds, millimeters, and degrees Celsius, then the constant multiplier in the heat equation is very close to 1 if the material is ice. Quartz and sandstone are also relatively close.

This post left you burning to speak your mind? Reach out and e-mail the author! Selected replies will be published here.