According to Newton’s law of cooling, the temperature of abody changes at a rate pro-
portional to the difference between its temperature and thatof the surrounding medium (the ambient
temperature),
dT
dt = −k(T − Ta) with T(0) = T0
where T is the temperature of the body in oC, t is time inmin, k = 0.019 min−1
is the proportion-
ality constant, and Ta = 20 oC is the ambient temperature. Theanalytical solution for this ordinary
differential equation (ODE) is:
T(t) = Ta + (T0 − Ta)e
−kt
The Euler’s numerical method for solving the ODE assumes thatthe first derivative is approximated
using the finite difference equation:
dT
dt ≈
∆T
∆t
=
Ti+1 − Ti
∆t
Suppose that a cup of coffee originally has a temperature of70 oC. Solve the ODE
(a) Using Eulers method for the temperatures from t = 0 to 20min using a step size of 5 min.
(b) Plot the results obtained in parts (a) together with theanalytical solution given above