Shared2018-04-12-012027.sagewsOpen in CoCalc
var("H","G") 
h_prime=((1/(1+G^9))-0.2*H)
g_prime=H-0.18*G #defi8ens the g equation
t=srang(0,50,0.1) #ranges from 0 to 50 with a step size of 0.1
sol=desolve_odeint([h_prime,g_prime], ics=[0.4,0.3],dvars=[H,G],times=t) #simulates each differential equation
list_plot(zip(t,sol[:,0]), axes_labels=["time","Hormone secretion"], legend_label="H gland") + list_plot(zip(t,sol[:,1]), color="red", legend_label="G gland") #plots the time seriese
(H, G)

var("h,p,g")
k1 = k2 = k3 = 0.2
assume(h >= 0)
assume(p >= 0)
assume(g >= 0)
hprime=(1/(1+g^9))-k1*h
pprime=h-k2*p
gprime=p-k3*g
sol=solve([hprime,pprime,gprime], [h,p,g],solution_dict=True)
for s in sol:
    if s[h] >= 0 and s[p] >= 0 and s[g] >= 0:
        print "[h,p,g] = ({},{})".format(s[h].n(digits=4),s[p].n(digits=4),s[g].n(digits=4))
        p += point([s[h], s[p], s[g]], size=60, color="red")
        p += text("({},{})".format(s[h].n(digits=4), s[p].n(digits=4)), s[h].n(digits=4),[s[p]+1.5, s[p]+0.3, s[g]+0.5])
show(p, find_root)
(h, p, g) [h,p,g] = (0.02010 - 0.06160*I,0.1005 - 0.3080*I)
Error in lines 10-14 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1013, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 4, in <module> File "/ext/sage/sage-8.1/local/lib/python2.7/site-packages/sage/plot/point.py", line 353, in point return point3d(points, **kwds) File "/ext/sage/sage-8.1/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.py", line 1172, in point3d A = sum([Point(z, size, **kwds) for z in v]) File "/ext/sage/sage-8.1/local/lib/python2.7/site-packages/sage/plot/plot3d/shapes2.py", line 749, in __init__ self.loc = (float(center[0]), float(center[1]), float(center[2])) TypeError: 'sage.symbolic.expression.Expression' object does not support indexing
var("S","P") 
s_prime=(0.5-0.23*S*P^2)
p_prime=0.23*S*P^2-0.4*P #defi8ens the g equation
t=srange(0,50,0.1) #ranges from 0 to 50 with a step size of 0.1
sol=desolve_odeint([s_prime,p_prime], ics=[4,5],dvars=[S,P],times=t) #simulates each differential equation
list_plot(zip(t,sol[:,0]), axes_labels=["time","Hormone secretion"], legend_label="H gland") + list_plot(zip(t,sol[:,1]), color="red", legend_label="G gland") #plots the time seriese
(S, P)
var("S","P") 
s_prime=(0.5-0.23*S*P^2)
p_prime=0.23*S*P^2-0.4*P #defi8ens the g equation
t=srange(0,50,0.1) #ranges from 0 to 50 with a step size of 0.1
sol=desolve_odeint([s_prime,p_prime], ics=[10,20],dvars=[S,P],times=t) #simulates each differential equation
list_plot(zip(t,sol[:,0]), axes_labels=["time","Hormone secretion"], legend_label="H gland") + list_plot(zip(t,sol[:,1]), color="red", legend_label="G gland") #plots the time seriese
(S, P)
var("S","P") 
s_prime=(0.50-0.23*S*P^2)
p_prime=0.23*S*P^2-0.4*P #defi8ens the g equation
t=srange(0,100,0.1) #ranges from 0 to 50 with a step size of 0.1
sol=desolve_odeint([s_prime,p_prime], ics=[1,5],dvars=[S,P],times=t) #simulates each differential equation
list_plot(zip(t,sol[:,0]), axes_labels=["time","Hormone secretion"], legend_label="H gland") + list_plot(zip(t,sol[:,1]), color="red", legend_label="G gland", plotjoined=True) #plots the time seriese
(S, P)