Heat Equation
The heat equation uₜ = kuₓₓ describes how the temperature u(x, t) in a rod changes over time. With both ends held at 0°, separation of variables gives u(x, t) = Σ bₙe^(−k(nπ/L)²t) sin(nπx/L), where the bₙ are the Fourier sine coefficients of the starting temperature. Every term decays, so the rod cools toward 0°.
Before this lesson: Fourier Sine and Cosine Series, Boundary Value Problems and Partial Derivatives
What the heat equation says
Picture a thin metal rod from x = 0 to x = L whose sides are insulated, so heat moves only along the rod. Let u(x, t) be the temperature at position x and time t. The heat equation is:
u_t = k\,u_{xx},\qquad 0 \lt x \lt L,\quad t \gt 0Here uₜ is the rate of change of temperature, uₓₓ is the second partial derivative in x, and the constant k > 0 is the thermal diffusivity. Where the temperature graph is concave up (a cold dip), uₓₓ > 0, so that spot warms up. Where it is concave down (a hot bump), it cools. Heat always flows to even out the temperature.
A complete problem also needs boundary conditions at the ends and an initial condition u(x, 0) = f(x), the starting temperature.
Solving the heat equation by separation of variables
Take the ends held at 0°: u(0, t) = 0 and u(L, t) = 0. Look for solutions of the form u = X(x)T(t). Substituting gives XT′ = kX″T, and dividing by kXT separates the variables:
\frac{T'}{kT} = \frac{X''}{X} = -\lambdaThe left side depends only on t and the right side only on x, so both must equal the same constant, written −λ. That gives two ordinary differential equations:
- X″ + λX = 0 with X(0) = X(L) = 0. This is the eigenvalue problem from boundary value problems, so λₙ = (nπ/L)² and Xₙ = sin(nπx/L).
- T′ = −kλₙT. Its solution is Tₙ = e^(−kλₙt), an exponential decay.
- Add all the products XₙTₙ (superposition), and choose the bₙ so that the sum equals f(x) at t = 0.
u(x,t) = \sum_{n=1}^{\infty} b_n e^{-k(n\pi/L)^2t}\sin\frac{n\pi x}{L},\qquad b_n = \frac{2}{L}\int_0^L f(x)\sin\frac{n\pi x}{L}\,dxThe bₙ are just the coefficients of the Fourier sine series of f. Because the decay rate grows like n², the higher terms die out quickly, and after a short time the first term is a very good approximation.
Other boundary conditions
| Ends | Boundary conditions | Solution |
|---|---|---|
| held at 0° | u(0,t) = u(L,t) = 0 | \sum b_n e^{-k(n\pi/L)^2t}\sin\frac{n\pi x}{L} (sine series of f) |
| insulated | u_x(0,t) = u_x(L,t) = 0 | \frac{a_0}{2} + \sum a_n e^{-k(n\pi/L)^2t}\cos\frac{n\pi x}{L} (cosine series of f) |
| held at T₁ and T₂ | u(0,t) = T_1,\ u(L,t) = T_2 | T_1 + (T_2 - T_1)\frac{x}{L} + v(x,t), where v solves the 0° problem with v(x, 0) = f(x) − [T₁ + (T₂ − T₁)x/L] |
In the last row, the straight line T₁ + (T₂ − T₁)x/L is the steady-state temperature: it satisfies the equation with uₜ = 0 and both end conditions. The leftover part v decays to 0.
Heat equation examples
Example 1: A single sine term
Solve uₜ = 2uₓₓ for 0 < x < π, with u(0, t) = u(π, t) = 0 and u(x, 0) = 5 sin 3x.
L = \pi \Rightarrow \lambda_n = n^2,\quad X_n = \sin nx
Eigenvalues for zero ends: (nπ/L)² = n².
b_3 = 5,\quad b_n = 0 \text{ for } n \ne 3f(x) = 5 sin 3x is already a sine series.
k\lambda_3 = 2 \cdot 9 = 18
Decay rate of the n = 3 term.
u(x,t) = 5e^{-18t}\sin 3xWrite b₃e^(−kλ₃t) sin 3x.
u_t = -90e^{-18t}\sin 3x,\quad 2u_{xx} = 2(-45e^{-18t}\sin 3x)Check: both sides equal −90e^(−18t) sin 3x.
Answer: u(x, t) = 5e^(−18t) sin 3x. The shape stays a sine wave and its height shrinks by the factor e^(−18t).
Example 2: A rod that starts at 100°
A rod of length π with k = 1 starts at 100° everywhere, and at t = 0 both ends are put in ice water and held at 0°. Find u(x, t).
b_n = \frac{2}{\pi}\int_0^{\pi} 100\sin nx\,dx = \frac{200\left(1 - (-1)^n\right)}{n\pi}Sine coefficient with L = π, as in the sine series of a constant.
b_n = \frac{400}{n\pi} \text{ (n odd)},\quad b_n = 0 \text{ (n even)}1 − (−1)ⁿ is 2 for odd n.
k\lambda_n = n^2
k = 1 and λₙ = n².
u(x,t) = \frac{400}{\pi}\sum_{n \text{ odd}}\frac{e^{-n^2t}}{n}\sin nxPut bₙ and the decay factors into the series.
Answer: u(x, t) = (400/π)(e^(−t) sin x + e^(−9t) sin 3x/3 + e^(−25t) sin 5x/5 + ⋯). The n = 3 term decays 9 times as fast as the first, so the profile quickly rounds into the shape of sin x.
Example 3: Insulated ends
Solve uₜ = 4uₓₓ for 0 < x < π with insulated ends, uₓ(0, t) = uₓ(π, t) = 0, and u(x, 0) = 3 + 2 cos 2x.
X_n = \cos nx,\quad \lambda_n = n^2,\quad n = 0, 1, 2, \ldots
Insulated ends give the cosine eigenfunctions, including the constant n = 0.
\frac{a_0}{2} = 3,\quad a_2 = 2f(x) is already a cosine series.
k\lambda_2 = 4 \cdot 4 = 16
Decay rate of the n = 2 term; the constant does not decay.
u(x,t) = 3 + 2e^{-16t}\cos 2xAssemble the series.
Answer: u(x, t) = 3 + 2e^(−16t) cos 2x. As t → ∞, u → 3, the average starting temperature. No heat leaves through insulated ends, so the average stays the same.
Example 4: Ends held at different temperatures
A rod of length 10 with k = 1 has u(0, t) = 20 and u(10, t) = 50. It starts at u(x, 0) = 20 + 3x + 10 sin(πx/10). Find u(x, t).
u_E(x) = 20 + \frac{50 - 20}{10}x = 20 + 3xSteady state: the straight line through (0, 20) and (10, 50).
v(x,t) = u(x,t) - u_E(x)
v satisfies vₜ = vₓₓ with v = 0 at both ends.
v(x,0) = 10\sin\frac{\pi x}{10}Subtract u_E from the starting temperature.
v(x,t) = 10e^{-\pi^2t/100}\sin\frac{\pi x}{10}One sine term with kλ₁ = (π/10)² = π²/100.
u(x,t) = 20 + 3x + 10e^{-\pi^2t/100}\sin\frac{\pi x}{10}Add the steady state back.
Answer: u(x, t) = 20 + 3x + 10e^(−π²t/100) sin(πx/10). The hump decays, and the rod settles to the straight-line temperature 20 + 3x.
Example 5: Cooling an aluminum rod (word problem)
An aluminum rod 20 cm long starts at 100 °C. At t = 0 both ends are held at 0 °C. Take k = 0.9 cm²/s. Use the first term of the series to estimate the temperature at the center after 60 seconds.
u(x,t) \approx \frac{400}{\pi}e^{-k(\pi/20)^2t}\sin\frac{\pi x}{20}First term: b₁ = 400/π as in Example 2, with L = 20.
k\left(\frac{\pi}{20}\right)^2 = 0.9\cdot\frac{\pi^2}{400} \approx 0.022207Decay rate in 1/s.
0.022207 \cdot 60 \approx 1.3324
Multiply by t = 60.
e^{-1.3324} \approx 0.26384Evaluate the exponential.
u(10,60) \approx 127.324 \cdot 0.26384 \cdot \sin\frac{\pi}{2} \approx 33.6400/π ≈ 127.324 and sin(π/2) = 1.
Answer: the center is about 33.6 °C after 60 s. The next term, with n = 3, is smaller than 0.001 °C by then, so one term is plenty. The graph shows the whole temperature profile at four times.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Forgetting k in the exponent | Writing 5e^(−9t) sin 3x in Example 1 | The decay rate is kλₙ = 2 · 9 = 18. |
| Using n instead of (nπ/L)² | Writing e^(−ktπ/20) in Example 5 | Square the whole factor: k(nπ/L)². |
| Using the sine series for insulated ends | Dropping the constant 3 in Example 3 | Insulated ends need the cosine series, which keeps a₀/2. |
| Solving nonzero end temperatures directly | Using a sine series for u in Example 4 | Subtract the steady-state line first; only v has zero ends. |
| Choosing the wrong sign for the separation constant | Writing X″/X = +λ with λ > 0 | That gives growing exponentials and only X = 0. Use −λ, as in boundary value problems. |
| Expecting heat to build up over time | Saying the center of the rod in Example 5 warms up | Every term decays; the temperature moves toward the steady state. |
Related ideas
Diffusion
The same equation, often called the diffusion equation, describes a dye spreading in still water or a chemical moving through a membrane. Only the meaning of u and k changes.
Other partial differential equations
The wave equation uₜₜ = c²uₓₓ is solved by the same separation steps, but its time factors are sines and cosines instead of decaying exponentials. That is the next lesson, Wave Equation. The steady state of the heat equation in two dimensions satisfies Laplace’s Equation.
Practice problems
- Solve uₜ = uₓₓ for 0 < x < π with zero ends and u(x, 0) = 7 sin 2x.
- Solve uₜ = 5uₓₓ for 0 < x < 1 with zero ends and u(x, 0) = sin πx + 3 sin 4πx.
- Solve uₜ = 2uₓₓ for 0 < x < π with insulated ends and u(x, 0) = 4 − cos x.
- What temperature does the rod in Problem 3 approach as t → ∞?
- Find the steady-state temperature of a rod 0 < x < 5 with u(0, t) = 10 and u(5, t) = 30.
- Show that u = e^(−9t) sin 3x solves uₜ = uₓₓ.
- In Example 2, how many times as fast as the first term does the n = 5 term decay?
- Solve uₜ = uₓₓ for 0 < x < π with zero ends and u(x, 0) = x(π − x).
- Use the first term of Problem 8 to estimate u(π/2, 1).
- For the rod in Example 5, use the first term to find when the center reaches 10 °C.
Show answers
1.
\lambda_2 = 4,\quad k\lambda_2 = 4
Only n = 2 appears; k = 1.
Answer: u(x, t) = 7e^(−4t) sin 2x
2.
\lambda_1 = \pi^2,\quad \lambda_4 = (4\pi)^2 = 16\pi^2
L = 1, so λₙ = (nπ)².
k\lambda_1 = 5\pi^2,\quad k\lambda_4 = 80\pi^2
Multiply by k = 5.
Answer: u(x, t) = e^(−5π²t) sin πx + 3e^(−80π²t) sin 4πx
3.
\frac{a_0}{2} = 4,\quad a_1 = -1,\quad k\lambda_1 = 2Cosine series with L = π; λ₁ = 1.
Answer: u(x, t) = 4 − e^(−2t) cos x
4.
\lim_{t\to\infty}\left(4 - e^{-2t}\cos x\right) = 4The exponential goes to 0.
Answer: 4°, the average starting temperature
5.
u_E(x) = 10 + \frac{30 - 10}{5}x = 10 + 4xStraight line through (0, 10) and (5, 30).
Answer: u_E(x) = 10 + 4x
6.
u_t = -9e^{-9t}\sin 3xDifferentiate in t.
u_{xx} = e^{-9t}(-9\sin 3x) = -9e^{-9t}\sin 3xDifferentiate twice in x.
Answer: uₜ = uₓₓ, so the function is a solution
7.
\frac{k\lambda_5}{k\lambda_1} = \frac{25}{1} = 25Compare the decay rates n².
Answer: 25 times as fast
8.
b_n = \frac{8}{\pi n^3} \text{ (n odd)},\quad b_n = 0 \text{ (n even)}Sine series of x(π − x), from the Fourier sine and cosine series lesson.
Answer: u(x, t) = (8/π)(e^(−t) sin x + e^(−9t) sin 3x/27 + e^(−25t) sin 5x/125 + ⋯)
9.
u\left(\frac{\pi}{2}, 1\right) \approx \frac{8}{\pi}e^{-1}\sin\frac{\pi}{2}First term with t = 1.
\approx 2.5465 \cdot 0.36788 \approx 0.9368
8/π ≈ 2.5465 and e^(−1) ≈ 0.36788.
Answer: about 0.937; the next term is smaller than 0.00002
10.
127.324\,e^{-0.022207t} = 10Set the first term at x = 10 equal to 10.
e^{-0.022207t} = \frac{10}{127.324}Divide both sides by 127.324.
-0.022207t = \ln\frac{10}{127.324} \approx -2.5441Take the natural logarithm of both sides.
t \approx \frac{2.5441}{0.022207} \approx 114.6Divide both sides by −0.022207.
Answer: about 115 seconds
Heat equation FAQ
What is the heat equation?
It is the partial differential equation uₜ = kuₓₓ, which says the temperature at a point changes at a rate proportional to how curved the temperature graph is there. It models heat flow in a rod and other kinds of diffusion.
How do you solve the heat equation?
Separate variables with u = X(x)T(t), solve the eigenvalue problem for X from the boundary conditions, solve T′ = −kλT, and add the solutions. Then match the starting temperature with a Fourier sine or cosine series.
What is the steady-state solution of the heat equation?
It is the temperature the rod settles to as t → ∞. It solves uₓₓ = 0, so for fixed end temperatures it is a straight line, and for insulated ends it is the average starting temperature.
What does k mean in the heat equation?
k is the thermal diffusivity of the material. A larger k, as in copper or aluminum, makes the temperature even out faster.
Summary
- The heat equation uₜ = kuₓₓ models temperature in a rod.
- Separation of variables turns it into an eigenvalue problem in x and a decay equation in t.
- With zero ends, u = Σ bₙe^(−k(nπ/L)²t) sin(nπx/L), where bₙ is the sine series of the starting temperature.
- Insulated ends use the cosine series; fixed nonzero ends need the steady-state line first.
- Higher terms decay like e^(−kn²π²t/L²), so one term is often enough after a short time.
Previous lesson: Fourier Sine and Cosine Series
Next lesson: Wave Equation
Back to the Differential Equations Index