Experiments in predator-prey with Sage (Rev #11, changes)

Showing changes from revision #10 to #11:
Added | ~~Removed~~ | ~~Chan~~ged

I want to showing an easy way of doing predator-prey modeling in Sage. Right now it is a dimensionless version and one version which is the competitive Lotka-Volterra.

This is the original Lotka-Volterra phase map for a non-dimensional form. This was posted on Marshall Hampon on the ask.sagemath.org site. The original Lotka-Volterra equations has many coarse “flaws” and has also been modified over time as we’ll see below. Dimensionless format of Lotka-Volterra. The default for Sage ode_solver() is to use runga-kutta-felhberg (4,5) to find solutions

This is the phase plot for prey on the x-axis and predator on the y-axis.

We first add a parameter g which is used in the to control the effect of the growth of the number of predator. For g=1 I got a similar plot as the first one above.

def lv(g,k=None): Tg = ode_solver() Tg.function = lambda t, y: [y[0]*(1 - y[1]), -g*y[1] + y[0]*y[1]] sol_lines = Graphics() for i in srange(0.1,1.1,.2): Tg.ode_solve(y_0=[i,i],t_span=[0,10],num_points=10^3) y = Tg.solution sol_lines += line([x[1] for x in y], rgbcolor = (i,i,0)) return sol_lines @interact def lv_explorer(gamma = (0.,1.,0.1)): #html("equilibrium points are is %.2f" % k) show(lv(gamma))

Try to see **what happens for small values of g**. Also see if you can **find a way to show time plots for predator and prey in the same plot**.

Here is my plot of varying g:

We will add some better model of growth and look at cases where Lotka-Volterra might lead to Hopf bifurcation and also see if we can add the Allee effect.

- Sage public worksheet containing the complete code so far which you can view or download.

category: experiments