Sage DE-solvers tutorial

148 days ago by staffan

var('pred prey t') LV= desolve_system_rk4([pred*(1-prey),-prey*(1-pred)],[pred,prey],ics=[0,.5,2.],ivar=t,end_points=50) # phase plot line([e[1:] for e in LV]) 
       
line(LV) #.show(viewer='tachyon') 
       
# plot how predator and prey population varies over time predt = line([e[:-1] for e in LV],linestyle=':') preyt = line([e[::2] for e in LV]) predt + preyt