Lite / Engineering Complex Systems / 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?
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.
Predict
You plot ln(T − Tₐ) against time for cooling data. What should you see if Newton's law holds?
- A curve that flattens out
- A straight line with negative slope −k
- A horizontal line
Guess first, then reveal
T − Tₐ = (T₀ − Tₐ)e^(−kt), so ln(T − Tₐ) = ln(T₀ − Tₐ) − kt: a straight line with slope −k. Curvature in that plot is evidence against the model or against your value of Tₐ.
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?
What the interactive shows (text version)
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.
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
Intuitive
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.
Technical
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.
Mathematical
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.
Applied
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.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
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.
Reflect
Why do the latest readings scatter most in the log view, and what would you do about it?
Write your answer on paper or in your own notes. Lite never stores what you write.