First-order equations: The Euler method


Required math: Differential calculus.

The laws of nature are often written down in terms of differential equations. A differential equation in a dependent variable $x(t)$ is any equation containing $x(t)$ and its derivatives $\frac{dx}{dt}, \frac{d^2x}{dt^2}, \ldots$. For example, if $P = P(t)$ denoted the population of rabbits on a university campus as a function of time then the population can be modelled by the differential equation $$ \frac{dP}{dt} = \left( 1 - \frac{P}{K} \right) rP $$ where $K$ is the "carrying capacity" or the maximum number of rabbits allowed the campus can sustain according to the model and $r$ is the growth rate of the rabbits.

Most differential equations you encounter cannot be solved analytically (this one can though!) and so we turn to computers. The first step is to approximate the derivative $$ \frac{\Delta P}{\Delta t} = \left( 1 - \frac{P(t - \Delta t}{K} \right) rP(t - \Delta t) $$

Submit Your Code