Application Center - Maplesoft

App Preview:

Predator and Prey Model

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

 

 

Predator and Prey Model 

 

The following was implemented in Maple by Marcus Davidsson (2008) davidsson_marcus@hotmail.com 

 

 

 

Outline of Problem 

 

 

Rabbits and foxes are living in a confined area.  

 

Rabbits are eating grass which there are plentiful of. 

 

Foxes are eating rabbits. 

 

 

We can now set up a model which will enable us to model the number of rabbits and foxes at any given time.  

 

 

We assume that: 

 

the number of rabbits at time t is denoted by x(t) and the number of foxes at time t is denoted by y(t).  

 

The equation of motion for the rabbit population is given by 

dx/dt = x(t) ? x(t)*y(t)   

 

The equation of motion for the fox population is given by 

dy/dt = x(t)*y(t) - y(t) 

The initial rabbit population is given by x(0) =1.5 and the initial fox population is given by y(0) =0.5  

 

We can now visualize the dynamics of the number of rabbits and foxes over time 

 

 

 

 

Rabbit Population Over Time 

 

 

restart; 1; with(plots); -1; with(DEtools); -1; `:=`(sys, [diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t))))), diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))]); 1 

[diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t))))), diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))] (1)
 

`:=`(Rab, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize = .1, scene = [t, x(t)], linecolor = 'blue')); -1; display({Rab}, title =
`:=`(Rab, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize = .1, scene = [t, x(t)], linecolor = 'blue')); -1; display({Rab}, title =
 

Plot_2d
 

 

 

 

 

Fox Population Over Time 

 

 

restart; 1; with(plots); -1; with(DEtools); -1; `:=`(sys, [diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t))))), diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))]); 1 

[diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t))))), diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))] (2)
 

`:=`(Fox, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize = .1, scene = [t, y(t)], linecolor = 'red')); -1; display({Fox}, title =
`:=`(Fox, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize = .1, scene = [t, y(t)], linecolor = 'red')); -1; display({Fox}, title =
 

Plot_2d
 

 

 

 

Rabbit and Fox Population Over Time 

 

 

restart; 1; with(plots); -1; with(DEtools); -1; `:=`(sys, [diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t))))), diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))]); 1 

[diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t))))), diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))] (3)
 

`:=`(Rab, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize = .1, scene = [t, x(t)], linecolor = 'blue')); -1; `:=`(Fox, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize =...
`:=`(Rab, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize = .1, scene = [t, x(t)], linecolor = 'blue')); -1; `:=`(Fox, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize =...
`:=`(Rab, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize = .1, scene = [t, x(t)], linecolor = 'blue')); -1; `:=`(Fox, DEplot(sys, [x(t), y(t)], t = 0 .. 13, {[0, 1.5, .5]}, stepsize =...
 

Plot_2d
 

 

 

 

Phase Diagram in a 2D Plane 

 

 

restart; 1; with(plots); -1; with(DEtools); -1; `:=`(dif1, diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t)))))); -1; `:=`(dif2, diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))); -1; `:=`(initial...
restart; 1; with(plots); -1; with(DEtools); -1; `:=`(dif1, diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t)))))); -1; `:=`(dif2, diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))); -1; `:=`(initial...
restart; 1; with(plots); -1; with(DEtools); -1; `:=`(dif1, diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t)))))); -1; `:=`(dif2, diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))); -1; `:=`(initial...
restart; 1; with(plots); -1; with(DEtools); -1; `:=`(dif1, diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t)))))); -1; `:=`(dif2, diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))); -1; `:=`(initial...
restart; 1; with(plots); -1; with(DEtools); -1; `:=`(dif1, diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t)))))); -1; `:=`(dif2, diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))); -1; `:=`(initial...
restart; 1; with(plots); -1; with(DEtools); -1; `:=`(dif1, diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t)))))); -1; `:=`(dif2, diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))); -1; `:=`(initial...
restart; 1; with(plots); -1; with(DEtools); -1; `:=`(dif1, diff(x(t), t) = `+`(x(t), `-`(`*`(x(t), `*`(y(t)))))); -1; `:=`(dif2, diff(y(t), t) = `+`(`*`(x(t), `*`(y(t))), `-`(y(t)))); -1; `:=`(initial...
 

Plot_2d
 

 

 

 

 

Phase Diagram in a 3D Space 

 

 

restart 

 

Our general function is given by 

F(x(t), y(t)) 

F(x(t), y(t)) (4)
 

The derivative with respect to time (chain rule) for the above funcion is given by 

 

`+`(`*`(diff(F(x, y), x), `*`(diff(x(t), t))), `*`(diff(F(x, y), y), `*`(diff(y(t), t)))) 

`+`(`*`(diff(F(x, y), x), `*`(diff(x(t), t))), `*`(diff(F(x, y), y), `*`(diff(y(t), t)))) (5)
 

 

We know that our two differential equations are given by 

 

1) diff(x(t),t) = x-x*y  2) diff(y(t),t) = x*y-y 

 

 

If we plug that into the previous equation we get: 

 

subs({diff(x(t), t) = `+`(x, `-`(`*`(x, `*`(y)))), diff(y(t), t) = `+`(`*`(x, `*`(y)), `-`(y))}, %) 

`+`(`*`(diff(F(x, y), x), `*`(`+`(x, `-`(`*`(x, `*`(y)))))), `*`(diff(F(x, y), y), `*`(`+`(`*`(x, `*`(y)), `-`(y))))) (6)
 

The solution to the above partial differential equations is given by: 

 

pdsolve(%) 

F(x, y) = _F1(`*`(x, `*`(y, `*`(exp(`+`(`-`(y), `-`(x))))))) (7)
 

 

Note that only equations with closed form solutions is possible to solve with pdsolve 

 

In order for F(x,y)= constant for example F(x,y)=1 then _F1 has to be equal to 1/(x*y*exp(-y-x)) 

 

`:=`(_F1, `/`(1, `*`(x, `*`(y, `*`(exp(`+`(`-`(y), `-`(x)))))))) 

`/`(1, `*`(x, `*`(y, `*`(exp(`+`(`-`(y), `-`(x))))))) (8)
 

We now plot that function with its corresponding contour lines: 

 

plot3d(_F1, x = 0 .. 2.7, y = 0 .. 2.7, axes = box, style = surfacecontour, labels = [x, y, time], view = [0 .. 2.7, 0 .. 2.7, 7 .. 15]); 1
plot3d(_F1, x = 0 .. 2.7, y = 0 .. 2.7, axes = box, style = surfacecontour, labels = [x, y, time], view = [0 .. 2.7, 0 .. 2.7, 7 .. 15]); 1
 

Plot
 

 

 

 

Legal Notice: The copyright for this application is owned by the authors. Neither Maplesoft nor the authors are responsible for any errors contained within and are not liable for any damages resulting from the use of this material.. This application is intended for non-commercial, non-profit use only. Contact the authors for permission if you wish to use this application in for-profit activities.