Math 308, Matlab assignment 2

advertisement
Math 308, Matlab assignment 2
due October 14 in class
plot(x,y) plots entries of the vector y versus entries of the vector x. plot(x1,y1,x2,y2)
plots two graphs on the same plot. They are automatically done in different colors. You can also
modify the style of each graph: try plot(x1,y1,’x:’,x2,y2,’--’) and use help plot
for more details. You can also add a new graph to the previous plot by using hold on / hold
off commands. Use legend(’first graph’,’second graph’) to label the graphs,
xlabel(’x’), ylabel(’y’), title(’Title’) to label the axes and the figure, and
grid on to add a grid if you want.
1. The file RPS.m models the evolution of interacting Rock-Paper-Scissors populations. With the
growth parameter a = 1.1 and initial conditions R(0) = 2, P (0) = 0.5, S(0) = 1, answer the
following question: which population is the largest at the time
(a) t = 1
(b) t = 5
(c) t = 10?
You can attach the plots if you like. The easiest way to do this problem is to imitate what is done in
the diary.
2. The predator-prey equations are also called the Lotka-Volterra equations. They were originally
introduced in the 1920’s by the Italian mathematician Umberto Volterra to explain why, during the
first World War, a larger percentage of catch of Italian fishermen consisted of sharks and other fish
eating fish than was true both before and after the war. His equations were a little different from
the ones we used in class, and contained an extra parameter E to account for fishing. If x1 (t) is the
number of prey, and x2 (t) is the number of predators, then
x01 (t) = Ax1 − Bx1 x2 − Ex1
x02 (t) = −Cx2 + Dx1 x2 − Ex2 .
(a) Re-write this system in exactly the form we used in class (which is the form of Equation
(7.4.1) in the textbook). What are your new 4 parameters?
(b) Fix A = 0.4, B = 0.01, C = 0.3, D = 0.005, and initial conditions x1 (0) = 50, x2 (0) = 30.
For E = 0, 0.01, 0.02, 0.03, 0.04, use the file PP.m with appropriate parameters to compute
the solution for the time values [0, 10]. For example, for E = 0.02 you might use the
commands
[t2,x2] = ode45(@PP,[0,10],[50;30],[],0.38,0.01,0.32,0.005);
For each of the solutions, plot the number of prey versus the number of predators, all on the
same plot, and label them appropriately.
(c) Finally, plot on the same graph the ratio of the predators to the prey for each of your five
solutions. You would use something like
plot(t0,x0(:,2)./x0(:,1),t1,x1(:,2)./x1(:,1),t2,x2(:,2)./x2(:,1),
t3,x3(:,2)./x3(:,1),t4,x4(:,2)./x4(:,1)); shg
(depending on your own notation). During the war, the total amount of fishing (the value of
the parameter E) decreased. Does your computation predict a larger proportion of predators
in that case?
1
Download