Murder Mystery: A Differential Equation Application
Suppose you are forensic expert trying to figure out a murder mystery. You found a dead body around 4.30 AM maintained at 33 degrees Celsius, after investigating the surroundings you measured the body temperature again at 6.00 AM which was found to be 31 degrees. What time did this murder happen? (Assume the average body temperature is 37 degrees temperature and the ambient temperature is 28 degrees)
Let's start with intuition, we know a hot cup of coffee kept in a cold environment will begin to cool down immediately at a higher rate than a coffee with a moderate temperature in the same environment. This suggests that the rate at which the body starts to cool down is directly proportional to the temperature difference between the body and its surroundings. Sir Isaac Newton studied this phenomenon thoroughly and formulated the laws governing it, better known as Newton's Law of Cooling.
Mathematically, it states that the rate of heat loss of a body is directly proportional to the difference in the temperatures between the body and its environment or,
$$\frac{d \,T(t)}{dt} = -k \,(T(t) - T_{a})$$
where, $T(t)$ is the temperature of the body after $t$ units of time
$T_{a}$ is the ambient (room) temperature
$k$ cooling constant (depends on factors such as area exposed, conductivity of body)
They key realization is that temperature is a function of time which decreases and saturates to the ambient temperature, respecting the cooling law.
Solving the differential equation
$$ \frac{dT}{dt} = -k \,(T(t) - T_{a}) $$
$$ \frac{dT}{T - T_a} = -k \, dt $$
Let's integrate both sides:
$$ \int \frac{dT}{T - T_a} = \int -k \, dt $$
$$ \ln |T - T_a| = -kt + C $$
Exponentiating both sides, $$ e^{\ln |T - T_a|} = e^{-kt + C} $$
$$ |T - T_a| = e^{C}e^{-kt} $$
Since our body is cooling down, the temperature of our body is always greater than the ambient temperature, which means we can remove the absolute value symbol
$$T(t) = T_{a} + Ae^{-kt}$$
Let's solve the IVP, we have $T(0) = T_{0}$, we get
$$A = T_a - T_0$$
$$ \boxed{T(t) = T_{a} + (T_0 - T_{a}) e^{-kt}} $$
Intuition: Let's try to visualize this function. Initially, it's $T(t)$ is way bigger than $T_a$ since $(T_0 - T_a)e^{-kt}$ is always positive and very large for smaller values of $t$. As $t$ increases the value gradually decreases and gets closer and closer to $T_a$ but never equals. This perfectly fits our real world situation.
Now, Let's apply all these theory into our muder mystery problem for find the time the murder took place
Soon after the person is deceased his body starts to cool down from an initial temperature $T_0 = 37°C$ (average human body temperature), gradually trying to attain the ambient temperature, $T_a = 28°C$, thus mathematically the heat transfer of body can be given as,
$$ T(t) = 28 + (37 - 28) e^{-kt} = 28 + 9e^{-kt}$$
We need to find the hours elapsed $\tau$ that took for the body to reach 33 degrees Celsius (the temperature when we saw the body) from the initial body temperature of 37 degrees Celsius. Or simply how many hours elapsed after the murder and our first observation
$$ T(\tau) = 28 + 9e^{k \tau} = 33 \tag{1} $$
We have also taken another observation after 1.5 hours after the first observation :
$$ T(\tau + 1.5) = 28 + 9e^{k (\tau + 1.5)} = 31 \tag{2} $$
(2) can be written as $e^{k \tau} = \frac{1}{3 e^{1.5k}}$, subtituting in (1) gives $28 + 9\frac{1}{3 e^{1.5k}} = 33$ solving this gives $$e^{1.5k} = \frac{3}{5}$$
taking logarithm gives $k = \frac{\ln\left(\frac{3}{5}\right)}{1.5}$
log(3/5)/(1.5)
-0.3405504158439938
$$ T(t) = 28 + (37 - 28) e^{-0.34t}$$
Now let's get to the punch line, solving for $\tau$
we have $$28 + 9e^{-0.34\tau} = 33$$ $$e^{-0.34 \tau} = \frac{5}{9}$$
Taking logarithm, we get $$\tau = -\frac{\ln(\frac{5}{9})}{0.34}$$
-(log(5/9) / (0.34))
1.7287843085356438
Thus $$\tau = 1.73 \text{ hours}$$
This means the murder took place 1.73 hours before we saw it or 1 hour and around 44 minutes ago. Thus the murder happened at 2:46 PM. Rest In Peace
Let's pack our bags up, murderer shouldn't be far.
Plotting in Julia
using Plots
f(x) = 28 + (37 - 28)*exp((-0.34*x))
g(x) = 28 # Surrounding Temperature
g (generic function with 1 method)
plot(f, title="Cooling of a body", color = "red")
plot!(g, color = "blue")