School/□ Systems Engineer/Week 9
Fitting a cooling model to data
You have a column of temperatures from a cooling mug and one unknown number, k. How do you pull k out of noisy data, and how sure can you be?
About 45 min · 3 goals · Checked by automated tests
1.Why should I care?
A model is not finished until its parameter comes from data. Fitting k turns a textbook equation into a prediction for your mug, your sensor or your circuit, and the linearising trick here is used across engineering whenever a model is exponential.
- ◇ Linearise Newton's law of cooling with ln(T − Tₐ) and fit k as a slope.
- ◇ Estimate k from two readings and from a least-squares fit, and compare.
- ◇ Explain how a wrong ambient temperature or noise near Tₐ distorts the fit.
Safety: Use warm tap water, not boiling water, and keep the cup on a stable table. A thermometer is all you need; never put electronics in liquid.
2.Predict
You plot ln(T − Tₐ) against time for cooling data. What should you see if Newton's law holds?
Guess first. Being wrong here is how the surprise works.
3.Understand
Linearise, then fit a line
Subtract the room temperature, take natural logs, plot against t. The slope of the best straight line is −k, the intercept ln(T₀ − Tₐ). A least-squares line through all points uses every reading, so it is far less sensitive to one bad reading than a two-point estimate.
Two-point estimate
From readings at t₁ and t₂: k = ln[(T₁ − Tₐ)/(T₂ − Tₐ)]/(t₂ − t₁). Quick and useful as a sanity check, but it rests entirely on two noisy numbers. Example: 86 °C at 0 min and 63.7 °C at 10 min in a 21 °C room give k = ln(65/42.7)/10 ≈ 0.042 per minute.
What distorts the fit
Noise near Tₐ: when T − Tₐ is small, a 0.5 °C error is a large fraction, so late points scatter wildly in the log view. Weight them less or stop the fit early. Wrong Tₐ: guessing the room 2 °C too low makes the log plot curve. Early evaporation from a hot drink cools it faster at first than the model allows.
Explain it another way
Fitting is turning a dial (k) until the model's curve lies as close as possible to all the dots at once. Taking logs turns the curve into a straight line, so the dial becomes a ruler's slope.
Least squares on yᵢ = ln(Tᵢ − Tₐ) against tᵢ: k̂ = −Σ(tᵢ − t̄)(yᵢ − ȳ)/Σ(tᵢ − t̄)². This minimises errors in log space, which overweights late, low readings compared with a direct nonlinear fit.
If each Tᵢ has error ε, the log has error ≈ ε/(Tᵢ − Tₐ): small near the start, large near the end. A weighted fit uses weights (Tᵢ − Tₐ)² to undo this.
Thermal engineers characterise a component's time constant exactly this way: heat it, log the cooling, fit k. That number then sets how long a sensor or a motor can be pushed before it overheats.
Worked example 1
Readings: 86 °C at t = 0, 63.7 °C at t = 10 min, room 21 °C. Estimate k and τ.
k = ln(65/42.7)/10 = ln(1.522)/10 = 0.420/10 = 0.042 per minute. τ = 1/k ≈ 23.8 min; half-life ≈ 16.5 min.
Common mix-ups
- The two-point estimate is as good as a fit through all the data.
✓ It rests on two noisy numbers. A least-squares fit uses every reading. - A good fit proves the model is right.
✓ It shows the model can describe this data. Testing on data not used for fitting (next lesson) is the real check.
4.Discover
Choose the mug of tea. Adjust k by eye until the curve runs through the points, and note your RMS error. Switch on the log view: are the points straight? Press Best fit and compare its k with yours. Which points scatter most in the log view, and why?
Loading the interactive…
Can't use the interactive? Read a description instead
The decay-fit lab shows synthetic cooling data: 16 readings from 86 °C towards a 21 °C room over 60 minutes. A model curve with the chosen k is drawn through them. In log view, ln(T − 21) against time is close to a straight line with slope −k; late points scatter more. The least-squares fit gives k close to 0.042 per minute.
5.Checkpoint: guided practice
Check what you just discovered before going on. Hints appear after a wrong answer.
Practice 1
A mug reads 86 °C at t = 0 and 63.7 °C at t = 10 min in a 21 °C room. Estimate k in per minute (3 decimal places).
6.Practice on your own
Practice, not a test. Wrong answers get a hint and another try.
Practice 2
With k = 0.042 per minute, what is the time constant τ, in minutes?
Practice 3
You assumed Tₐ = 18 °C but the room was really 22 °C. What will the ln(T − Tₐ) plot show?
Practice 4 · a fresh version every time
A mug of tea at 85 °C cools in a 20 °C room as T(t) = Tₐ + (T₀ − Tₐ)·e^(−kt) with k = 0.08 per minute. What is its temperature after 30 minutes, in °C?
Practice 5 · a fresh version every time
A quantity decays as e^(−t/τ) with τ = 5 s. How long until it falls to 5% of its start value, in seconds?
7.Apply it
If you can do so safely, log a cup of warm (not boiling) tap water cooling for 30 minutes with a kitchen thermometer, every 2 minutes, and note the room temperature. Fit k by both methods. If you cannot, use the lab's synthetic set and say so in your write-up.
8.Reflect
Concepts: First-order differential equations · Fitting lines with least squares