The Logistic Map

Math 242 Modern Computational Mathematics

Define the logistic map

The logistic map is the recurrence (Subscript[x, n+1])=r (Subscript[x, n])(1-(Subscript[x, n])), where 0<=r<=4 is a parameter. For any starting value 0<=(Subscript[x, 0])<=1, this recurrence defines a sequence of real numbers (Subscript[x, 0]),(Subscript[x, 1]),(Subscript[x, 2]),….

Today we will explore logistic map trajectories for various parameters 0<=r<=4 and starting values 0<=(Subscript[x, 0])<=1.

To facilitate this exploration, first define (Subscript[f, r])(x)=r x(1-x). In Mathematica, we can do this using a double-indexed function, like this:

f[r_][x_]:=r*x(1-x)

This allows us to specify a value of r and obtain a function of x. For example, suppose r=0.8:

f[0.8][x]

Now we can choose a starting value 0<=(Subscript[x, 0])<=1 and iterate the f[r]. Let’s try (Subscript[x, 0])=0.4:

f[0.8][0.4]

f[0.8][0.192]

f[0.8][0.124109]

We could write a loop to make this easier. This is similar to our makeSeq function from last week.

x=0.4  (* initial value *)
Do[
x=f[0.8][x];  (* compute the next iterate *) 
Print[x],
10 (* number of times to repeat *)
]

Mathematica has a function NestList that makes this even easier. Specifically, NestList[f, (Subscript[x, 0]), m] produces a list of m iterates of the function f, starting at (Subscript[x, 0]). For example:

NestList[f[0.8],0.4,20]

Exploration

Choose your own value 0<=r<=4. Iterate (Subscript[f, r])(x) for various starting values 0<=(Subscript[x, 0])<=1.

What do you observe?

What do you wonder?

traj=NestList[f[0.8],0.4,30]

Plots

We can use a Manipulate environment to help us understand solutions to r x(1-x)=x for various parameters r.

Manipulate[Plot[                ,{x,0,1},PlotRange->{0,1}],{r,0,4}]

We can plot a trajectory on the diagram above, creating a cobweb plot.

The following module makes a cobweb plot. The usage is cobwebPlot[ function, starting value, number of iterates, xmin, xmax ], where xmin and xmax are optional parameters that specify the domain to be plotted.

cobwebPlot[f_,start_,numIter_,xmin_:0,xmax_:1]:=Module[
{cob={{start,0}},prev=start,next,g1,g2},

(* build the list of points to plot *)
Do[
next=f[prev];
AppendTo[               ];
AppendTo[               ];
prev=next,
numIter];

(* display the plot *)
g1=Graphics[{Purple,Opacity[0.3],Line[cob]}];
g2=Plot[{x,f[x]},{x,xmin,xmax},PlotStyle->{Blue,Black}];
Show[{g1,g2},Frame->True]
]

Now we can make a cobweb plot: