MATH332 for Assignment 3

Graphical analysis; period doubling bifurcations

Based on the GraphicalAnalysis package by Thomas LoFaro

A (very) few things about Mathematica

2+3

<<"H:\.WIN2k_SETTINGS\DESKTOP\GraphicalAnalysis.m"

<<"~/Courses/MATH332/Notebooks/GraphicalAnalysis.m"

Now, just to get the feel of it, create and run a new cell, by clicking just below this sentence (which should create a horizontal line) and typing in 
"5*3^2<Enter>"

5*3^2

If a calculation is taking too long and you want to cancel it, press <Alt>. (on Windows). If it finishes but gives miles of useless output, you can delete it by clicking on the gray line immediately to the right of the cell and choosing Cut from the Edit menu (or pressing <Ctrl> X, in Windows), If you delete too much, you can choose "Undo" from the "Edit" menu. Try it:

2^1000000

Sin[Pi/4]

f[x_,a_] := a x(1-x)

f[0.2,1]

?ListIterates

Iteration

g[x_] := 3.3 x (1-x)

example1 = ListIterates[g[x], {x,.01}, Iterations -> 30]

This means that g[0.01]=0.03267, g[0.03267]=0.104289,etc.
Note that this list starts with round brackets and does not use commas, which means that ListIterates is actually returning a "nested list": a list with one element in it, which is itself a list with 20 elements in it! The inner list is accessed like this:

example1[[1]]

We can plot this list by using the built-in ListPlot function.

ListPlot[example1[[1]],AxesLabel->{"n","x[n]"},PlotStyle->PointSize[0.02`]]

The plot makes it easier to notice that the iterates seem to converge on a period-2 orbit.
Here are the same iterates plotted on a "cobweb diagram":

PlotIterates[g[x],{x,0,1},{.01}, Iterations->30]

You can also simultaneously generate cobweb diagrams for multiple initial conditions as in the following example.  Each trajectory is colored differently.

PlotIterates[g[x],{x,0,1},{.01,0.96}, Iterations->30]

PlotIterates[g[x],{x,0,1},{.01,0.96}, Iterations -> 100, Transients -> 50]

PlotIterates[g[x],{x,0,1},{.01,0.96}, Composition -> 2]

Plot[{x,g[x],g[g[x]]},{x,0,1}]

Work area for Part A:

Part B: Generating Bifurcation Diagrams

A bifurcation is a sudden qualitative change in behaviour when a function parameter is changed. A parameter is like a variable, but we call it a "parameter" when it's fixed or changes relatively seldom. Here is a function with two arguments, the second of which we will consider to be a parameter:

f[x_,a_] := a x (1-x)

Setting a=3.3 gives the function g from the earlier examples:

f[x,3.3]

For every value of a, we can study the dynamics of the resulting function. We can do this by hand, as in the previous section. The function Bifurcation from the GraphicalAnalysis package allows us to study the dynamics for many parameter values at once.

?Bifurcation

The method is crude: for every value of the parameter, pick one or more initial points, iterate for a long time (throwing away transients), and plot all of the resulting x values. In the plot below, the vertical axis is x, while the horizontal axis is a, the parameter.

Bifurcation[f[x,a],{x,0.1,0.4,0.5, 0.7, 0.8},{a,0,3.3}, Iterations -> 300, Transients->200, Slices-> 250]

Interpretation: for any a value up to 3, all four of the initial conditions converge to the same point, which we assume on this evidence to be a stable fixed point and the only one (see Caveat 2 below). The value of that fixed point slowly increases to around 0.65. For larger a values, all of the initial conditions converge to a period-2 point; actually, we can't tell from this one picture whether they're two fixed points or one period-2 point, but from our earlier analysis, we take this to be a stable period-2 orbit. 
Caveat 1: We're never going to find unstable periodic orbits this way, only stable ones.
Caveat 2: in general, for this method to give a general picture, we should examine lots of initial conditions. But the logistic map is simple enough that just one will usually do. As you examine the structure more closely, more iterations may be needed.

Work area for Part B: