This is an example from Jim Cushing’s book An Introduction to Structured Population Dynamics. He studies flour beetles in the lab, and his gang (The Beetle Team) has demonstrated chaos in the population dynamics of the flour beetles Tribolium. 

(Their bitter rival gang -- the Aphid Team -- has demonstrated chaos in flowers.)

This demo explores Cushing’s Figure 1.19, p. 60.

Andy Long
Spring, 2018

We set the initial populations, and the parameters to generate the results of the bifurcation diagram:

L=100;
P=100;
A=100;
cel=0.01385;
cea=0.01114;
cpa=0.004348;
mul=0.1613;
mua=0.96;
b=7.876;
TransitionCpa[A_,L_,cpa_]:=
{
{0,           0,                       b Exp[-cel L -cea A] },
{1-mul,0,                       0                                              },
{0,           Exp[-cpa A],1-mua                                   }
};
x0={L,P,A};
iterations={x0};
Do[
TransitionMatrix=TransitionCpa[A,L,cpa];
{L,P,A}=TransitionMatrix.x0;
x0={L,P,A};
iterations=AppendTo[iterations,x0],
{i,1,100}
]
iterations;

Let’s see how the equilibrium is computed, and visualize the solutions starting from that equilibrium for cpa:

Clear[a,pstar,lstar,astar]
n=b(1-mul)/mua
pstar=(1-mul)lstar
lstar=(Log[n]-(cea+cpa)astar)/cel
astar=a/.FindRoot[mua a -(1-mul)(Log[n]-(cea+cpa)a)/cel Exp[-cpa a],{a,10}]

(* These two curves have to intersect -- i.e. there is a solution astar so long as the y-intercept of the second of these two functions is positive: (1-mul)Log[n]. So n must be greater than 1. *)
Plot[{mua a ,(1-mul)(Log[n]-(cea+cpa)a)/cel Exp[-cpa a]},{a,0,10 astar},PlotLabel->"Intersection of the curves is at A=A^*"]

(* 
Now I'm going to perturb the equilibrium just a little (more); it's already perturbed, because we computed astar numerically -- so it's off, but perhaps in the seventeenth decimal place. If we waited around long enough, however, we'd probably see the solutions veer away from the equilibrium even without the push.
 *)
L=lstar*1.0001
P=pstar
A=astar

(* Reset the transition matrix function: *)
TransitionCpa[A_,L_,cpa_]:=
{
{0,           0,                       b Exp[-cel L -cea A] },
{1-mul,0,                       0                                              },
{0,           Exp[-cpa A],1-mua                                   }
};

(* Let's keep track of the iterations, so that we can plot them later: *)
x0={L,P,A};
iterations={x0};
Do[
TransitionMatrix=TransitionCpa[A,L,cpa];
{L,P,A}=TransitionMatrix.x0;
x0={L,P,A};
iterations=AppendTo[iterations,x0],
{i,1,200}
]
ListPlot[Transpose[iterations],PlotStyle->{Black,Red,Blue}]

Now let’s turn this into a manipulation: we’ll tune the cannibalism coefficient Cpa (predation on pupae by adults), and watch as the once-stable equilibrium destabilizes into cycles, and ultimately “chaos”  (and back to cycles again!):

Manipulate[
Module[
{n,lstar,pstar,astar,L,P,A,x0},
n=b(1-mul)/mua;
pstar=(1-mul)lstar;
lstar=(Log[n]-(cea+cpa)astar)/cel;
astar=a/.FindRoot[mua a -(1-mul)(Log[n]-(cea+cpa)a)/cel Exp[-cpa a],{a,10}];
L=lstar*1.0001;
P=pstar;
A=astar;
x0={L,P,A};
iterations={x0};
transmat=TransitionCpa[A,L,cpa];
Do[
TransitionMatrix=TransitionCpa[A,L,cpa];
transmat=TransitionMatrix.transmat;
{L,P,A}=TransitionMatrix.x0;
x0={L,P,A};
iterations=AppendTo[iterations,x0],
{i,1,nits}
];
(* Print[MatrixForm[transmat]]; *)
ListPlot[Transpose[iterations],PlotStyle->{Black,Red,Blue},PlotLabel->Eigenvalues[TransitionMatrix]]
],
{{cpa,0.15},0,0.54},
{{nits,200},100,2000}
]