Learning Objectives
After working through this section you should be able to:
- Derive Newton's law of cooling from a one-sentence physical observation, ending in the differential equation .
- Solve that ODE by separation of variables and recognize the answer as exponential relaxation toward the room.
- Read off the meaning of each symbol — initial temperature, ambient temperature, cooling constant, half-life of the gap — and predict the temperature at any future time.
- Apply the law to two classic problems: the cooling-coffee puzzle (when to add cream) and the forensic estimation of time of death.
- Simulate the ODE with forward Euler in plain Python and recover the unknown from noisy measurements with PyTorch autograd.
Why Hot Things Cool Down
Imagine you place a cup of fresh coffee on the counter. After a minute it is a little cooler. After ten minutes it is much cooler. After an hour it is room temperature, and nothing more happens. The story of how a temperature decays is one of the very first systems ever modeled by a differential equation, and the story is the same for every object on Earth — a forgotten cup of tea, a forging cooling in air, a body on the floor of a crime scene.
The piece of physics behind all of these is so simple it almost feels like cheating. Heat moves from hot to cold, and the rate at which it moves is proportional to the temperature difference between the object and its surroundings. A cup at 95°C in a 20°C room is 75 degrees out of equilibrium and loses heat fast. Once it reaches 30°C, it is only 10 degrees out, and now it loses heat slowly. Cooling decelerates because it eats away its own driving force.
Newton's observation (1701)
The rate at which an object cools is proportional to the gap between its temperature and the surrounding temperature:
That single sentence — written four hundred years before central heating was a thing — is enough to build the whole solution. We just need to turn the words into calculus.
Where Newton Got the Idea
Newton was investigating the temperature of red-hot iron as it cooled in air. He recorded paired numbers — time on a clock and temperature on a scale — and noticed something striking: in equal stretches of time, the temperature did not drop by equal amounts. Instead, the fraction of the remaining excess heat that was lost in each minute was roughly constant. Hot iron lost a lot in the first minute and a little in the tenth, but it always lost about the same percentage of how-far-from-cold it was.
Anything whose loss rate is proportional to its current size obeys an exponential decay law. So Newton was discovering, before exponentials had a name, that the temperature gap decays exponentially. Once you see this in the data, the differential equation almost writes itself.
Building the Differential Equation
Let be the temperature of the body at time , and the (assumed constant) room temperature. Newton's observation says
where is a constant of proportionality whose units are 1/time (so the right side has units of temperature per time, just like the left). The minus sign encodes the physics: if , the parenthesis is positive, and we want ; if , the parenthesis is negative, and . In both cases T moves toward .
Solving It by Separation of Variables
The trick is to move all the 's to one side of the equation and all the 's to the other. Dividing through by and multiplying by :
Integrate both sides:
Exponentiating both sides — and absorbing the sign and the constant into a single arbitrary constant — gives
The constant is pinned down by the initial condition : plug in and you get . Substituting back:
That is the closed-form solution. Three lines of separable-equation algebra turn one physical sentence into a formula valid at every instant in time.
Anatomy of the Solution
Every piece of means something physical. The formula is small, so let us name everything in it.
| Symbol | Name | What it sets | Units |
|---|---|---|---|
| T_env | Ambient temperature | The horizontal asymptote — the curve approaches it but never crosses | °C (temperature) |
| T_0 | Initial temperature | Where the curve starts at t = 0 | °C (temperature) |
| T_0 − T_env | Initial gap | Vertical distance from the asymptote at t = 0 — the amplitude of the decay | °C |
| k | Cooling constant | How fast the gap shrinks. Big k = fast cooling. Small k = slow | 1 / time |
| 1/k | Time constant τ | Time for the gap to shrink to 1/e ≈ 36.8% of its starting value | time |
| ln(2)/k | Half-life of the gap | Time for the gap to shrink to half its starting value | time |
Two limits worth memorizing. As , . As , so . The exponential glues the two endpoints together with the right curvature.
Interactive: Direction Field & Solution Family
The clearest way to see the law is to look at its slope field. At every point in the plane there is a unique slope , and the solution curves are the lines that always follow those slopes. Drag the sliders. Click on the left edge of the plot to seed new initial temperatures and watch them flow into the dashed equilibrium line.
Worked Example: Coffee on the Counter
Let's pin all this down with one concrete problem. Try it by hand first; expand the panel to compare.
Problem. A cup of coffee at is left in a room at . After 5 minutes the temperature is 78.41°C.
- (a) Find the cooling constant .
- (b) Predict the temperature at min.
- (c) When is the coffee at 60°C (drinkable)?
Show the full hand-worked solution
Interactive: The Coffee + Cream Puzzle
Suppose you want to drink your coffee as warm as possible after 10 minutes, and you have a splash of refrigerated cream that will lower the temperature instantly when added. Should you add the cream immediately, or wait until you are about to drink?
Most people guess “wait” — they reason that pouring cold cream into hot coffee will cool it down a lot, so why do it early? Newton's law gives a counterintuitive answer. The cooling rate is proportional to the gap , so a cooler cup loses heat more slowly. By dropping the temperature now you also slow down every subsequent loss. Play with the simulator and watch the two strategies fight it out.
Forensic Application: Time of Death
Newton's law of cooling is so dependable that it is used in forensic medicine. A body at starts cooling toward room temperature the moment the heart stops. Given two temperature readings, taken at known times after discovery, both and the time of death can be solved.
Let be the time since the first reading. Then . A second reading at gives
so we can solve for k:
With in hand, run the curve backwards until — that is the time of death:
Python: Numerical vs Closed-Form Solution
We have a beautiful closed form. Why ever solve cooling numerically? Two reasons. (1) Real-world problems almost never have closed forms — once drifts with time or depends on , separation breaks. A numerical solver just keeps working. (2) Watching forward Euler underestimate the truth by exactly the right amount is the best way to internalize what a derivative actually is.
t Euler Exact error 0 95.0000 95.0000 0.0000 1 91.2500 91.3422 -0.0922 2 87.6875 87.8628 -0.1753 3 84.3031 84.5531 -0.2500 4 81.0880 81.4048 -0.3168 5 78.0336 78.4101 -0.3765 6 75.1319 75.5512 -0.4193The error grows almost linearly with — that is the hallmark of a first-order method. Halving would roughly halve the error. To remove it entirely you would move to a method like RK4, which we cover in a later chapter.
PyTorch: Fitting k from Real Measurements
Now flip the problem on its head. Instead of knowing and predicting the curve, suppose you have a thermometer and a stopwatch and you measured 11 temperatures over 20 minutes. What was ? The closed-form answer comes from any two measurements — but that throws away nine data points and is fragile against noise. A better approach is to fit the whole cooling curve to all the data at once.
That is exactly what an autograd optimizer does. Define a model (the Newton-law curve, parameterized by ), define a loss (mean-squared error against the measurements), and ask PyTorch to walk downhill on that loss until it stops moving. The same machinery that powers GPT does this without breaking a sweat.
recovered k = 0.0493 per minute half-life of the temperature gap: 14.06 minThe true used to generate the data was 0.0500. We recovered it to within 1.5% from 11 noisy measurements.
Where Else Cooling Shows Up
Pharmacokinetics
Drug concentration in the bloodstream decays toward zero by the same ODE, with (no drug at steady state) and set by the kidneys and liver. The half-life of a medication is . Dosing schedules — every 4 hours, every 12 hours — are chosen so the concentration stays inside a therapeutic window.
RC Circuits
A capacitor discharging through a resistor obeys , exact mathematical twin of Newton's law with and . The time constant is the electrical analog of the thermal .
Radioactive Decay
Replace temperature with the number of unstable nuclei and you get . Half-life is the basis of carbon dating.
Chemical Reactions
A first-order reaction has concentration decaying as . Same skeleton, chemistry instead of physics.
Anywhere “rate ∝ gap from equilibrium” holds
Sales returning to a baseline after a promotion, a thermostat-fed room responding to weather, a population whose density approaches carrying capacity in the small-perturbation limit. The shape recurs because the assumption — proportional restoring rate — is the simplest nontrivial model of relaxation.
Common Pitfalls
- Sign error on k. The minus is part of the law, not part of . Write with . If you absorb the minus into you will fit a negative cooling rate and your coffee will catch fire.
- Forgetting the constant of integration. After separation you get . That is essential — it becomes the amplitude after exponentiating.
- Using only one data point to find k. One reading and an initial condition just barely gives you . Two readings make the answer overdetermined and robust to noise. Many data points + least squares is the gold standard.
- Assuming T_env is constant. If the room itself is heating or cooling, replace with . The ODE is now forced and non-autonomous; separation no longer works directly. You go back to the integrating-factor method of Section 21.1.
- Mixing time units. has units of 1/time. If you measure in minutes but quote the half-life in hours, you will be off by 60×.
Summary
| Concept | What to remember |
|---|---|
| Newton's law | dT/dt = -k (T − T_env). Rate of cooling ∝ gap from environment. |
| Solution | T(t) = T_env + (T_0 − T_env) e^(−kt). Exponential relaxation toward T_env. |
| Time constant | τ = 1/k. Half-life of the gap = ln(2)/k ≈ 0.693/k. |
| Geometry | T_env is the horizontal asymptote. Curves above descend; curves below ascend. None cross. |
| Finding k | Two readings → k = -(1/Δτ) ln[(T_2 − T_env)/(T_1 − T_env)]. |
| Forensic use | Solve k from two readings, run curve back to 37°C → time of death. |
| Numerical | Forward Euler: T ← T + dt · dT/dt. First-order accurate; error grows ∝ dt. |
| Parameter fitting | MSE loss + autograd + Adam recovers k from noisy measurements. |
Coming next: Section 21.6 generalizes “rate ∝ gap” to mixing problems — saltwater flowing in and out of a tank — where the conservation law is mass instead of energy but the differential equation is the same character in a new costume.