Euler's method numerically approximates solutions of first-order ordinary differential equations (ODEs) with a given initial value. It is an explicit method for solving initial value problems (IVPs), as described in <ahref="https://en.wikipedia.org/wiki/Euler method"title="wp: Euler method"target="_blank">the wikipedia page</a>.
<li><big>$y(t+h) \approx y(t) + h \, \frac{dy(t)}{dt}$</big></li>
</ul>
which is the same as
<ulstyle="list-style: none;">
<li><big>$y(t+h) \approx y(t) + h \, f(t,y(t))$</big></li>
</ul>
The iterative solution rule is then:
<ulstyle="list-style: none;">
<li><big>$y_{n+1} = y_n + h \, f(t_n, y_n)$</big></li>
</ul>
where <big>$h$</big> is the step size, the most relevant parameter for accuracy of the solution. A smaller step size increases accuracy but also the computation cost, so it has always has to be hand-picked according to the problem at hand.
Newton's cooling law describes how an object of initial temperature <big>$T(t_0) = T_0$</big> cools down in an environment of temperature <big>$T_R$</big>:
It says that the cooling rate <big>$\frac{dT(t)}{dt}$</big> of the object is proportional to the current temperature difference <big>$\Delta T = (T(t) - T_R)$</big> to the surrounding environment.
The analytical solution, which we will compare to the numerical approximation, is