sample-model

127 days ago by ncr006

S,I,R,t=var('S I R t') k=1./5 b=2 ss = desolve_system_rk4([-b*S*I,b*S*I-k*I,k*I], [S,I,R],ics=[0,1,.0001,0],ivar=t,end_points=50,step=1) SS=[ [i,j] for i,j,k,l in ss] LP = list_plot(SS,color="green",plotjoined=True,thickness=3,linestyle="--", axes_labels=['$t$','$S$, $I$, $R$'],legend_label="S") II = [[i,k] for i,j,k,l in ss] LP += list_plot(II,color="red",plotjoined=True,thickness=3,linestyle="-.",legend_label="I") RR = [[i,l] for i,j,k,l in ss] LP += list_plot(RR,color="blue",plotjoined=True,thickness=3,legend_label="R") show(LP)