Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168704
Image: ubuntu2004
%latex .\\ BORLONGAN, Samuel Dennis R. \\ 2007-46377 \\ \\ CS 131 Machine Problem 5 \\ \\
%latex .\\ Problem Description: \\ \\ {\bf 9.1.} ({\em a}) Use a library routine to solve the {\it Lotka-Volterra model} of predator-prey population dynamics given in Example 9.4, integrating from {\em t} = 0 to {\em t} = 25. Use the parameter values \begin{equation} {\alpha}_1 = 1, {\beta}_1 = 0.1, {\alpha}_2 = 0.5, {\beta}_2 = 0.02, \end{equation} and initial populations \begin{equation} {\em y}_1(0) = 100, {\em y}_2(0) = 10. \end{equation} Plot each of the two populations as a function of time, and on a separate graph plot the trajectory of the point \begin{equation} ( {\em y}_1({\em t}), {\em y}_2({\em t}) ) \end{equation} in the plane as a function of time. The latter is sometimes called a "phase portrait." Give a physical interpretation of the behavior you observe. Try other initial populations and observe the results using the same type of graphs. Can you find nonzero initial populations such that either of the populations eventually becomes extinct? Can you find nonzero initial populations that never change ({\em Hint:} You can find such a {\em stationary point} without solving the differential equation.)\\ \\ ({\em b}) Repeat part {\em a} but this time use the {\em Leslie-Gower model} \begin{align} {{\em y}^'}_1 & = {\em y}_1({\alpha}_1-{\beta}_1{\em y}_2), \\ {{\em y}^'}_2 & = {\em y}_2({\alpha}_2-{\beta}_2{\em y}_2/{\em y}_1). \end{align} Use the same parameter values except take \begin{equation} {\beta}_2 = 10. \end{equation} How does the behavior of the solutions differ between the two models?
%latex .\\ Method Description: \\ \\ {\bf 9.1.} ({\em a}) The autonomous, nonlinear ODE otherwise known as the {\em Lotka-Volterra model} \begin{align} {{\em y}^'}_1 & = {\em y}_1({\alpha}_1-{\beta}_1{\em y}_2), \\ {{\em y}^'}_2 & = {\em y}_2({-\alpha}_2+{\beta}_2{\em y}_1). \end{align} is numerically solved using the 4th order Runge-Kutta method, either as implemented by the Maxima command \verb|rk|, or by the Sage command \verb|desolve_system_rk4|. \\ \\ ({\em b}) The autonomous, nonlinear ODE that is otherwise known as the {\em Leslie-Gower model} \begin{align} {{\em y}^'}_1 & = {\em y}_1({\alpha}_1-{\beta}_1{\em y}_2), \\ {{\em y}^'}_2 & = {\em y}_2({\alpha}_2-{\beta}_2{\em y}_2/{\em y}_1). \end{align} is numerically solved using the 4th order Runge-Kutta method, either as implemented by the Maxima command \verb|rk|, or by the Sage command \verb|desolve_system_rk4|.
%latex .\\ Results Discussion: \\ \\ {\bf 9.1.} ({\em a}) The combined plots of the two populations using the {\em Lotka-Volterra model} (one plot using the original parameter values, another where every single value except {\em t} is halved), where the prey population plot is colored green, while the predator population is colored red, and the phase portrait is colored blue, are shown below. According to the combined plot, the prey population decreases and the predator population increases (due to the consumption of prey by predator) until \begin{equation} {\em t} = 4{\em n}, {\em n} = 1, 2, \ldots , \end{equation} in which both populations decrease (due to the low amount of prey, which then lowers the amount of predators via starvation), until a certain point was reached, where there are too few predators to eat too little prey, thus increasing the amount of prey, which later increases the amount of predators due to an increase of food for the latter population. The cycle then restarts when the rate of prey consumption is once again greater than the rate of prey production.
%sage from sage.calculus.desolvers import desolve_system_rk4 a_1 = 1 b_1 = 0.1 a_2 = 0.5 b_2 = 0.02 y_1_init = 100 y_2_init = 10 y_1, y_2, t = var('y_1 y_2 t') P=desolve_system_rk4([y_1*(a_1-b_1*y_2), y_2*(-a_2+b_2*y_1)], [y_1, y_2], ics=[0, y_1_init, y_2_init], ivar=t, end_points=[0,25]) Q_1=[ [i, j] for i, j, k in P] P_1=list_plot(Q_1, plotjoined=True, color='green') Q_2=[ [i, k] for i, j, k in P] P_2=list_plot(Q_2, plotjoined=True, color='red') P_1+P_2 Q_3=[ [j, k] for i, j, k in P] P_3=list_plot(Q_3, plotjoined=True) P_1+P_2+P_3
%sage from sage.calculus.desolvers import desolve_system_rk4 a_1 = 0.5 b_1 = 0.05 a_2 = 0.25 b_2 = 0.01 y_1_init = 50 y_2_init = 5 y_1, y_2, t = var('y_1 y_2 t') P=desolve_system_rk4([y_1*(a_1-b_1*y_2), y_2*(-a_2+b_2*y_1)], [y_1, y_2], ics=[0, y_1_init, y_2_init], ivar=t, end_points=[0,25]) Q_1=[ [i, j] for i, j, k in P] P_1=list_plot(Q_1, plotjoined=True, color='green') Q_2=[ [i, k] for i, j, k in P] P_2=list_plot(Q_2, plotjoined=True, color='red') P_1+P_2 Q_3=[ [j, k] for i, j, k in P] P_3=list_plot(Q_3, plotjoined=True) P_1+P_2+P_3
%latex .\\ To obtain a set of nonzero initial populations that remain constant, there has to be no difference in the populations of the predators nor the prey over time. Thus \begin{align} 0 & = {\em y}_1({\alpha}_1-{\beta}_1{\em y}_2), \\ 0 & = {\em y}_2({-\alpha}_2+{\beta}_2{\em y}_1), \\ {\em y}_1({\alpha}_1-{\beta}_1{\em y}_2) & = {\em y}_2({-\alpha}_2+{\beta}_2{\em y}_1), \\ {\em y}_1{\alpha}_1-{\beta}_1{\em y}_1{\em y}_2 & = -{\em y}_2{\alpha}_2+{\beta}_2{\em y}_1{\em y}_2, \\ {\em y}_1{\alpha}_1+{\em y}_2{\alpha}_2 & = {\beta}_1{\em y}_1{\em y}_2+{\beta}_2{\em y}_1{\em y}_2, \\ {\em y}_1{\alpha}_1+{\em y}_2{\alpha}_2 & = {\em y}_1{\em y}_2({\beta}_1+{\beta}_2). \end{align} The simplified equation gives the solution \begin{equation} ({\em y}_1, {\em y}_2) = (\frac{{\alpha}_2}{{\beta}_2}, \frac{{\alpha}_1}{{\beta}_1}) \end{equation} as the initial populations. Using these with the previously defined parameter values (replacing the originally defined initial populations) with the model results into the following graph:
%sage from sage.calculus.desolvers import desolve_system_rk4 a_1 = 1 b_1 = 0.1 a_2 = 0.5 b_2 = 0.02 y_1_init = a_2 / b_2 y_2_init = a_1 / b_1 y_1, y_2, t = var('y_1 y_2 t') P=desolve_system_rk4([y_1*(a_1-b_1*y_2), y_2*(-a_2+b_2*y_1)], [y_1, y_2], ics=[0, y_1_init, y_2_init], ivar=t, end_points=[0,25]) Q_1=[ [i, j] for i, j, k in P] P_1=list_plot(Q_1, plotjoined=True, color='green') Q_2=[ [i, k] for i, j, k in P] P_2=list_plot(Q_2, plotjoined=True, color='red') P_1+P_2 Q_3=[ [j, k] for i, j, k in P] P_3=list_plot(Q_3, plotjoined=True) P_1+P_2+P_3
%latex .\\ ({\em b}) The combined plots of the two populations using the {\em Leslie-Gower model} (using the same parameter values except taking \begin{equation} {\beta}_2 = 10, \end{equation} for the first plot, and using the halved parameter values except taking \begin{equation} {\beta}_2 = 5, \end{equation} for the second plot), with the same coloration scheme as the previous plots, are as follows:
%sage from sage.calculus.desolvers import desolve_system_rk4 a_1 = 1 b_1 = 0.1 a_2 = 0.5 b_2 = 0.02 y_1_init = 100 y_2_init = 10 y_1, y_2, t = var('y_1 y_2 t') P=desolve_system_rk4([y_1*(a_1-b_1*y_2), y_2*(a_2-b_2*y_2/y_1)], [y_1, y_2], ics=[0, y_1_init, y_2_init], ivar=t, end_points=[0,25]) Q_1=[ [i, j] for i, j, k in P] P_1=list_plot(Q_1, plotjoined=True, color='green') Q_2=[ [i, k] for i, j, k in P] P_2=list_plot(Q_2, plotjoined=True, color='red') P_1+P_2 Q_3=[ [j, k] for i, j, k in P] P_3=list_plot(Q_3, plotjoined=True) P_1+P_2+P_3
%sage from sage.calculus.desolvers import desolve_system_rk4 a_1 = 0.5 b_1 = 0.05 a_2 = 0.25 b_2 = 0.01 y_1_init = 50 y_2_init = 5 y_1, y_2, t = var('y_1 y_2 t') P=desolve_system_rk4([y_1*(a_1-b_1*y_2), y_2*(a_2-b_2*y_2/y_1)], [y_1, y_2], ics=[0, y_1_init, y_2_init], ivar=t, end_points=[0,25]) Q_1=[ [i, j] for i, j, k in P] P_1=list_plot(Q_1, plotjoined=True, color='green') Q_2=[ [i, k] for i, j, k in P] P_2=list_plot(Q_2, plotjoined=True, color='red') P_1+P_2 Q_3=[ [j, k] for i, j, k in P] P_3=list_plot(Q_3, plotjoined=True) P_1+P_2+P_3
%latex .\\ While the {\em Lotka-Volterra model} plots tend to oscillate, due to the interaction of the predator and prey populations, the {\em Leslie-Volterra model} plots show that the predator and prey populations asymptotically approach a certain value.
%latex .\\ Source code: \\ \\ \verb|http://www.sagenb.org/home/pub/2443|