Introduction for teachers
The logistic equation is a simple dynamical system that illustrates very nicely the emergence of complex chaotic behavior from a single, simple equation. This lesson plan is targeted towards high school students with a good grasp on the concepts of functions and graphing, and could serve as an entry-point into a larger unit on chaos theory and chaotic systems. Please be sure to check out some of the additional resources listed at the end of this lesson plan, and send all comments, questions, and suggestions to the author, Ben Weintraub, at benwei@u.washington.edu.
Getting the program
The Logistic Visualizer used in this lesson is a free Java program which you can run in your browser here, or download for offline use. Note that you must have Java installed in order to run it. On Macintosh computers, Java is installed by default. If you are using Windows or Linux, you may already have it installed, otherwise you can download it here.
The Logistic Visualizer was written using the Processing, toolkit, as a project for the Coastal Stories class. The source code is available for your perusal, modification, ridicule, etc.
Modelling populations
Consider the problem of a scientist studying a particular species and trying to predict how the population of this species will change. The scientist can make whatever measurements of the current population he or she wishes, and from these measurements mush attempt to determine the population at some time in the future. What types of measurements might this scientist be interested in making? Or, put another way, what are some of the factors that might affect the population of this particular species in the future?
As you might imagine, estimating population trends is not a simple task. Along with the factors you came up with above, consider the following:
- Current population
- Birth rate
- Predation
- Disease
- Death by old age
- Death by starvation
One way scientists have tried to approach and deal with this complexity is to break it down and deal with one part at a time, to understand the basics of what is going on first, and then add in all of the complicating factors.
Let's first look at a very simple model for population then. Consider a population of rabbits on an isolated island. In our simple model, the rabbits have an unlimited supply of food available to them, and never die due to old age, predation, disease, or other such factors. The population of rabbits on the island at some time t in the future depends only on the current population, and how far t is from the present. To keep things simple, let's say that we count the number of rabbits every year, and determine that the population of rabbits doubles every year. That is, population in year n+1 = 2 * (population in year n). Or, formally we could say:
Pn+1 = 2*Pn
Where Pn is the population in year n.
Examine the equation for the population growth of the rabbits on our imaginary island. How do you expect it to behave over a period of many years? How will changing the initial population (at n = 0) change the the behavior of the system?
Maps
You can think of the population of rabbits in our greatly simplified example as a one-dimensional map, that is, something which takes one input and maps onto one output. You can think of a map as similar to a function, like y = x2. It is one-dimensional because it takes one input and returns one output value. A two-dimensional map would take a pair of input values and return a pair on output values.
Feedback - positive and negative
The rabbit situation described above is an example of feedback, that is the output of a system feeding-back into it's input. In this case, the rabbits' current population is feeding back into the calculation of next-year's population.
The principle of feedback is simple, and one that we encounter in everyday life often. Think of the grating screeching sound you hear when someone puts a microphone too close to a speaker; this is a perfect example of positive feedback. The microphone picks up some small bit of background noise from the room, it gets amplified and played over the speaker, and then because of it's proximity to the speaker (the output of the system), the microphone (the input of the system) picks up the amplified sound, amplifies it again, and sends it to the speaker again, where it is played and picked up in a never-ending loop, creating a feedback loop that rapidly escalates out of control.
Both the rabbit example and the microphone example are instances of positive feedback. These systems involve feedback loops that cause the systems to grow quickly off to infinity. However, there are also systems that exhibit negative feedback, that is, they fall quickly to zero given a small push in the negative direction. Can you think of examples of such systems in everyday life?
The Logistic Equation
The logistic equation is an example of a system in which feedback produces some very complex and interesting results. It can be used as a simple population model as well. The equation is a one-dimensional map with an extra parameter, R, and is defined as follows:
Pn+1 = R * Pn * (1 - Pn)
Where Pn is the population after generation n. P varies between 0 and 1, and R can be anything, but the most interesting results are observed when it varies between 1 and 4.
Are there any parts of this equation that you expect to exhibit positive feedback on the overall behavior of the equation over time? Are there any parts you expect to exhibit negative feedback? What are they, and why?
The logistic equation can be thought of as a slightly more complex version of our rabbit-population model, which includes the concept of carrying capacity. The carrying capacity of an environment is the theoretical maximum number of organisms that environment can support at one time, due to constraints on food supply, organism density, or etc). Under this model, the population grows slowly at first, as there are few organisms to reproduce, and then more quickly as the number of organisms increases, and then levels off at the carrying capacity.
If you have not done so already, open the logistic visualizer program.
When you first launch the logistic visualizer, you should be presented with a window like this:
If you like, try playing with the program for about five minutes, to familiarize yourself with it's various options. In addition to clicking with the mouse, you can also access other functions of the program by using the space bar and the arrow keys.
Plotting the population over time
On the white area up top, find the vertical red line with the label 'R=...'. The position of this vertical line controls the value of the parameter R in the logistic equation. More about this later, but for now, click and drag the red line until you reach an R value of about 1.5 (it doesn't have to be exact).
On the bottom half of the program, note the red graph. This is a plot of the population over time, with population on the vertical axis, and time on the horizontal axis. To obtain this plot, we start the logistic equation with an initial population value (and the R value chosen in the previous paragraph), run it once, and save the output. Then we use this output as the input into the next step, and run the equation again. We keep doing this until we have a long enough sequence of numbers. Then we plot each number as a y value at some spot on the x-axis, and connect all of the lines between these dots.
To get a feel for what is going on in the graph, try plotting the first few numbers in this sequence. Write your exact R value below, and then fill out the following table.
R =
Generation (n) |
Pn |
Pn+1 |
|---|---|---|
| 0 | 0.01 | |
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 |
Look at the values in your table, and compare them to the first few points on the red graph on the bottom half on the program. Are they the same? Recall that the y-axis of this graph is ranging from 0 to 1. To create the graph you see, the program goes through almost exactly the same steps you did above, only much more quickly and many more times in a row.
Now press the space bar to save the current R value, and move the R control bar to R=1.6. Press space bar again to save again, and move to 1.7. Repeat this process at intervals of 0.1 until you reach R=2.0. You should end up with something that looks like this in the upper area of the graph.
Now look down at the lower half of the window. The plots of the population over time for all of the different values of R that you saved have been overlaid on each other, in different colors. Compare these various plots, using the colors of the marker lines on the top half of the program as your guide to which R value goes with which color, and explain below how the increasing R values affect the shape of the population curve.
When talking about the logistic equation, the variable R is often referred to as the growth rate or the biotic potential. Can you see why?
All of the curves you have saved are called S-Curves, because of their resemblance to the letter S. As mentioned previously, the population grows slowly at first, then more quickly as there are more organisms to reproduce, then levels off and remains stable at the environment's carrying capacity. Note how the vertical position of the final value that the population settles on corresponds to the vertical position of the black line in the upper diagram at that particular R value.
Changing the Initial Population
Press the
button on the bottom part of the program to clear the saved R values. Leave R at a value of about 2.0. Now find the slider on the left-hand side of the upper half of the program that looks like this
. You can move this slider by clicking and dragging with your right mouse button (or, on a Mac, by holding down the 'ctrl' key and dragging). The position of this slider controls the initial population in the model. Remember that our populations are all expressed as numbers between 0 and 1. The label to the right of the red line gives the current value of the initial population. Try moving it up and down. What effect does this have on the shape of the graph below? Does it change the final value that the population settles to (the carrying capacity)?
Stick a fork in it
When you are done playing with the population slider, set it back to 0.01 (again, doesn't need to be exact). Now move the R slider to the right again, until you get to about 2.9. What is happening in the graph below at this R value? What might be causing this behavior?
Continue moving the R slider to the right until you reach R = 3.0. You can use the right and left arrow keys to adjust the value of R by small increments. What happens on the lower graph at R=3.0? What does this correspond to in the diagram above?
Move the R slider farther to the right, to about 3.2. Notice on the upper diagram that the red line indicating our current R value now intersects the black lines in two places, corresponding to the two different values that the population oscillates between at this value of R. Continue moving the slider to the right until you reach an R value of about 3.45. What happens at this point on the red graph below? What does this correspond to on the upper half of the program?
Now move the slider to R=3.5. At this point, how many different values does the population graph below end up oscillating between? How many times does the red line of the R slider intersect the black diagram in the upper part of the program?
What is the next R where a similar situation as at 3.0 and 3.45 occurs?
The black diagram in the upper half of the window that we keep mentioning is known as a bifurcation diagram. The 'forks' in the diagram that occur at values like 3.0, 3.45, and the value you just found above are known as bifurcations. At each of these points, the number of values the that the population ends up oscillating between doubles, as each branch of the diagram splits in two.
Understanding the Bifurcation Diagram
Each column of pixels in the bifurcation diagram represents the behavior of the logistic equation at one particular value of R, that is, the x-axis corresponds to values of R ranging form 1 to 4. As on the graph below, the y-axis corresponds to values of P, the population ranging from 0 to 1. For each value of R (and each column of pixels), the darkness of each pixel in that column corresponds to how often the population of the system hits that particular population value at that particular R value. To get a better idea of what this all means, try this:
- Move the
Rslider back over to about 1.7. - Press the
button at the bottom of the program to animate the diagram. - Press the
button to stop the animation after a bit - Repeat for
Rvalues of 3.1, 3.5, and 3.56.
This animation explains how each column of the bifurcation diagram is generated. When you press the
button, the particular column corresponding to your currently selected R value is expanded to the right to make it easier to see what is going on, and then the logistic equation is run over and over again with your chosen R value, the output looping back into the input as discussed earlier. You can see this as it is being drawn on the graph below. Each time a particular population value is reached, a faint gray horizontal line is drawn both on the lower portion of the window, and on the upper right-hand portion, corresponding to that particular population value. If certain population values are hit multiple times, the lines layer upon one another and darken that particular region. Try animating at various other R values if you are interested.
On the edge of Chaos
By now you should have a good understanding of the bifurcation diagram and its relationship to the logistic equation. It all seems pretty rational and straightforward. But we've not yet explored this portion of the bifurcation diagram that looks like this:
That is, the interesting part.
Try moving the R slider around within this region. What do you observe in the population graph in the bottom half of the window. Are there discernible patterns in the population values, as there were for lower R values?
Note the
and
buttons near the bottom of the window. The
can be used to more closely examine a particular section of the bifurcation diagram and its corresponding plot on the population graph. The
will return you to the previous zoom level you were at. See if you can use the zoom tool to find areas that look similar to the following four, or other unique patterns of your own:
You will probably notice that these and other patterns keep recurring as you zoom in on different portions of the bifurcation diagram. This recurrence of patterns of the same patterns on different scales is an example of what is called self-similarity. The bifurcation diagram is actually an example of a fractal, and self-similarity is a property seen in all types of fractals, including the Mandelbrot set, and the Serpinski triangle, both shown below.
NOTE: You will notice that you can zoom in quite far before the quality of the diagram starts to degrade. This degradation is not a property of the actual bifurcation diagram, which theoretically would allow you to continue zooming in forever, like all fractals, discovering new details at each level. The degradation is a problem caused by the way the diagram is generated, and the fact that the program has a hard time handling very small numbers.
Mapping the effects of R
There seem to be several 'critical values' of R where the behavior of the resulting population model changes significantly (for instance, at 3.0, where the diagram first splits in two). Mark such values on a plot like the one below, noting next to each one what happens at it.
+----------+----------+----------+----------+----------+----------+ | | | | | | | 1 2 3 4
You may want to enlarge the portion of the plot between R=3 and R=4 using the
tool, as there are more such interesting points in this range of R. The area between about R=3.6 and R=4.0 is known as the chaotic region. If you look at the population graphs in this region, you can see why. For most values of R in this range, the population never settles to a steady point, or even to an oscillation between two or more points. Another way of saying this is to say that the function becomes aperiodic, that is, it never repeats itself, for these values of R. Note that we say most here instead of all. You've probably noted the white 'bands' where the graph settles out to a nice steady oscillation, then collapses into chaos again. These areas are where the logistic equation returns to a behavior of simple oscillation, and are sometimes called islands of stability.
Changes in input, changes in output
Remember this diagram?
How much is R changing by between each different saved value? How does this compare to the amount of change in the shape of the population graph? Does the change in input (value of R) appear to be proportional to the change in output (shape of the population graph)? That is, does a large change in input yield a large change in output, while a small change in input yields a small change in output?
Now press the
button, and then use the
tool to enlarge the region between R=3.6 and R=4.0. Choose an interesting value for R and press space bar to save the population graph. Now use the left and right arrow keys to adjust the value of R slowly. What happens to the population graph when you change the value of R slightly like this? Would you say that the change in output (shape of the population graph) is still proportional to the change in input? You can also try changing the initial population using the slider to the left (remember use the right-mouse button or hold down 'ctrl' on a Mac). Is the change in initial population proportional to the change in the resulting population graph?
Sensitivity to Initial conditions
As you probably determined above, very small changes in the value of R or the initial population can drastically affect the shape of the resulting population graph in the chaotic region. This is a property that is common to systems called chaotic systems, of which the logistic equation is an example, and is sometimes called sensitivity to initial conditions. Can you think of some examples of real-life systems that exhibit the property of sensitivity to initial conditions, where tiny changes in inputs can lead to large changes in outputs?
How does the property of sensitivity to initial conditions pose problems for scientists trying to model the behavior of chaotic natural systems by making measurements of the current state of the system, and then trying to extrapolate the state at some time in the future based on these measurements? (Consider the fact that measurements can never be exactly accurate.)
Chaos and randomness
It is important to understand the difference between a system that is chaotic, and a system that is random. Chaotic systems such as the logistic equation are not random in the usual sense of the word. That is, given any particular R value and any particular initial population, you can calculate exactly how the population will behave by just following the equation, and you will get the exact same result every time if you start with the same inputs. There's no chance to it at all, meaning the algorithm is called deterministic. However, it is unpredictable in the sense that if I am given the population graph for say R=3.6800 and asked to predict form that the population graph for R=3.6801 without actually carrying out the calculations of the logistic equation to build the graph, it is very difficult. Try this yourself with these or other adjacent values of R. It is easy enough in the non-chaotic region (where R < 3.5 or so), but once you get into the chaotic region, it becomes very nearly impossible, as the graphs quickly diverge.
Optional: Calculating Feigenbaum's Constant
Let us look more closely at our bifurcation diagram. Zoom in to a region of about R=2.9 to R=3.6, so your bifurcation diagram looks something like this:
Move the R slider to the spot where the first bifurcation (fork) occurs, at R=3.0. Press space bar to save this value. Now move to where the second bifurcation occurs and save it. Do this also for the third and fourth. Record the values in the table below.
| Bifurcation Number | R |
Distance from last bifurcation |
|---|---|---|
| 1 | 3.0 | N/A |
| 2 | ||
| 3 | ||
| 4 |
You should now have a series of three distances between bifurcations, call them D1 through D3. Is it possible to make a general rule about these distances? See if you can come up with a general rule that will allow you to calculate D2 from D1 or D3 from D2. If you're having trouble, try writing out the following ratios:
D2/D1 =
D3/D2 =
You should come up with a ratio that will allow you to calculate how far (in terms of change in R) the n+1th bifurcation will be from the nth. Test out this ratio by predicting where the 4th and 5th bifurcations will be, and then zooming in to check if you were right.
The ratio which you have just calculated is called Feigenbaum's Constant. If you were able to continue finding bifurcation points and calculating the ratios of the distances between them on to infinity, you would find that the ratio approaches 4.6692016...
Curiouser and curiouser
As it turns out, Feignbaum's Constant is exactly the same for all one-dimensional maps that approach chaos through bifurcation, like the logistic equation. For more on this, see the Additional Resources section below.
Additional Resources
Chaos: Making a New Science - James Gleik's excellent book on Chaos thery, written for the curious layperson. Gleik talks at length about the logistic equation, and gives some very interesting historical background into how it was discovered. Amazon Entry- An Introduction to Chaos [PDF] by David Harrison of the University of Toronto
- Mathworld Entry on the Logistic Map - A detailed examination of the logistic map from a mathematical standpoint.
- Mathworld Entry on the Feigenbaum Constant
- The Chaos Hypertextbook - An interesting approach to learning about Chaos Theory online
- List of Chaotic Maps on Wikipedia - This is an extensive list of chaotic maps like the logistic map. It includes maps of higher dimensions as well.
- Processing - The toolkit with which the Logistic Visualizer was written