(^) in which the primes (′) denote that the best constants might be a little different from
the infinitesimal case. The Δ symbols imply changes over small, but finite, intervals.
A solution is a very large number of sequential calculations of N1 and N2, a process
greatly eased by use of a computer. The equations are programmed in some
convenient computer language, then run through very large numbers of cycles of ΔT.
We show a version called PROGRAM VOLTERRA as a Matlab script, a currently
popular programming language, in Box 4.1.
(^) With the program in hand, we need some preliminary values of the constants. We
start with some that give a steady-state or equilibrium result, that is, ΔN1 = ΔN2 = 0
always. Thus, (dropping the primes for simplicity):
(^) So, N1 = d/K2 and N2 = b/K1.
Box 4.1 Computer programs for the Lotka–
Volterra model
(^) Instructions to the computer embodied in a program like this are simple and can be learned most
quickly by working with an experienced programmer. The code here is a “Matlab” script, a popular
commercial system for programming personal and other computers. It provides a variety of tools for
mathematical manipulations, data handling and graphing. The “%” sign indicates a comment, an
explanation to human readers of the program that computers will ignore. Here the whole comment
statements are in bold.
(^) %PROGRAM lotka_volterra.m
%1. Set up vectors of zeros for 1000 time steps
N1=zeros(1,1000); N2=zeros(1,1000);
%2. Enter starting values N1=prey, N2=predators
N1(1)=1000; N2(1)=11; %Stable point; change to experiment.
%3. Parameters; these are values for the 1000:10 stable point
B1=0.1; K1=0.01; K2=0.0001; D2=0.1; %Change to experiment.
%4. Loop through 1000 time steps
Dt=1.0; % Time step is 1 time unit
for i=1:1000 % Approximate over 1000 time steps
DN1=B1N1(i)Dt - K1N1(i)N2(i)Dt;
DN2=K2N1(i)N2(i)Dt - D2N2(i)Dt;
N1(i+1)=N1(i)+DN1;
N2(i+1)=N2(i)+DN2;
end
%5. Graph the results as a function of time
subplot(3,2,1:2);
plotyy((0:i), N1,(0:i), N2);
xlabel('Time Steps′)
ylabel(′Left No. N1; right No. N2′)
% As a phase diagram
subplot(3,2,3:6);
plot(N1,N2); xlabel(′N1′); ylabel(′N2′);
(^) To run this, type the statements (comments – i.e., % statements – not needed) into the editor window
of a Matlab system. Use the semicolons; they stop the computer from listing every variable value in
the command window at every step. Click the run symbol (a green triangle over a white rectangle),
and the program will very quickly show a plot in a new window of the N2 vs. N1 phase diagram. For