The ODEs of the Lotka-Volterra model, \(\dot{\vec x} = f(\vec x)\), are given by: \[ \begin{align} \dot{x}(t) & = a \cdot x(t) - b \cdot x(t) \cdot y(t), \\ \dot{y}(t) & = c \cdot x(t) \cdot y(t) - d \cdot y(t). \end{align} \] where \(\mathbb{R} \ni t \mapsto x(t) \in \mathbb{R}\) and \(\mathbb{R} \ni t \mapsto y(t) \in \mathbb{R}\), and all parameters \((a, b, c, d) \in \mathbb{R}_{+}^4\) are positive.
Write a function euler_LV <- function(ini, pars, dt, tmax)
integrating the LV system via the Euler method for a set of initial values ini
, parameters pars
, stepsize dt
for \(t\in[0,{\tt tmax}]\). The function should return a data.frame
with columns time, x, y
. Reminder: \(\vec x_{n+1} = \vec x_n + f(\vec x_n)\cdot dt\).
ggplot2()
in configuration and phase space for \(a = 2/3\), \(b = 4/30\), \(c = 1/10\), \(d = 1\) and a set of initial values \((x(t=0), y(t=0)) = \{ (10,15), (15,10)\}\). To do so, first arrange the output of euler_LV
in a config or phase space data.frame
with columns:
time, value, species, ini
, where species
is a character
variable labelling the states x
and y
.x, y, ini
, where ini
is a character
or factor
variable to label the initial value.Add a noise term to the euler integration: \(x_{n+1} = x_n + f(x_n)\cdot dt + \epsilon \cdot \sqrt{dt}\) with \(\epsilon\sim \mathcal{N}(0, {\tt sd)}\). Use sd = c(sdx, sdy)
as additional argument of your euler function and avoid \(x_n < 0\). Compare the solutions obtained with sd = c(.3, .3)
to the standard solutions without noise by plotting.
The LV system can be extended to: \[ \begin{align} \dot{x}(t) & = a \cdot x(t) \cdot \left(1 - \frac{x(t)}{K} \right) - b \cdot \frac{x(t)}{x(t) + S} \cdot y(t), \\ \label{eq:ELV2} \dot{y}(t) & = c \cdot \frac{x(t)}{x(t) + S} \cdot y(t) - d \cdot y(t), \end{align} \] where also \(K\) and \(S\) are positive parameters.
Repeat Exercise 1 for the extended equations using \(a = b = c = 1\); \(d= \tfrac{1}{3}\); \(K = 30\), \(S=10\) and \((x(0),y(0)) = \{(1,1), (10,10)\}\).
The choir of the cathedral is slightly inclined relative to the main nave. Why?