Vous êtes sur la page 1sur 3

Physics 7682 / Computing & Information Sciences 6229 - Fall 2012

INSTRUCTOR: ERICH MUELLER


MONDAYS & FRIDAYS 1:30-3:30, ROCKEFELLER B3 (DIRECTIONS)
http://www.physics.cornell.edu/~myers/teaching/ComputationalMethods/

NAVIGATIONAL LINKS:
C ourse W e b Site
C om pute r Ex e rcise s

RELATED EXERCISES:

Logistic Ma p

Chaos and Lyapunov


Exponents

Invariant Measures

Fractal Dimensions

Period Doubling Routes


to Chaos

FILES
Le cture on C ha os a nd
Lya punov Ex pone nts /
Inva ria nt Me a sure
P ython:
Logistic iteration hints
Logistic iteration answer and demo

LINKS

Background
We have five exercises on discrete maps. This one develops the main tools, and should be done
before the other four.
Often models of nature have a discrete deterministic structure. A classic example is in population
dynamics, where one hypothesises that the number of rabbits in year xn is simply a function of
the number in the previous year:

P ython na notutoria ls
Sta rting up a ne w P ython
proje ct unde r Linux
P ython se tup info
C ourse W e b P a ge
R obe rt M. Ma y,
"Sim ple m a the m a tica l
m ode ls with ve ry
com plica te d dyna m ics"
, Na ture 261, 459-467
(1976).

xn+1 = f(xn ).
If f(x) is linear one has the logistic equation, and the number of rabits grows exponentially. This
is a reasonable model if there are infite resources no preditors. The next most sophisticated model
would be to add a nonlinear term representing either the finite resources or the role of preditors.
This gives the logistic map

f(x) = 4x(1 x),


which is a map of the interval (0, 1) onto itself. There is one parameter , which will change the
behavior of the map. For example, at = 1, this function precisely folds the unit interval in half
and stretches it (nonuniformly) to cover the original domain. It turns out that this simple map
displays some complicated behavior.

Learning Goals
Science: You will learn about Chaos and discrete maps.
Com putation: You will learn about iterative algorithms.

Procedure

1. Create a new directory


2. Download Logistic iteration hints, and rename it IterateLogistic.py.
3. Open this file in a text editor (kate or emacs -- we recommend against using kedit) or
load it into the IPython dashboard (started with ipython notebook --pylab inline. In
this file, you will notice Python code that has already been written, but it mostly consists
of hints to help you flesh out the code, i.e., comments (lines that begin with #) and
documentation strings (material enclosed in triple quotes """ that document what each
module, class, and function is about and can be queried with the Python help()
function). You will also notice the keyword pass embedded within each function body:
pass is a legal Python expression that means "do nothing". The first thing you will do
when you start to define a function is to remove the pass statement and replace it with
new code.
4. Open a terminal window, move to the correct directory and start ipython, or click on the
notebook in the dashboard. You will find it convenient to start python with the --pylab
flag -- ie type ipython --pylab or ipython notebook --pylab.
5. define a function f(x,mu) which when called with

x and returns 4x(1 x).

6. Use pylab commands to plot f as a function of x for different values of mu.


7. Write a function Iterate(g, x0, N, mu) which is passed a function g, an initial point x0
and integer N and a parameter mu which returns g(g(...(g(x0,mu),mu)...). That is it
iterates the function N times, starting at x=x0.
8. Test this function with f. Are there any other functions you can write to test it more
easily?
9. Write a function IterateList(g, x0, N, mu) which acts just like iterate, but returns a
list of the sequential values of x. (A more verbose description is in the hints file.)
10. Play a bit with this function.
T y p e ylim((0,1)) then plot(IterateList(f,0.5,100,0.1)). This should
make a graph of the iterates of x, starting with x0=0.5, using mu=0.1. As
you can see, the bunnies don't do so well for small mu.
Try different values of mu. You should find that mu=0.25 is special. How does
the behavior of the iterates change when mu>0.25?
How does the behavior change when mu>0.75?
To explore this structure in more detail, see
Period Doubling Routes to Chaos
this structure can be compactly encoded in a "bifurcation diagram"
11. Write
a
function BifurcationDiagram(g,
showPlot) which takes as arguments:

x0,

nTransient,

nCycle,

muArray,

g -- a function
x0 -- the starting value for the iterates
nTransients -- an integer
nCycle -- another integer
muArray -- a list of mu values
showPlot -- True/False
For each value of mu in muArray, this function should iterate g, starting a x0. It throws
away the first nTransient iteratates. It then stores the next nCycle iterates. It then
makes a plot where the x-axis is the values of mu, and the y-axis are the values of x.
12. Try the following parameters:
BifurcationDiagram(f, 0.1, 500, 500, scipy.linspace(0., 1.00001, 200))
BifurcationDiagram(f, 0.1, 500, 500, scipy.linspace(0.85, 1.00001, 300))
BifurcationDiagram(f, 0.1, 500, 500, scipy.linspace(0.96, 0.97, 400))
13. To explore this structure in more detail see Fractal Dimensions
James P. Sethna, Christopher R. Myers, Erich J. Mueller.
L a s t mo d ifie d : Ju ly 2 0 1 2

St a t is t ica l Me ch a n ics : E n t ro p y, O rd e r P a ra me t e rs , a n d C o mp le xit y


, n o w a va ila b le a t
O xfo rd U n ive rs it y P re s s (U SA, E u ro p e ).

Vous aimerez peut-être aussi