CoCalc Shared FilesLab 1 / Homework #2.sagewsOpen in CoCalc with one click!
Author: Ashley Osorio-Zavala
Views : 70
Description: hw
#Further Excercise 5 var("P") var("N") Nprime=0.5*N-0.1*N*P Pprime=0.5*0.01*N*P-0.2*P NP_vector = (Nprime,Pprime) plot_vector_field(NP_vector, (N,0,10), (P,0,10), axes_labels=["N","P"])
P N
t=srange(0,100,0.1) sol1=desolve_odeint([Nprime,Pprime],ics=[1,3],dvars=[N,P],times=t) list_plot(zip(t,sol1[:,0]), plotjoined=true)+list_plot(zip(t,sol1[:,1]), color="red", plotjoined=true)
t=srange(0,100,0.1) sol2=desolve_odeint([Nprime,Pprime],ics=[0.2,1],dvars=[N,P],times=t) list_plot(zip(t,sol2[:,0]), plotjoined=true)+list_plot(zip(t,sol2[:,1]), color="red", plotjoined=true)
plot_vector_field(NP_vector, (N,0,400), (P,0,30), axes_labels=["N","P"])+list_plot(sol1,plotjoined=true, color="blue")+list_plot(sol2, plotjoined=true, color="magenta")
#b #The Holling-Tanner model is a much more defined version of the Lokta Volterra model. The LV model does not set realistic expectations of the behavior of a model while the Holling-tanner model incoporates limitations that help make the system more biologically sound- like adding a carrying capacity to the naturalk growth of populations or adding a saturation point to the amount of prey the predator can eat. var("G","H","P","n") #set variable k1=0.2 # define values k2=0.21 k3=0.18 t=srange(0,100,0.1) #set srange Hprime=(1/(1+G^n))-k1*H @interact def nval(n=(2,12)): Hprime=(1/(1+G^n))-k1*H #define differential equations P2prime=H-k2*P Gprime=P-k3*G system=[Hprime,Gprime, P2prime] #make all differential equations in one list sol5=desolve_odeint(system,ics=[3,5,4],dvars=[H,G,P],times=t) #use desolve p=list_plot(zip(t,sol5[:,0]), plotjoined=true, color="lime")+list_plot(zip(t,sol5[:,1]), color="magenta", plotjoined=true)+list_plot(zip(t,sol5[:,2]), color="blue",plotjoined=true) show(p)
(G, H, P, n)
Interact: please open in CoCalc