Group Abstract Group Abstract

Message Boards Message Boards

Predator Prey Plot over time

Posted 2 months ago

Hi;
I am trying to plot a progression of time periods for a Predator - Prey model using the function ParametricPlot with constants, Eigenvalues (raised to k powers and Eigenvectors - see attached notebook. However, I am having trouble getting any output. I am sure it is something that I am not coding correctly.

Thanks,
Mitch Sandlin

POSTED BY: Mitchell Sandlin
13 Replies
POSTED BY: Gianluca Gorni

Hi Gianluca;

I discovered that the key to getting what I wanted was using starting values that reflected the Eigenvalues. In the case of the attached Notebook, I used the exact Eigenvalues as the initial values.

I found it interesting that both your method and Eric's method produced exactly the same answer even though you used the MatrixPower function and Eric used Eigenvalues and Eigenvectors in his calculations.

Thanks so much, I not only obtained the answer, but learned a lot in the process.

Mitch Sandlin

Attachments:
POSTED BY: Mitchell Sandlin

Using MatrixPower:

mat = {{6/10, 1/2}, {-(7/40), 6/5}};
eigen = Eigenvectors[mat];
f[t_] = MatrixPower[mat, t];
ParametricPlot[{f[t] . {1, 1},
  f[t] . eigen[[1]], f[t] . eigen[[2]],
  f[t] . {1, 0}}, {t, 0, 20}] /. Line -> Arrow
POSTED BY: Gianluca Gorni
POSTED BY: Gianluca Gorni
Posted 2 months ago

This is probably the nicest way to see the overall behavior of the system.

POSTED BY: Eric Rimbey

ParametricPlot[] is evaluated before the c's are replaced by numbers. You need to do the replacement first.

If f and r are scalars, then you're plotting a scalar, which ParametricPlot[] won't do.

If f and r are ordered pairs, then you're plotting an ordered pair, and you should see a plot, if the first point is addressed.

You can also use Unevaluated[] to address the first point:

Unevaluated[
  ParametricPlot[Subscript[c, 1]*(0.95^k*{10, 7} . {f, r}) + 
         Subscript[c, 2]*(0.85^k*{2, 1} . {f, r}), {k, 1, 10}]] /. 
   {Subscript[c, 1] -> 1, Subscript[c, 2] -> 1, f -> {1, -1}, 
     r -> {-3, 2}}

Oops, update: Just noticed the blackboard. I think one problem, which is addressed incorrectly in the 2nd and 3rd points, is that you should not be using . (Dot[]) in your code. The blackboard as scalar multiplication (* or Times[]), not vector-vector multiplication nor matrix-vector multiplication.

POSTED BY: Michael Rogers
Posted 2 months ago
POSTED BY: Eric Rimbey
POSTED BY: Mitchell Sandlin
Posted 2 months ago
POSTED BY: Eric Rimbey
Attachments:
POSTED BY: Mitchell Sandlin
Posted 2 months ago
POSTED BY: Eric Rimbey

I am trying to guess what f and r may be:

With[{c1 = 1, c2 = 1, f = 1, r = 1},
 Plot[c1*0.95^k {10, 7} . {f, r} +
   c2*0.85^k {2, 1} . {f, r}, {k, 1, 10}]]
POSTED BY: Gianluca Gorni

Hi Gianluca;

In this predator - prey model, the f represents for "Foxes" and the r represents "Rabbits".

In the example that I submitted, I set the Predation value (the first value in the Rn+1 equation to - 0.175 which gives Eigenvalues of {.95, .85}. Since both these eigenvalues are less than 1 then over time both the Foxes and Rabbits should go extinct (as the provided graph in my attached notebook displays). My goal is to produce a plot to show this progression over several periods using Mathematica.

Thanks,

Mitch Sandlin

POSTED BY: Mitchell Sandlin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard