Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
223 views
var('x y t') k = 0.08 a = 0.001 r = 0.02 b = 0.00002 prey = k*x - a*x*y predator = -r*y + b*x*y # The initial conditions are in the form (t, x, y); end_points is the final value of t solution = desolve_system_rk4([prey, predator], [x,y], ics=[0, 1000, 50], ivar = t, end_points = 500) # We need to pick appropriate pairs of points to construct the plots txpoints = [ [i,j] for i, j, k in solution] typoints = [ [i,k] for i, j, k in solution] xypoints = [ [j,k] for i, j, k in solution] # Construct plots separately tx = list_plot(txpoints, plotjoined=true, color='red') ty = list_plot(typoints, plotjoined=true, color='blue') xy = list_plot(xypoints, plotjoined=true, color='green') sf = plot_slope_field((predator)/(prey), (x, 0, 4000), (y, 0, 200), plot_points = 25) # Display the graphs show(tx+ty) show(sf+xy)
(x, y, t)
solve([prey == 0, predator == 0], [x, y])
[[x == 0, y == 0], [x == 800, y == 0], [x == 1000, y == -20]]
var('x y t') prey = 2*x*(1-0.0001*x) - 0.01*x*y predator = -0.5*y + 0.0001*x*y # The initial conditions are in the form (t, x, y); end_points is the final value of t solution = desolve_system_rk4([prey, predator], [x,y], ics=[0, 1000, 50], ivar = t, end_points = 500) # We need to pick appropriate pairs of points to construct the plots txpoints = [ [i,j] for i, j, k in solution] typoints = [ [i,k] for i, j, k in solution] xypoints = [ [j,k] for i, j, k in solution] # Construct plots separately tx = list_plot(txpoints, plotjoined=true, color='red') ty = list_plot(typoints, plotjoined=true, color='blue') xy = list_plot(xypoints, plotjoined=true, color='green') sf = plot_slope_field((predator)/(prey), (x, 0, 15000), (y, 0, 200), plot_points = 25) # Display the graphs #show(tx+ty) #show(sf+xy) show(sf)
(x, y, t)