The heat equation
Picture a thin metal rod along the -axis, wrapped so that heat can only flow along it. Write for its temperature at position and time . The heat equation says how that temperature changes.
Rule: The heat equation
The left side is how fast the temperature at a fixed point changes in time. The right side is how the profile bends at that point at that moment: the second partial in , with held fixed (lesson 4.1.2).
Lesson 6.3.1 met this equation and checked solutions such as and by computing their partials. This lesson explains what the equation does to a profile, and why.
Units, and the diffusivity
For a real rod the equation reads . The diffusivity says how fast heat spreads in the material. It is in units of length² per unit of time, such as m² per second, so both sides are in degrees per unit of time.
A change of clock removes . Measure time as ; by the chain rule (lesson 4.2.2), , so the equation becomes . With , two seconds make one unit of .
From here on . Case study 6.4.4 removes a in exactly this way.
Hot to cold: the bend and the neighbours
The second central difference (lessons 2.4.2 and 2.8.1) estimates the bend from three values a step apart. Write for the average of the two neighbours. Then
So means the point is colder than its neighbours on average. Heat flows in from them, and the heat equation says the point warms. A point hotter than its neighbours cools.
Rule: Which way a point moves
The speed is the size of the bend. Only the bend counts, not the height or the slope: a straight profile such as never changes, however steep it is.
A worked example: a dip between two peaks
Take a rod of length whose ends are held at temperature 0, a boundary condition as in lesson 6.3.2. Start it at : two peaks with a dip between them. The solution is
Each term solves the equation, and the equation is linear, so their sum does too (lesson 6.3.1). For the second term, , and differentiating twice in gives , the same.
At the bend is . The table checks it against the neighbours with . It looks at the dip, the left peak, and the point between them where the bend changes sign.
| point | neighbours' average | second difference | |||
|---|---|---|---|---|---|
| dip | 1.5708 | 0.5 | 0.5173 | 3.4672 | 3.5 |
| left peak | 0.7017 | 1.0758 | 1.0534 | ||
| between | 1.1141 | 0.7978 | 0.7978 | 0 |
The dip is colder than its neighbours, so it warms at 3.5 degrees per unit of time. The peaks cool at about 4.5. Between them the point is, for a moment, still.
| time | 0 | 0.05 | 0.1 | 0.2 | 0.5 | 1 |
|---|---|---|---|---|---|---|
| dip, | 0.5 | 0.6324 | 0.7016 | 0.7361 | 0.601 | 0.3678 |
| peak, | 1.0758 | 0.8884 | 0.759 | 0.5996 | 0.3963 | 0.2375 |
The dip fills in until , when it reaches 0.7365. After that the whole profile sinks, because heat leaks out through the cold ends.
The profile bends down at the peaks, so they sink; it bends up at the dip, so the dip rises. By the dip has gone, and the single hump that is left sinks as heat leaves through the ends.
Try it
SymPy confirms that is 0. The loop prints the first table: , the neighbours' average, and the second difference with .
The last loop prints the second table, the dip and the peak over time.
Fine wiggles fade fastest
The example has two waves, and they fade at different rates. For any number , the wave solves the heat equation, because and are both .
Rule: Decaying waves
A wave with times as many wiggles fades times as fast: its height halves after time . The same holds with . Fine detail dies first, so the heat equation smooths a profile.
| wiggles | 1 | 2 | 3 | 10 |
|---|---|---|---|---|
| height left at | 0.9048 | 0.6703 | 0.4066 | |
| time to halve | 0.6931 | 0.1733 | 0.077 | 0.0069 |
In the example the wave fades 9 times as fast as . By it is down to of its start, which is why one hump is left.
Lesson 6.3.2 found that running the heat equation backwards makes small ripples explode. The waves show why: backwards in time each one grows like , and the finest grow fastest.
Corners and jumps
A corner is smoothed at once. Take the kink : its slope jumps from 0 to 1 at , so does not exist there. Its second difference at 0 is , which is 10, 100 and 1000 for = 0.1, 0.01 and 0.001.
That grows without limit as shrinks, so the corner starts to rise infinitely fast and is rounded off immediately. A jump, such as a step from 0 to 1, is smoothed at once in the same way. Away from the corner, where the kink is straight, nothing happens at first.
Try it
The first loop prints the table: what is left of each wave at , to 4 significant figures, and its time to halve. 4.54e-05 means .
Then the wave at , and the kink's second difference at 0 for three steps: each time. round hides float noise.
The explorer shows the heat equation smoothing three profiles on a long rod. Choose the kink and set : the corner is already round, while at the profile has not moved. Then choose the spike and move up to 1. The height at 0 falls from 3.3333 to about 0.28, while the spread grows to 1.4142.
Explore
Heat flows from hot to cold, so peaks sink and dips fill in. Move time forward and watch the profile spread out; a corner is smoothed at once.
Dashed: the profile at time 0. Dark: the exact solution.
- Height at x = 0
- 0.1262
- Spread
- the bell curve that smooths it has standard deviation √(2t) = 0.3162
Total heat stays the same
The total heat in the rod between and is the area under the profile, . Its rate of change is . By the fundamental theorem (lesson 2.5.3) that is the difference of the slopes at the two ends.
Rule: Conservation of heat
The slope at an end measures heat flowing in or out there. With no flow through the ends, the total stays the same: heat moves about, but none is made or lost.
That holds for an insulated rod, whose ends have , and on an endless line when the profile is flat and zero far out. It fails when heat can cross the ends.
The rod of the example has its ends held at 0, so heat leaks out. At the start at and at , so the total falls at per unit of time. Integrating the solution gives : 2.3333 at the start, 1.9452 at , 1.2168 at 0.5 and 0.7358 at 1.
Try it
quad integrates the profile at four times, next to the formula .
The last line prints the slopes at the two ends at and their difference, the rate at which the total changes.
Spreading like
Now put one unit of heat in a narrow tent around on an endless rod. As time passes the heat spreads out, but its centre stays at 0 and its total stays 1. Read the profile as a density (lesson 5.4.1): its variance, , grows by exactly 2 per unit of time.
Rule: Spreading
For a total heat of 1 centred at 0; the width is the standard deviation. Stated here and checked below; lesson 6.4.2 meets it in an exact solution. Since the area stays 1 while the width grows, the peak falls like .
| time | 0.01 | 0.04 | 0.16 | 0.64 |
|---|---|---|---|---|
| width | 0.1414 | 0.2828 | 0.5657 | 1.1314 |
Four times the time gives only twice the width. A fair random walk spreads in the same way: after steps its standard deviation is (lesson 5.11.1). Heat is the same fact in continuous time, and lesson 6.4.2 makes the link exact.
Stepping a profile forward
A computer can follow the heat equation directly. Keep the profile's values on a grid of points apart, and estimate the bend at each by the second difference. Then take a short time step : each value moves by times its bend, towards its neighbours' average.
Lesson 6.5.1 studies this method, its error and how short must be. Here and , a fifth of , which is safely small.
Try it
The tent has half-width 0.2 and area 1, on a grid from to 8 whose end values stay 0. Each pass of the loop is one time step for every inner point at once.
At = 0.25, 0.5 and 1 the cell prints the total heat, the growth of the variance and the peak. The total stays 1 and the variance grows by . The peak, 0.5606, 0.3977 and 0.2816, is close to : lesson 6.4.2's height for heat that starts at a single point.
Common mistakes
- The bend drives the change, not the height or the slope. A steep but straight profile does not change at all.
- Check the sign. rises where , where the profile bends up: a dip. It falls at a peak.
- Corners and jumps have no . The second difference there grows like , and the corner is rounded at once.
- Heat is conserved only when none crosses the ends. Ends held at a fixed temperature let heat out or in, at the rate given by the slopes there.
- The width grows like , not like . From a single point it is : four times the time, twice the width.
- Mind the clock. For , use the results of this lesson with in place of .
Diffusion and the heat equation
0 of 13 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- The heat equation : the temperature at a point changes at the rate the profile bends there. With a diffusivity, becomes with .
- , with the neighbours' average: a point colder than its neighbours warms. Peaks sink, dips fill in, straight stretches stay put.
- is a solution: fine wiggles fade times as fast, so corners and jumps are smoothed at once.
- Total heat changes by : it is conserved when no heat crosses the ends.
- From a point, heat spreads to width ; the variance grows by and the peak falls like .