Friday, April 24, 2009

Adventures in Coupled Differential Equations

If you ever took a differential equations course in college, you probably encountered the fox and rabbit (predator/prey) paired differential equations. They looked something like this:

R'(t) = 2 R(t) - 0.01 R(t) F(t), R(0) = R0
F'(t) = - F(t) + 0.01 R(t) F(t), F(0) = F0

where R(t) and F(t) are functions representing the rabbit population and fox population, respectively, at time t. The initial conditions (starting values for R and F at time zero) are R0 and F0, respectively. R'(t) and F'(t) are standard notation indicating the derivatives of R and F with respect to t: in other words, the change in R and T per unit time at time t.

If you think about it, you can understand that if we neglect constraints such as food supply and predation, the more rabbits there are, the faster the rabbit population will rise, which is indicated by the first term on the right-hand side of the first equation. Conversely, the more foxes there are, the more the fox population will decrease, because the foxes have to compete with each other for food, as modeled by the first term on the right-hand side of the second equation. The encounters between rabbits and foxes have a deleterious effect on rabbits and a population raising effect on foxes, as you can see by the opposite signs on the coefficients of the final terms in both equations.

This turns out to be actually a pretty good model of population dynamics. An important question in ecology is what population levels can be sustained at a constant level (equilibrium)? If you look at the effect on the predator-prey populations of different initial conditions, you can find this out using trial and error. (There are legitimate mathematical ways to figure this out without graphing a bunch of guesses like this, just so you know.)

I used Matlab to solve the pair of differential equations with different initial conditions. I didn't graph some of the more boring initial conditions: if we start off with all rabbits and no foxes, the number of rabbits grows exponentially. Similarly, if we start off with no rabbits and all foxes, the foxes go extinct. On to more exciting initial conditions.

First, let's suppose that we start off with equal rabbit and fox populations. How do the populations change over time?
(Click the graph to embiggen.) As you can see, the populations vary in a regular, periodic pattern. You can see that the populations return to the starting state every so often, but the numbers of each species vary by a factor of 3 or 4. What happens then if we start off with 200 rabbits and 5 foxes?
Observe the dramatic swings in the populations of the two species. Again, the result is periodic, but the period is longer and the change in population from the maximum to the minimum of each species is quite drastic.

As it turns out, I know what the starting populations must be for the two species to remain at constant population. Look what happens when we start with 100 rabbits and 200 foxes:


You might wonder, what if we vary the numbers slightly? So I set the starting population of rabbits to 110 and kept the starting fox population at 200, and here's what I obtained:

So, as you can see, if the ratio of rabbits to foxes is close to 1:2, the populations will remain relatively stable, while if it gets out of balance, the populations will swing wildly.


Similar predator-prey coupled differential equations can be used to determine the equilibrium state of vampires and humans in the Buffy the Vampire Slayer universe. The equilibrium population size for the city where Buffy lives is about 36,000 humans and 18 vampires. As it turns out, the population of Sunnydale is actually very close to the equilibrium population size computed with the differential equations! (h/t Pharyngula)

Other fun vampire population ecology links:
Punk Rock Operations Research: On Vampires and Stochastic Processes
The Oyster's Garter: Vampire Ecology: Twilight vs Buffy

2 comments:

Doctor Pion said...

Nicely done!

The case with no foxes was, of course, of particular interest in Australia.

Curious Computer said...

Hmm... yes, I wonder how Myxo would be added in to the equation :)