## 3.4 Predator-prey model

The dynamical system is given by the following set of first-order differential equations, one represents changes in a population of predators, (e.g., Foxes: $$f_F(R_t,F_t)$$ ), the other represents changes in a population of prey, (e.g., Rabbits: $$f_R(R_t,F_t)$$ ).

\begin{align} \frac{dR}{dt}&=(a-b*F)*R \\ \\ \frac{dF}{dt}&=(c*R-d)*F \tag{3.2} \end{align}

This is not a difference equation but a differential equation, which means building this system is not as straightforward as was the case in the previous assignments. Simulation requires a numerical method to ‘solve’ this differential equation for time, which means we need a method to approach, or estimate continuous time in discrete time. Below you will receive a speed course in one of the simplest numerical procedures for integrating differential equations, the Euler method.

### 3.4.1 Euler Method

A general differential equation is given by:

$$$\frac{dx}{dt} = f(x) \tag{3.3}$$$

Read it as saying: “a change in $$x$$ over a change in time is a function of $$x$$ itself”. This can be approximated by considering the change to be over some constant, small time step $$\Delta$$:

$$$\frac{(x_{t+1} = x_t)}{\Delta} = f(x_t) \tag{3.4}$$$

After rearranging the terms a more familiar form reveals itself:

\begin{align} x_{t+1} &= x_t &= f(x_t) * \Delta \\ x_{t+1} &= f(x_t) * \Delta + x_t \tag{3.5} \end{align}

This looks like an ordinary iterative process, $$\Delta$$ the time constant determines the size of time step taken at every successive iteration. For a 2D system with variables R and F on would write:

\begin{align} R_{t+1} &= f_R(R_t,Ft) * \Delta + R_t \\ F_{t+1} &= f_F(R_t,F_t) * \Delta + F_t \tag{3.6} \end{align}

### 3.4.2 Coupled System in a spreadsheet

Implement the model in a spreadsheet by substituting $$f_R(R_t,Ft)$$ and $$f_F(R_t,F_t)$$ by the differential equations for Foxes and Rabbits given above.

• Start with $$a = d = 1$$ and $$b = c = 2$$ and the initial conditions $$R_0 = 0.1$$ and $$F_0 = 0.1$$. Use a time constant of $$0.01$$ and make at least $$1000$$ iterations.
• Visualize the dynamics of the system by plotting:
• $$F$$ against $$R$$ (i.e., the state space)
• $$R$$ and $$F$$ against time (i.e., the timeseries) in one plot.
• Starting from the initial predator and prey population represented by the point $$(R, F) = (0.1, 0.1)$$, how do the populations evolve over time?
• Try to get a grip on the role of the time constant by increasing and decreasing it slightly (e.g. $$\Delta = 0.015$$) for fixed parameter values. (You might have to add some more iterations to complete the plot). What happens to the plot?
• Hint: Remember that $$\Delta$$ is not a fundamental part of the dynamics, but that it is only introduced by the numerical integration (i.e., the approximation) of the differential equation. It should not change the dynamics of the system, but it has an effect nonetheless.