## Section 3.6: Bifurcations - an aside - chaos and the logistic map.

Section 3.6: Bifurcations - an aside - chaos and the logistic map.

Let’s take a bit of a break from all of these bifurcations of first order differential equations and look at another situation where we get some very very interesting behaviour with fixed points. I’ve mentioned it briefly before, but let’s go into some more detail. We’re going to be looking at not a differential equation, but a difference equation. This one is called The Logistic Map:

P

n

P

n-1

P

n-1

We can think of this as a population on a given day (or week, or year, or whatever), and r is some sort of growth rate. It is related to the population at the previous time step. Let’s say =2, then if the population at time-step 0 is 0.2, then on the next time step, the population will be:

r

P

1

So the population has grown. How about the next time step?

P

2

We can write a little piece of code which calculates the population through time for a given initial population and value of

r

In[]:=

ClearAll["Global`*"]

In[]:=

(*Herepnisandpnm1is*)createplot[p0_,r_,timesteps_]:=Module[{},pn[pnm1_]=rpnm1(1-pnm1);populationlist=Partition[Riffle[Range[0,timesteps-1],NestList[pn,p0,timesteps]],2];ListPlot[populationlist,AxesLabel{Style["n",14],Style["",14]},JoinedTrue,MeshAll,PlotLabelStyle[" = "<>ToString[p0]<>", r = "<>ToString[r],16],PlotRangeAll]]createplot[0.2,2,10]

p

n

p

nm1

P

n

P

0

Out[]=

Let’s look at it with, a higher starting population:

In[]:=

createplot[0.8,2,10]

Out[]=

We see that starting at 0.8, the population first plummets, then it starts to go up again.

Exercise: Try and code this up yourself in Python.

If we start even higher, then something funky happens:

In[]:=

createplot[1.2,2,10]

Out[]=

This looks bad! We seem to end up with a negative population. Well, while this doesn’t make sense in terms of a population, it makes sense in terms of the equation. If we have a population greater than 1 at any time, then the next time step we will have a negative population, and once you have that, then the next will be negative and even larger magnitude, etc. So anything starting with a population of greater than 1 or less than 0 will end up flying off to -∞.

Let’s look at a range of starting values between 0 and 1:

In[]:=

Manipulate[Show[createplot[p0,2,10],PlotRange{-0.1,1.1},PlotLabel" = "<>ToString[p0]<>", r=2",AxesOrigin{0,0}],{{p0,0.8},0,1,0.1},SaveDefinitions->True]

P

0

Out[]=

P

1

We see that there are two fixed points here. One at 0, which is reached when you either start with =0, or =1, and another one. A fixed point is defined by = and so they can be found by solving:

P

0

P

0

P

n

P

n-1

P

n

P

n

P

n

Re-arranging this gives us:

P

n

P

n

r-1

r

which for the case of =2 gives 0 and 0.5. What happens as we decrease ?

r

r

In[]:=

Manipulate[Show[createplot[p0,1.5,10],PlotRange{-0.1,1.1},PlotLabel" = "<>ToString[p0]<>", r=1.5",AxesOrigin{0,0}],{{p0,0.8},0,1,0.1},SaveDefinitions->True]

P

0

Out[]=

The second fixed point seems to have moved down a bit. Let’s see what happens as we alter :

r

In[]:=

Manipulate[Show[createplot[p0,r,10],PlotRange{-0.1,1.1},PlotLabel" = "<>ToString[p0]<>", r = "<>ToString[r],AxesOrigin{0,0}],{{p0,0.8},0,1},{{r,1.5},0,2,0.1},SaveDefinitions->True]

P

0

Out[]=

How on Earth could we find anything interesting in the humble Logistic Map equation?

Something strange is about to happen...let’s do our plot, but this time for, say r=3.1 with a starting population of 0.5

This has four solutions:

Explore what happens if you start close to the true, but unstable fixed point.

ok, things are getting a bit complicated. We’re going to stick with an initial population of 0.5 from now on. Let’s write some code which outputs the late time behaviour...which will tell us which values it is bouncing between for a given value of r:

We can plot this now as a function of r:

So this says that for r less than 3, you will reach a fixed point and stay there, but for r>3 you will find two points that you jump between.

Does anything else happen if we increase r some more? Let’s look at the behaviour at r=3.5...

This going from one to two to four values that we jump between is known as period doubling.

What the!!!! Has something gone wrong with our program?

That seems pretty different...Let’s actually zoom into a region between 3.6 and 3.61...

The strange thing is that within this chaos we see an island of calm, between around 3.605 and 3.6065. And indeed within the chaos you will keep seeing islands of calm.

Exercise: Explore this with Python.

What has this got to do with the real world? Well, it turns out that it has a huuuge amount to do with the real world!

and this number appears all over nature in systems that become chaotic.

Mathemafrica: Mandelbrot set.

I’m going to leave you with this plot. See if you can figure out what’s going on. The red line is a line of gradient 1 through the origin:

OK, back to our study of first order differential equations.