CoCalc Public Files.snapshots / 2020-01-17-203940 / 2020-01-17-115306.sagewsOpen with one click!
Author: Saja Kamal
Views : 108
#Saja Kamal #Homework #1 #4.2.1 #n greater than 8. var("G, H, P") #Assigns the variables G, H, P. n=100 #n greater than 8. k1=0.2 k2=0.21 k3=0.18 t=srange(0,100,0.1) #Defines the srange: from 0 to 100, with a step size of 0.1, at t. Hprime=((1/(1+(G^n)))-k1*H) Pprime=H-(k2*P) Gprime=P-k3*G sol=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[0.7, 0.5, 0.7], dvars=[H,P,G]) #Defines sol as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (0.7,0.5,0.7). sol_1=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[3, 3, 3], dvars=[H,P,G]) #Defines sol_1 as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (3,3,3). sol_2=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[0.6, 0.6, 0.6], dvars=[H,P,G]) #Defines sol_2 as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (0.6,0.6,0.6). list_plot(zip(t, sol[:,0]), legend_label="H", plotjoined=True) + list_plot(zip(t, sol[:,1]), legend_label="P", plotjoined=True, color="yellow") + list_plot(zip(t, sol[:,2]), legend_label="G", plotjoined=True, color="blue", axes_labels=["X", "Y"]) #Plot HPG list_plot(zip(t, sol_1[:,0]), legend_label="H", plotjoined=True, color="red") + list_plot(zip(t, sol_1[:,1]), legend_label="P", plotjoined=True, color="orange") + list_plot(zip(t, sol_1[:,2]), legend_label="G", plotjoined=True, color="black", axes_labels=["X", "Y"]) #Plot HPG. list_plot(zip(t, sol_2[:,0]), legend_label="H", plotjoined=True, color="pink") + list_plot(zip(t, sol_2[:,1]), legend_label="P", plotjoined=True, color="gray") + list_plot(zip(t, sol_2[:,2]), legend_label="G", plotjoined=True, color="purple", axes_labels=["X", "Y"]) #Plot HPG.
(G, H, P)
#As n passes 8, the equilibrium point becomes unstable, and a stable oscillation is created. #n less than 8 var("G, H, P") #Assigns the variables G, H, P. n=1 #n less than 8 k1=0.2 k2=0.21 k3=0.18 t=srange(0,100,0.1) #Defines the srange: from 0 to 100, with a step size of 0.1, at t. Hprime=((1/(1+(G^n)))-k1*H) Pprime=H-(k2*P) Gprime=P-k3*G sol=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[0.7, 0.5, 0.7], dvars=[H,P,G]) #Defines sol as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (0.7,0.5,0.7). sol_1=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[3, 3, 3], dvars=[H,P,G]) #Defines sol_1 as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (3,3,3). sol_2=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[0.6, 0.6, 0.6], dvars=[H,P,G]) #Defines sol_2 as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (0.6,0.6,0.6). list_plot(zip(t, sol[:,0]), legend_label="H", plotjoined=True) + list_plot(zip(t, sol[:,1]), legend_label="P", plotjoined=True, color="yellow") + list_plot(zip(t, sol[:,2]), legend_label="G", plotjoined=True, color="blue", axes_labels=["X", "Y"]) #Plot HPG. list_plot(zip(t, sol_1[:,0]), legend_label="H", plotjoined=True, color="red") + list_plot(zip(t, sol_1[:,1]), legend_label="P", plotjoined=True, color="orange") + list_plot(zip(t, sol_1[:,2]), legend_label="G", plotjoined=True, color="black", axes_labels=["X", "Y"]) #Plot HPG. list_plot(zip(t, sol_2[:,0]), legend_label="H", plotjoined=True, color="pink") + list_plot(zip(t, sol_2[:,1]), legend_label="P", plotjoined=True, color="gray") + list_plot(zip(t, sol_2[:,2]), legend_label="G", plotjoined=True, color="purple", axes_labels=["X", "Y"]) #Plot HPG.
(G, H, P)
#When n is less than 8, the system goes to a stable equilibrium. #4.2.2 var("G, H, P") #Assigns the variables G, H, P. n=9 k1=0.2 k2=0.21 k3=0.18 t=srange(0,100,0.1) #Defines the srange: from 0 to 100, with a step size of 0.1, at t. Hprime=((1/(1+(G^n)))-k1*H) Pprime=H-(k2*P) Gprime=P-k3*G sol=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[0.7, 0.5, 0.7], dvars=[H,P,G]) #Defines sol as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (0.7,0.5,0.7). sol_1=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[3, 3, 3], dvars=[H,P,G]) #Defines sol_1 as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (3,3,3). sol_2=desolve_odeint([Hprime, Pprime, Gprime], times=t, ics=[0.6, 0.6, 0.6], dvars=[H,P,G]) #Defines sol_2 as desolve_odeint for the function, time list of t, state variable H, P, and G, and the initial condition (0.6,0.6,0.6). list_plot(zip(sol[:,0], sol[:,1], sol[:,2]), plotjoined=True, color="brown") #Plot 3-D trajectories. list_plot(zip(sol_1[:,0], sol_1[:,1], sol_1[:,2]), plotjoined=True, color="teal") #Plot 3-D trajectories. list_plot(zip(sol_2[:,0], sol_2[:,1], sol_2[:,2]), plotjoined=True, color="red") #Plot 3-D trajectories.
(G, H, P)
3D rendering not yet implemented
3D rendering not yet implemented
3D rendering not yet implemented
#4.2.3 #n greater than 8. var("G, H") #Assigns the variables G, H. n=100 #n greater than 8. k1=0.2 k2=0.21 k3=0.18 t=srange(0,100,0.1) #Defines the srange: from 0 to 100, with a step size of 0.1, at t. Hprime=((1/(1+(G^n)))-k1*H) Gprime=P-k3*G sol=desolve_odeint([Hprime, Gprime], times=t, ics=[0.7, 0.7, 0.7], dvars=[H,G]) #Defines sol as desolve_odeint for the function, time list of t, state variable H, G, and the initial condition (0.7,0.7). sol_1=desolve_odeint([Hprime, Gprime], times=t, ics=[3, 3, 3], dvars=[H,G]) #Defines sol_1 as desolve_odeint for the function, time list of t, state variable H, G, and the initial condition (3,3). sol_2=desolve_odeint([Hprime, Gprime], times=t, ics=[0.6, 0.6, 0.6], dvars=[H,G]) #Defines sol_2 as desolve_odeint for the function, time list of t, state variable H, G, and the initial condition (0.6,0.6). list_plot(zip(t, sol[:,0]), legend_label="H", plotjoined=True + list_plot(zip(t, sol[:,1]), legend_label="G", plotjoined=True, color="blue", axes_labels=["X", "Y"]) #Plot HG list_plot(zip(t, sol_1[:,0]), legend_label="H", plotjoined=True, color="red" + list_plot(zip(t, sol_1[:,1]), legend_label="G", plotjoined=True, color="black", axes_labels=["X", "Y"]) #Plot HG. list_plot(zip(t, sol_2[:,0]), legend_label="H", plotjoined=True, color="pink" + list_plot(zip(t, sol_2[:,1]), legend_label="G", plotjoined=True, color="purple", axes_labels=["X", "Y"]) #Plot HG.
(G, H)
Error in lines 9-9 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1234, in execute flags=compile_flags), namespace, locals) File "", line 1, in <module> File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/sage/calculus/desolvers.py", line 1705, in desolve_odeint mxhnil=mxhnil, mxordn=mxordn, mxords=mxords, printmessg=printmessg) File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/scipy/integrate/odepack.py", line 244, in odeint int(bool(tfirst))) File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/sage/calculus/desolvers.py", line 1689, in func return [dec(*v) for dec in desc] File "sage/ext/interpreters/wrapper_rdf.pyx", line 71, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (build/cythonized/sage/ext/interpreters/wrapper_rdf.c:2184) if self._n_args != len(args): raise ValueError ValueError
# The negative feedback will not oscillate, no matter how steep the feedback for n greater than 8 if the middleman, P Prime, is eliminated. This is so because P Prime is a key time delay in generating an oscillation. #n less than 8. var("G, H") #Assigns the variables G, H. n=1 #n less than 8. k1=0.2 k2=0.21 k3=0.18 t=srange(0,100,0.1) #Defines the srange: from 0 to 100, with a step size of 0.1, at t. Hprime=((1/(1+(G^n)))-k1*H) Gprime=P-k3*G sol=desolve_odeint([Hprime, Gprime], times=t, ics=[0.7, 0.7, 0.7], dvars=[H,G]) #Defines sol as desolve_odeint for the function, time list of t, state variable H, G, and the initial condition (0.7,0.7). sol_1=desolve_odeint([Hprime, Gprime], times=t, ics=[3, 3, 3], dvars=[H,G]) #Defines sol_1 as desolve_odeint for the function, time list of t, state variable H, G, and the initial condition (3,3). sol_2=desolve_odeint([Hprime, Gprime], times=t, ics=[0.6, 0.6, 0.6], dvars=[H,G]) #Defines sol_2 as desolve_odeint for the function, time list of t, state variable H, G, and the initial condition (0.6,0.6). list_plot(zip(t, sol[:,0]), legend_label="H", plotjoined=True + list_plot(zip(t, sol[:,1]), legend_label="G", plotjoined=True, color="blue", axes_labels=["X", "Y"]) #Plot HG list_plot(zip(t, sol_1[:,0]), legend_label="H", plotjoined=True, color="red" + list_plot(zip(t, sol_1[:,1]), legend_label="G", plotjoined=True, color="black", axes_labels=["X", "Y"]) #Plot HG. list_plot(zip(t, sol_2[:,0]), legend_label="H", plotjoined=True, color="pink" + list_plot(zip(t, sol_2[:,1]), legend_label="G", plotjoined=True, color="purple", axes_labels=["X", "Y"]) #Plot HG.
(G, H)
Error in lines 9-9 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1234, in execute flags=compile_flags), namespace, locals) File "", line 1, in <module> File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/sage/calculus/desolvers.py", line 1705, in desolve_odeint mxhnil=mxhnil, mxordn=mxordn, mxords=mxords, printmessg=printmessg) File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/scipy/integrate/odepack.py", line 244, in odeint int(bool(tfirst))) File "/ext/sage/sage-8.9_1804/local/lib/python2.7/site-packages/sage/calculus/desolvers.py", line 1689, in func return [dec(*v) for dec in desc] File "sage/ext/interpreters/wrapper_rdf.pyx", line 71, in sage.ext.interpreters.wrapper_rdf.Wrapper_rdf.__call__ (build/cythonized/sage/ext/interpreters/wrapper_rdf.c:2184) if self._n_args != len(args): raise ValueError ValueError