Math 2325
Project 5 (Chapter 14) - Iteration of Quadratic Functions

Art Duval, Department of Mathematical Sciences, UTEP, El Paso TX 79968
artduval@math.utep.edu
11/212004, last edits 10/21/2008. 
Modifications by Helmut Knaust, hknaust@utep.edu, 10/28/2012, last edits 10/27/2022.

The Basic Program for Quadratic Iteration

The following program performs quadratic iteration, using the function f(x)=a x(1-x), much as the linear iteration program in Chapter 1 worked.  You must run this program before you do anything else in this notebook; everything else runs independently of one another.

IterQuad[a_,n_,x0_]:=NestList[Function[x,a x(1-x)],x0,n]

Here is an example, where a=1.5, the number of iterations n=50, and the initial value (Subscript[x, 0])=0.1.  Always set a to a number between 0 and 4, and (Subscript[x, 0]) to a value between 0 and 1.

IterQuad[1.5,50,.1]

Cobweb Diagrams

The following program will display a "cobweb" diagram for quadratic iteration, with the same inputs as IterQuad:

ItPoints[itlist_]:=Partition[Drop[Drop[Flatten[Transpose[{itlist,itlist,itlist,itlist}]],1],-1],2];
IterGraph[a_,n_,x0_,pr_:{0,1}]:=Show[ListPlot[ItPoints[IterQuad[a,n,x0]],Joined->True,PlotRange->{pr,pr}],Plot[{x,a x (1-x)},{x,0,1},PlotStyle->{{Red,Thick},{Green,Thick}}]]
IterGraphEnd[a_,n_,x0_,k_:16]:=Show[ListPlot[Drop[ItPoints[IterQuad[a,n,x0]],2(n-k)],Joined->True,PlotRange->{{0,1},{0,1}}],Plot[{x,a x (1-x)},{x,0,1},PlotStyle->{{Red,Thick},{Green,Thick}}]]

Here is an example, where  where a=2.6, the number of iterations n=20,and  the initial value (Subscript[x, 0])=.9.

IterGraph[2.6,20,.9]

You can change the viewing window by an optional fourth argument. The following command graphs the portion of the graph in the square [0.5,0.7]×[0.5,0.7].

IterGraph[2.6,20,.9,{.5,.7}]

The next command is similar to to IterGraph,but shows only the last sixteen points on the diagonal. Here is an example displaying an attractive 4-cycle (a=3.51):

IterGraphEnd[3.51,100,.9]

Confirming that this is an example displaying an attractive 4 - cycle:

IterQuad[3.51,100,.5]

The Take command with -5 in the end gives you the last 5 iteration values:

Take[IterQuad[3.51,100,.5],-5]

Feigenbaum Diagram

This program, which takes no input, will produce the Feigenbaum diagram. The Feigenbaum diagram only shows attractive fixed points and cycles.

FeigDiagram:=Module[{newones,allofthem={}},
Do[newones=Transpose[{Table[a,{100}],Take[IterQuad[a,200,.1],-100]}];
allofthem=Join[allofthem,newones],
{a,0,4,.015}];
ListPlot[allofthem,AxesLabel->{"a",None},ImageSize->500]];
FeigDiagram

Sensitive Dependence on Initial Conditions

The following program performs quadratic iteration, with a = 4 fixed, on two initial inputs, (Subscript[x, 1]) and (Subscript[x, 2]).  (To change a, simply replace both occurrences of "4" to whatever value you like.)

IterQuad2[n_,x1_,x2_]:=MatrixForm[Transpose[{Range[n+1],IterQuad[4,n,x1],IterQuad[4,n,x2]}]]

Here is an example where the number of iterations is n=25, and the two initial values are (Subscript[x, 1])= .1and(Subscript[x, 2]) = .1001.

IterQuad2[25,.1,.1001]

Chaos is not Random: Histograms

The following program will perform quadratic iteration (with a=4 fixed), and then report how many of the iterates are in different parts of the interval from 0 to 1. (To change a, simply replace the "4" to whatever value you like.)

RandomIter[n_,x0_,m_]:=Module[{i,iq=Drop[IterQuad[4,n,x0],1],b,b2},b=BinCounts[iq,{0,1+1/m,1/m}];b2=Join[Drop[b,-2],{b[[m]]+b[[m+1]]}];
Do[Print["The number of values between " ,(i-1)/m, " and ", i/m, " is ",b2[[i]]],
{i,m}]];

Here is an example where the number of iterations is n=1000, the initial value is (Subscript[x, 0])= .768,and the interval from 0 to 1 is being split up into sevenths.

RandomIter[1000,.768,7]

RandomIter[10,1/2,2]

The same information displayed as a histogram:

RandomIterH[n_,x0_,m_]:=Module[{i,iq=Drop[IterQuad[4,n,x0],1],b,b2},b=BinCounts[iq,{0,1+1/m,1/m}];b2=Join[Drop[b,-2],{b[[m]]+b[[m+1]]}];z=Table[Row[{"[",((i-1)/m),",",(i/m),")"}],{i,m}];z2=Join[Drop[z,-1],{Row[{"[",1-(1/m),",",1,"]"}]}];BarChart[b2,ChartLabels->z2,ImageSize->500]]

RandomIterH[1000,.769,7]