% This program uses Euler's method to solve the D.E.'s
%    du/dt =  0.5 u - 0.2 uv
%    dv/dt = -0.7 v + 0.3 uv
% where u(0)=2 and v(0)=3
clear;

h = 0.02;
tstart = 0;
tend = 20;

U(1) = 2;
V(1) = 3;

k = 1;

for t = tstart:h:tend-h
   Uprime = 0.5*U(k) - 0.2*U(k)*V(k);
   Vprime = -0.7*V(k) + 0.3*U(k)*V(k);

   U(k+1) = U(k) + h*Uprime;
   V(k+1) = V(k) + h*Vprime;

   k = k+1;
end

t = tstart:h:tend;

plot(t,U,t,V,'--');
