Escolar Documentos
Profissional Documentos
Cultura Documentos
– A Case Study
Lotka-Volterra Equations- [BASED ON WIKIPEDIA]
The Lotka-Volterra equations, also known as the predator-prey equations, are a pair
of first order, non-linear, differential equations frequently used to describe the
dynamics of biological systems in which two species interact, one a predator and one
its prey. They were proposed independently by Alfred J. Lotka in 1925 and Vito
Volterra in 1926.
where
Prey
The prey are assumed to have an unlimited food supply, and to reproduce
exponentially unless subject to predation; this exponential growth is represented in
equation above by the term αx. The rate of predation upon the prey is assumed to be
proportional to the rate at which the predators and the prey meet; this is represented
above by βxy. If either x or y is zero then there can be no predation.
With these two terms the equation above can be interpreted as: the change in the
prey's numbers is given by its own growth minus the rate at which it is preyed upon.
Predators
Hence the equation represents the change in the predator population as the growth of
the predator population, minus natural death.
An example problem
Suppose there are two species of animals, a baboon (prey) and a cheetah (predator). If
the initial conditions are 80 baboons and 40 cheetahs, one can plot the progression of
the two species over time. Time is dimensionless.
One can also plot a solution which corresponds to the oscillatory nature of the
population of the two species. At any given time, the solution is somewhere on the
inside of these elliptical solutions.
In the model system, the predators thrive when there are plentiful prey but, ultimately,
outstrip their food supply and decline. As the predator population is low the prey
population will increase again. These dynamics continue in a cycle of growth and
decline.
Consider the pair of first order ordinary differential equations known as the Lotka-
Volterra predator-prey model.
y1' = (1 - alpha*y2)*y1
The functions y1 and y2 measure the sizes of the prey and predator populations
respectively. The quadratic cross term accounts for the interactions between the
species. Note that the prey population increases when there are no predators, but the
predator population decreases when there are no prey.
To simulate a system, create a function M-file that returns a column vector of state
derivatives, given state and time values. For this example, Matlab has already a demo
file called LOTKA.M. [note that this also defines the alpha and beta parameters]
type lotka
function yp = lotka(t,y)
yp = diag([1 - .01*y(2), -1 + .02*y(1)])*y;
Now simulate LOTKA using ODE45 (could also be using ODE23 for less precision
but more speed). ODE45 takes longer at each step, but also takes larger steps.
Nevertheless, the output of ODE45 is smooth because by default the solver uses a
continuous extension formula to produce output at 4 equally spaced time points in the
span of each step taken. The plot compares this result against the previous.
t0 = 0; % this is the start time of the experiment
tfinal = 85; % this is the end time of the experiment
y0 = [10 10]'; % these are the initial numbers of predator and prey
figure;
% Plot the result of the simulation two different ways.
subplot(1,2,1)
plot(t,y)
title('Time history')
subplot(1,2,2)
plot(y(:,1),y(:,2))
title('Phase plane plot')
[TOUT,YOUT] = ODE45(ODEFUN,TSPAN,Y0)
with TSPAN = [T0 TFINAL] integrates
the system of differential equations y' = f(t,y) from time T0 to TFINAL
with initial conditions Y0.
For a scalar T
and a vector Y, ODEFUN(T,Y) must return a column vector corresponding
to f(t,y). Each row in the solution array YOUT corresponds to a time
returned in the column vector TOUT. To obtain solutions at specific
times T0,T1,...,TFINAL (all increasing or all decreasing), use TSPAN =
[T0 T1 ... TFINAL].
ODE45 can solve problems M(t,y)*y' = f(t,y) with mass matrix M that is
nonsingular. Use ODESET to set the 'Mass' property to a function handle
MASS if MASS(T,Y) returns the value of the mass matrix. If the mass matrix
is constant, the matrix can be used as the value of the 'Mass' option. If
the mass matrix does not depend on the state variable Y and the function
MASS is to be called with one input argument T, set 'MStateDependence' to
'none'. ODE15S and ODE23T can solve problems with singular mass matrices.
Example
[t,y]=ode45(@vdp1,[0 20],[2 0]);
plot(t,y(:,1));
solves the system y' = vdp1(t,y), using the default relative error
tolerance 1e-3 and the default absolute tolerance of 1e-6 for each
component, and plots the first component of the solution.