Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to solve a difference equation, a Lotka-Volterra difference equation. I tried a model from http://www.stolaf.edu/people/mckelvey/envision.dir/nonDE.lotka-volt.html

Using their parameters:

a = 0.04; b = 0.0005; c = 0.2; d = 0.1;

I obtain the following:

eqs = {r[n + 1] == r[n] + a*r[n] - b*r[n]*f[n], f[n + 1] == f[n] + b*d*r[n]*f[n] - c*f[n]}
RSolve[eqs, {r[n], f[n]}, n]

(* RSolve[{r[1 + n] == 1.04 r[n] - 0.0005 f[n] r[n], 
          f[1 + n] == 0.8 f[n] + 0.00005 f[n] r[n]}, {r[n], f[n]}, n] *)

Mathematica does not give any clue, what is wrong. Can anyone help me find out where the problem is?

share|improve this question
add comment

1 Answer

When a difference equation does not have a closed form solution, you cannot realistically expect Mathematica to find one. The exercises on the page you link to ask for the steady state, not for a closed form solution! We can find the steady state solution by letting r=r[n] and f=f[n] and then rewriting the relationships that hold at the fixed point.

ss = {r - (r + a*r - b*r*f) == 0, f - (f + b*d*r*f - c*f) == 0}

The steady state is when ss holds. This can be handled easily by Solve

Solve[ss, {f, r}]

which returns two solutions:

{{f -> 0, r -> 0}, {f -> a/b, r -> c/(b d)}}

If you wish to simulate the equation, this can be done many ways. One is to explicitly use recursion:

Clear[a, b, c, d, r, f];
a = 0.04; b = 0.0005; c = 0.2; d = 0.1;
r[n_] := r[n] = r[n - 1] + a*r[n - 1] - b*r[n - 1]*f[n - 1]; 
f[n_] := f[n] = f[n - 1] + b*d*r[n - 1]*f[n - 1] - c*f[n - 1];
r[0] := c/(b d) - 100;
f[0] := a/b;

allR = r /@ Range[1500];
allF = f /@ Range[1500];

The final two lines calculate r and f (the number of rabbits and foxes, presumably) for 1500 timesteps. The output can be easily visualized. With these particular values, it doesn't look like a very happy ecosystem.

ListPlot[{allR, allF}]

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.