Lab 4 - Chaos in Discrete Logistic Equation

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

The Discrete Logistic Equation and Chaos

One of the most intriguing topics in mathematical biology and dynamics


is chaos: erratic but fully deterministic behavior. Chaotic behavior cannot be
predicted in quantitative detail but its overall form can be known.
One of the simplest examples of chaotic behavior is a difference equation
called the discrete logistic equation: XN +1 = rXN (1 − XN ). This is similar to
the continuous-time logistic equation with k = 1, but makes some important
changes. In the discrete logistic model, time can only take on integer values:
0,1,2,... . Also, in this model, we assume that each generation dies off completely
and only their offspring survive to the next time unit. Population sizes in the
model range between 0 and 1. In this lab, we will use SageMath to explore the
discrete logistic model.

Exercise 1. Iterate f (X) = rX(1 − X) 20 times for r = 2.5, r = 3.1, r = 3.5


and r = 3.9, using the same initial condition each time. For each line, add
a comment explaining what it does. Plot each set of results and identify the
behavior of each time series as equilibrium behavior, oscillations (say between
how many) points, or chaos.
Exercise 2. Redo the previous problem using a for loop for the different r
values.

One of the hallmarks of chaos is sensitive dependence on initial conditions.


This means that time series starting very close together will eventually diverge
to the point of being completely uncorrelated.

1
Exercise 3. Iterate the discrete logistic 20 times for r = 3.9 and an initial
state of X = 0.4. Plot the time series. (You’ll probably want to use the option
plotjoined=True). Then, do the same thing using 0.401 for the initial state.
Overlay the plots and observe the relationship between the time series.
Exercise 4. Do the same thing for at least three more pairs of initial conditions,
using values of r between 3.7 and 4.0. What can you say about the relationship
between pairs of time series?

Exercise 5. Using a for loop, compute the absolute value of the difference
between the first 8 pairs of corresponding values for the simulation you ran in
Exercise 3. Plot the results and briefly describe what you see.

Order in chaos
We have now seen the unpredictability that gives chaotic behavior its name.
However, chaos is not randomness. If we look at chaotic data the right way, we
can see the order behind the unpredictability.

Exercise 6. Using the data you generated in Exercise 3 with an initial value of
0.4, plot Xt+1 against Xt . Briefly describe the resulting plot. HINT: What are
the indices of the entries that should go on the horizontal axis? On the vertical
axis?
Exercise 7. Plot f (X) = 3.9X(1 − X) for 0 ≤ X ≤ 1 and overlay this plot on
top of the one you made in the previous exercise. What do you observe? Why
does this result make sense?

Long-term behavior and bifurcation plots


Earlier in this course, we used bifurcation plots to look at how the equilibria of
a system changed as we varied a parameter. However, bifurcation plots don’t
have to just display equilibria – they can display any kind of long-term behavior.
For example, we might run a simulation, throw away the first 100 time steps (or
more, if necessary) and plot the rest. This shows us how the system’s behavior
varies with a parameter. Figure 1 is an example of this kind of bifurcation
diagram.
You will start by recreating this diagram. To begin, you’ll work with just
one value of r.
There are a couple of tricks for working with lists you’ll find helpful. First,
to make a list that repeats the same value many times, use *. For example,
50*[2] will make a list of 50 copies of the number 2. Second, you can use

2
x
1

0.8

0.6

0.4

0.2

0 r
2 2.5 3 3.5 4

Figure 1: The bifurcation diagram for the logistic equation.

indexing to get part of a list. For example, to show a list starting with item 20,
use listname[20:].

Exercise 8. For r = 3.5, iterate the logistic equation 250 times and make a
list of the results. Then, make a new list that excludes the first 100 values of
X. Using the new list, make a list of points (2-element lists) of the form (r, X).
(HINT: What function do you know that can do this?) Print the list. How
many different values of X do you see?

Exercise 9. In the previous exercise, why did we throw away the first 100
values?

Now you are ready to make the complete diagram.

3
Exercise 10. Recreate Figure 1. Your program will need to run the code you
developed in Exercise 8 for values of r ranging from 2.0 to 4.0 in steps of 0.01.
(Skip the printing step.) All (r, X) points should placed in a single master list,
which you can do by adding the lists. (You can literally use + to join lists end
to end.) Once the list is made, plot it. You may want to use the option size=1
to make the plot look nicer.
Exercise 11. Use your plot or Figure 1 to approximate the values of r that
produce chaotic behavior.
Exercise 12. Describe what this plot tells you about how the behavior of the
discrete logistic model changes as r increases. Compare your observations here
with your results from #1.

You might also like