FindExtrema

| FindExtrema[f,{tmin,tmax}] |

| FindExtrema[f] |

| FindExtrema[rulelist] |

(3)

Basic Examples

(3)

An unforced continuous-time model — the Rosenzweig-MacArthur predator-prey model:

Needs["EcoEvo`"];

In[1]:=

SetModel[{Pop[n]{EquationdN,ColorGreen},Pop[p]{EquationdP,ColorRed}}];dN:=n[t](1-n[t]/k)-anp[t]n[t]/(n[t]+h);dP:=p[t](apn[t]/(n[t]+h)-m);

In[2]:=

an=1;ap=2;h=1;m=1;k=4;sol=EcoSim[{nk,p0.1},100]

In[3]:=

n

InterpolatingFunction

,pInterpolatingFunction

Out[3]=

PlotDynamics[sol]

In[4]:=

Out[4]=

Look across entire domain:

FindExtrema[n/.sol]

In[5]:=

{{9.47682,0.135844},{16.8988,3.20897},{22.8321,0.149691},{30.1197,3.15271},{35.96,0.1523},{43.2239,3.14226},{49.0479,0.152817},{56.3072,3.1402},{62.1279,0.152921},{69.3863,3.13979},{75.2065,0.152942},{82.4646,3.13971},{88.2846,0.152947},{95.5427,3.1397}}

Out[5]=

Focus on a certain range:

FindExtrema[n/.sol,{50,100}]

In[6]:=

{{56.3072,3.1402},{62.1279,0.152917},{69.3863,3.13979},{75.2065,0.152939},{82.4646,3.13971},{88.2846,0.152943},{95.5427,3.13969}}

Out[6]=

Thread across the rulelist sol:

FindExtrema[sol]

In[7]:=

{n{{9.47682,0.135844},{16.8988,3.20897},{22.8321,0.149691},{30.1197,3.15271},{35.96,0.1523},{43.2239,3.14226},{49.0479,0.152817},{56.3072,3.1402},{62.1279,0.152921},{69.3863,3.13979},{75.2065,0.152942},{82.4646,3.13971},{88.2846,0.152947},{95.5427,3.1397}},p{{7.18359,3.61523},{13.0114,0.193923},{20.5307,3.5074},{26.2892,0.214566},{33.6571,3.48826},{39.4036,0.218466},{46.7447,3.48451},{52.4888,0.219238},{59.8247,3.48377},{65.5683,0.219392},{72.9031,3.48362},{78.6467,0.219422},{85.9813,3.48359},{91.7248,0.219428},{99.0594,3.48358}}}

Out[7]=

———

The discrete-time Ricker equation:

Needs["EcoEvo`"];

In[1]:=

SetModel[{Pop[n]{Equationn[t]E^(r(1-n[t]))},ModelType"DiscreteTime"}]

In[2]:=

r=2.1;sol=EcoSim[{n0.01},10]

In[3]:=

nTimeSeries

Out[3]=

PlotDynamics[sol]

In[4]:=

Out[4]=

FindExtrema[n/.sol]

In[5]:=

{{0,0.01},{3,1.41422},{4,0.592575},{5,1.39419},{6,0.609274},{7,1.38408},{8,0.617834},{9,1.37852},{10,0.622578}}

Out[5]=

FindExtrema[sol]

In[6]:=

{n{{0,0.01},{3,1.41422},{4,0.592575},{5,1.39419},{6,0.609274},{7,1.38408},{8,0.617834},{9,1.37852},{10,0.622578}}}

Out[6]=

———

A List:

Needs["EcoEvo`"];

In[1]:=

list={{1,1.1},{2,2},{3,1},{4,2.1}};

In[2]:=

FindExtrema[list]

In[3]:=

{{1,1.1},{2,2},{3,1},{4,2.1}}

Out[3]=

FindExtrema[list,{2,3}]

In[4]:=

{{2,2},{3,1}}

Out[4]=

▪