Generating the Figures in Chapter 6 of Otto and Day

Clear["Global`*"]

Figure 6.1 - General solution to the mouse model of Chapter 2

genmouse [R_,m_,n0_,t_]:= R^t n0+(1-R^t) m/(1-R)

Show[ListPlot[Table[{t,genmouse[0.99,1,10,t]},{t,0,500}],Joined->True],ListPlot[Table[{t,genmouse[0.99,1,50,t]},{t,0,500}],Joined->True],ListPlot[Table[{t,genmouse[0.99,1,75,t]},{t,0,500}],Joined->True],ListPlot[Table[{t,genmouse[0.99,1,125,t]},{t,0,500}],Joined->True],ListPlot[Table[{t,genmouse[0.99,1,150,t]},{t,0,500}],Joined->True],ListPlot[Table[{t,genmouse[0.99,1,190,t]},{t,0,500}],Joined->True],PlotRange->{{0,400},{0,200}}]

Export["Fig",%,"EPS"];

Using Mathematica’s Manipulate to explore the dependence on the parameters:

Manipulate[ListPlot[Table[{t,genmouse[R,m,n0,t]},{t,0,500}],PlotRange->{{0,500},{0,200}}],{{R,0.99},0,0.999},{{m,1},0.2,2},{{n0,150},10,200}]

Figure 6.2 - Exponential growth comparisons

Show[
Plot[Exp[r],{r,-10,10}],
Plot[(1+r),{r,-10,10}],
PlotRange->{{-2,2},{0,5}}
]

Show[
ListPlot[Table[{t,(1+r)^t n0/.{r->-0.2, n0->1000}},{t,0,50}]],
Plot[Exp[r t] n0/.{r->-0.2, n0->1000},{t,0,50},PlotRange->All],
ListPlot[Table[{t,(1+r)^t n0/.{r->0.1, n0->1000}},{t,0,50}]],
Plot[Exp[r t] n0/.{r->0.1, n0->1000},{t,0,50},PlotRange->All],
ListPlot[Table[{t,(1+r)^t n0/.{r->0.2, n0->1000}},{t,0,50}]],
Plot[Exp[r t] n0/.{r->0.2, n0->1000},{t,0,50},PlotRange->All],
PlotRange->{{0,21},{0,5000}}
]

Figure 6.3 - Logistic Growth in Continuous Time (NDSolve vs General Solution)

Clear[DifLogistic,k,r,n0,n]
DifLogistic[k_,r_,n0_,tmin_,tmax_]:=DifLogistic[k,r,n0,tmin,tmax]=NDSolve[{D[n[t],t]==r n[t] (1-n[t] /k),n[tmin]==n0},n[t],{t,tmin,tmax}]

SolLogistic[k_,r_,n0_,t_]=Exp[r*t]*n0/((1-n0/k)+Exp[r*t]*n0/k);

Show[
Plot[SolLogistic[1000,0.5,10,t],{t,0,100},PlotStyle->Dashing[{0.005,0.02}],PlotRange->All],
Plot[Evaluate[n[t]/.DifLogistic[1000,0.5,10,0,100]],{t,0,100},PlotStyle->Dashing[{0.05}],PlotRange->All],
   PlotRange->{{0,30},{0,1100}}
]

Using Mathematica’s Manipulate to explore the dependence of the general solution for logistic growth on the parameters:

Manipulate[Plot[SolLogistic[k,r,n0,t],{t,0,100},PlotRange->{{0,100},{0,1200}}],{{k,1000},100,1200},{{r,0.5},0.01,2},{{n0,150},10,200}]