Dynamical Systems and Chaos
Transcript
Hi everyone and welcome. In this video, I'll introduce some concepts in dynamical systems theory and chaos theory, and I'll demonstrate these concepts using several examples, mainly from ecology. This is a video for general audiences, and although the examples I have chosen will involve differential equations, I promise you'll be able to follow along whether calculus is in your future or your distant past, or even if you've never taken a calculus course. Instead of doing the math by hand, we'll use computer programs for the heavy lifting. If you want to experiment yourself, the source code for several of the examples is written in Python and is available on GitHub; just click the links in the description below. Finally, this video is based on a one-day class I taught through "Splash at Northwestern" earlier this year. Splash is dedicated to providing unique and fun learning opportunities to high school
students in the greater Chicago area, especially for students coming from underrepresented or disadvantaged backgrounds. If you want to know more about Splash, the link to their website is in the description below. Alright, let's get started. The goals for this video are to look at complexity and chaos, mainly in the context of ecology, and to see how math and computer programming can be used to understand how single-species and multi-species populations grow, shrink, and interact. Simplicity and complexity in systems and behaviors I like to think of complexity as a continuum, ranging from simple to complex. We can apply this continuum to various systems and also to the behaviors they demonstrate. For example, it isn't too surprising that there are some simple systems out there that behave in fairly simple, straightforward ways. It also isn't too surprising that some complex systems exhibit complex behavior.
What might be more interesting is that some remarkably complex systems demonstrate surprisingly simple behavior, and likewise, some simple systems demonstrate surprisingly complex behavior, including chaos. This last quadrant is where our focus will be for this video. Chaos exploded onto the pop culture scene in the 90s with Jurassic Park, first the book by Michael Crichton and then the movie by Steven Spielberg. How much the events in the story actually have to do with chaos theory is another story for another time, but thanks to Jeff Goldblum's portrayal of the mathematician Ian Malcolm, some awareness of chaos theory is now embedded in society's collective consciousness. The concept of chaos as the absence of rhythm also appears in Dune, where you have to walk without rhythm if you want to avoid attracting the attention of the sandworms.
Oh and a reference to this also appears in the song "Weapon of Choice" by Fatboy Slim. Let's leave pop culture behind and talk about chaos in reality, or more precisely, chaos as it is defined in dynamical systems theory, which is a branch of mathematics that studies how the state of a system can evolve over time. One important thing to point out right away is that chaos isn't randomness. Instead, one of the really cool things about chaos is that it can appear in systems that are completely deterministic, where perfect knowledge of the current state and the laws that govern the system means, in theory, that we can perfectly predict how the state of the system will evolve over time. Another characteristic of chaos is the absence of rhythm, or in mathematical terms, aperiodicity, which is the absence of any discernible period. One of the most important characteristics of chaos is that it represents extreme sensitivity to initial conditions.
This means that, even if you have a perfectly deterministic system, if it's chaotic, then a tiny amount of uncertainty in your measurement of the system's current state will make it extremely difficult to predict how the state will evolve over time. However, there are certain conditions that have to exist for chaos to appear, so not all systems can exhibit chaos. For that same reason, systems that are capable of chaotic behavior don't always behave chaotically. Instead, chaotic behavior only appears when conditions are right. There's a nice quote that applies to all of this: "Making predictions is difficult, especially about the future." Said another way, chaos is "when the present determines the future, but the approximate present does not approximately determine the future." The man who said that is Edward Lorenz, one of the early pioneers of chaos theory. We'll come back to him near the end of the video.
We're now ready to look at chaos in greater detail. The roadmap for the rest of this video is as follows: First, we'll go over some foundations, using Python to solve differential equations and then applying this idea to simulate exponential growth of a population of a single species. Second, we'll modify our model of growth to account for the environment's carrying capacity, resulting in a model of logistic growth for our species. Next, we'll add a second species that preys on the first species, and we'll experiment with this predator-prey model a bit. Then, things will get a lot more interesting when we add a third species to our model. We'll look at a couple different ways these three species can interact and the chaos that can result. All the examples so far are drawn from mathematical ecology, but no discussion of chaos is complete
without mentioning the Butterfly Effect, so we'll do just that in our final example which will be a simple weather model. Chaos is an aspect of dynamical systems theory, and dynamical systems are often represented as differential equations, in which the state and its derivatives appear together. That's the representation we'll use in this video. If you haven't taken calculus or if you don't remember what a derivative is, don't worry because we're going to go over that now. Let's say we have some variable x, which is the state of our system, and let's suppose that it varies with time. For example, x could be the population of some species in an environment. The derivative dx/dt represents the rate of change of the state x with respect to time t, or in other words, how quickly the state is changing at time t. If we know the state at time t and the state at some time t plus delta t in the future,
we can approximate the derivative as the change in state divided by the change in time. As the time difference shrinks to zero, our approximation approaches the true rate of change of x at time t. Suppose we know the true value of the derivative dx/dt, and also suppose the timestep Delta t is small but not zero. As long as the timestep is small, we can rearrange the equation onscreen to approximate the future state x of t plus Delta t, by multiplying dx/dt by the timestep Delta t and adding this result to the current state x. When working with differential equations, as one does when studying dynamical systems, we have some function f that maps the current state x to the current derivative dx/dt, so we can plug f into the equation onscreen and use it to predict the state x at some time in the near future. We can then feed that prediction into the same equation and predict a little further ahead, and so on and so forth, over some time horizon.
This iterative process allows us to numerically solve—or simulate—differential equations even when the equations are challenging enough to prevent us from solving them analytically. There are much more sophisticated algorithms for doing this than the one I just described, but they all follow the same basic idea. Let's put this simulation technique to use. We'll use it to simulate exponential growth of some population. Thanks to the COVID-19 pandemic, exponential growth has been on everyone's minds a lot lately, so you probably already have some intuition to guide you through this example. In exponential growth, the rate of change of the population, dx/dt, is proportional to the current population x. The constant of proportionality, denoted by c, represents how aggressively the population grows. I promise this is the last mention of COVID-19, but if you compare the original strain of
the virus to the Delta variant and then the Omicron variant, you could say this constant of proportionality was bigger for Delta than the original strain, and bigger still for Omicron. Finally, all the recommended public health practices, including getting vaccinated, wearing a mask, and practicing social distancing, these are all tools for making this growth parameter c smaller and smaller. But rather than keep talking about viruses, let's imagine a more benign species for this example. How about rabbits? We want to predict how big the rabbit population will be some time in the future, given an initial population x-nought and the growth parameter c. To predict the population some small time Delta t in the future, we'll multiply the current rate of change of the population by Delta t and add this result to the current population. We can repeat this process over and over, stepping forward in time a little bit with each iteration.
Now let's write a short Python script to do this simulation for us. First, we define our model. Then, we specify the initial rabbit population. After setting up a list of times at which we'd like to predict the rabbit population, we iterate through this list, using our algorithm to predict the population at each time in the list. For this simple model, there's an analytical solution for the population as a function of time, so we'll also compute that at each timestep so we can evaluate our numerical solution. We can run our simulation for a variety of timestep sizes, and we see that as the timestep gets smaller, our numerical solution (the blue curve) approaches the true analytical solution (the red curve). If you want to play around with this example yourself, the code is available on GitHub through a link in the description below. Now, in reality, exponential growth can't continue forever.
The environment can only support a finite population, called a carrying capacity. Let's use the letter k to denote the carrying capacity. Another way to think about the carrying capacity is that once the population gets big enough, everyone's competing for resources, and this slows down the rate at which everyone can reproduce. This competition for resources results in something called logistic growth, modeled by the equation on the right, where growth starts off fast but slows down as the population x approaches the carrying capacity k. Even with simulation, though, we can ask a couple questions about this mathematical model. First, what is the limit of the growth rate as the population approaches the carrying capacity? Well, it's going be 0, because as x approaches k, the term inside the parentheses approaches zero.
In other words, the population curve flattens out as the population approaches the carrying capacity asymptotically. Second, what does the population growth look like at really low populations, far away from the carrying capacity? Well in this limit, the term inside the parentheses is close to 1, so the growth looks exponential when the population is much smaller than the carrying capacity. Again, you can play around with this code on GitHub if you want to experiment further. Let's increase the complexity of our model just a little bit, by adding a second species. We'll keep the logistic growth model for our rabbit population, denoted by x1, but we'll add a predator species, let's say foxes, with its own population denoted by x2. Foxes prey on rabbits, so the two populations will be coupled. The number of inter-species encounters depends on both populations, and we can represent this by the product of the two populations, x1 times x2.
These inter-species interactions will hurt the rabbit population growth rate by some amount, and they'll help the fox population growth rate by some other amount. Also, without rabbits to eat, the fox population will decay exponentially, either through starvation, or if you prefer to think of it differently, through migration as the foxes migrate to an environment with more food. Now let's simulate this predator-prey model. Once again, the code for this model is available on GitHub. In this animation, I'm steadily increasing the carrying capacity and plotting steady-state behavior of the rabbit and fox populations, long after any initial transient effects have faded away. On the left, I'm plotting both populations versus time. At low carrying capacities, the predator and prey populations settle down to constant levels. However, as the carrying capacity gets bigger, the populations begin to oscillate.
Let's start with the rabbit population: when the carrying capacity is large, the rabbit population grows rapidly, supporting an increasingly large fox population. Once the fox population is big enough, predation drives the rabbit population back down rapidly. As this happens, there is less food available to sustain the fox population, so it also declines. Once the fox population is small enough, the rabbit population begins to recover, and the cycle repeats. If you look at the pair of differential equations above that model the predator-prey dynamics, you can see that the time t never appears anywhere explicitly. This means we can plot one population directly against the other, in phase space, and that's shown on the right. Phase space is a general-purpose concept in dynamics, where each dimension corresponds to an element of the system's state. In this two-species example, the phase space is two-dimensional, with one dimension corresponding
to the rabbit population and the other dimension corresponding to the fox population. Plots in phase space are called phase plots, and they're very useful when studying dynamical systems because they reveal more of the structure in the system than can be seen with time-series plots. In this example, when both populations stabilize to constant levels, the phase plot shows a single point. However, once the two populations oscillate, the phase plot shows an orbit, and the amplitude of this orbit grows as the carrying capacity increases. There's a name for this orbit: it's called a limit cycle. In fact, limit cycles are known to exist for a special class of predator-prey models called Lotka-Volterra predator-prey models, where the carrying capacity is large enough that its effects can be ignored. Soon, we're going to add a third species to our model, but before we do, I want to return to our earlier discussion of complexity, where we considered varying degrees of complexity
in systems and in the behavior they demonstrate. We can place our basic two-species food chain somewhere in the bottom left quadrant. When we add a third species, our system becomes a bit more complex, as the dimensionality of its phase space jumps from two to three. This tells us that our three-species system will be located a bit to the right of our two-species system on this two-axis graph. When we add a third species, we have more options for how the three species interact, compared to the basic two-species system. For example, we can have a food chain, where the top species preys on the middle species, which in turn preys on the bottom species. Alternatively, we could have a food web, where each species interacts directly with each other species. We'll see two different food web examples soon. In general, though, the small increase in system complexity from adding a third species can lead to a disproportionately large increase in behavioral complexity.
This puts our 3-species system up here, in the top left quadrant. In fact, adding a third species can be enough to cause chaos, in the mathematical sense we talked about earlier. There's even something called the Poincaré-Bendixson theorem that describes this phenomenon. I'll provide an intuitive description of this theorem without going into the math. Think of it this way: if you start scribbling some arbitrary curve in a region of 2D space, eventually you'll have to cross over some part of the curve you drew earlier. As soon as you do this, you're revisiting a point in 2D space you visited before, and that's the exact definition of periodic behavior. However, if instead you're scribbling in a region of 3D space, you can scribble forever without crossing over an existing line. Scribbling forever, in some finite region, without crossing over an existing line - this is an intuitive definition of chaos.
So, the Poincaré-Bendixson theorem implies that, in order for a system to demonstrate chaotic behavior, its phase space must have three or more dimensions. Connecting this back to our food web models, the food web has to have three or more species for chaos to arise. One example of a three-species food web involves an omnivorous apex predator. This species is at the top of the food web, and it preys on both the middle species and the bottom species. The middle species also preys on the bottom species. This example comes from a 2005 Ecology paper by Tanabe and Namba, and there's a link to it in the description if you want to read more. One example of omnivory is a food web consisting of great blue herons, who like to eat fish, including carp. Carp, in turn, will eat insects such as dragonflies. Great blue herons will eat just about anything they can, including dragonflies.
So, we have a three-species food web consisting of herons, carp, and dragonflies. I'm simulating this food web and plotting the solution in three-dimensional phase space on the left; I'll get to the right-hand plot in just a second. I'm also treating the rate at which the top species preys on the bottom species as a "knob" that I can turn up or down, to see the effect of omnivory on the food web's behavior. At low top-versus-bottom predation rates, the three species' populations eventually converge to stable levels, indicated by a single point in phase space. However, once this predation rate is big enough, the populations start to fluctuate, and, in phase space, the point becomes an orbit or, in other words, a limit cycle. You might be wondering why there's a pink rectangle in the phase plot on the left. This pink rectangle has a name - it's called a Poincaré section, and it's another useful tool for studying a wide variety of dynamical systems, from food webs to legged robots.
I'm using this Poincaré section to take a snapshot of the population levels every time the system completes another orbit through phase space. When the orbit passes through my Poincaré section, I plot the population of one of the species, in this case the apex predator (the heron). This helps me keep track of qualitative changes in the behavior of the food web. One such qualitative change happens when the top-versus-bottom predation rate reaches about 6.3. Where it previously took one orbit for the population levels to repeat themselves, it now takes two. Since the period has doubled, from one to two, this change is called a period-doubling bifurcation. You can also see this change on the right-hand plot, where the curve has branched in two. Now, as I bump the predation rate a bit higher, another period-doubling bifurcation occurs, and it now takes four orbits for the population levels to repeat themselves.
As the predation rate climbs, these period-doubling bifurcations cascade, one after another, in increasingly rapid succession, until the food web is in chaos. In fact, this phenomenon is called the "period-doubling route to chaos" and is a nearly-universal feature of chaotic systems. Let's see if we can uncover this period-doubling route to chaos in another food web. We looked at omnivory last time, so let's look at a different type of interaction this time. How about scavenging? In this food web, a scavenger species hunts the prey species, and it also feeds on dead members of the predator species, but it doesn't kill them, it just waits for them to die off. One example of this could be a food web consisting of hyenas, lions, and wildebeest. This example comes from a 2013 review paper by Previte and Hoffman, and there's a link to it in the description if you want to read more. The setup for this example is pretty much the same as last time.
In this example, I'm varying the rate at which the scavenger population dies off. I'm plotting the steady-state behavior of the food web in phase space on the left, and the pink rectangle represents my Poincaré section. On the right, as with the previous example, I'm plotting the predator population every time the orbit passes through the Poincaré section. At low scavenger die-off rates, the population levels are stable. As the scavenger die-off rate goes up a bit, the population levels oscillate. Once the scavenger die-off rate climbs above about 5, the food web begins the period-doubling route to chaos, much like we saw in the previous example of omnivory. Chaos is in full swing once the scavenger die-off rate is around 11. Interestingly, there follows a brief window of order, but then chaos resumes at a die-off rate around 12.
However, what happens next is even more interesting: as the scavenger die-off rate climbs higher and higher, the system undergoes a cascade of period-halving bifurcations leading away from chaos back to order, culminating in stable population levels once the scavenger die-off rate is around 17 or higher. What can we take away from everything we've learned about chaos so far? The first takeaway is that, given the interpretation of chaos as extreme sensitivity to initial conditions, we have to be careful when forecasting far into the future, given that all measurements have some degree of uncertainty. Weather forecasts are a perfect example of this unpredictability. Meteorologists mitigate this uncertainty using ensemble forecasting, in which a distribution of initial conditions issimulated forward in time. The extent to which these points spread out over the course of simulation provides some
idea of the range of possible outcomes, as well as some idea of which outcomes are most likely. The second takeaway is that these mathematical models are useful tools for systematically examining the effects of modifications to various food webs, including modifications we, as humans, are causing. From both a practical standpoint and an ethical standpoint, performing controlled ecological experiments is very difficult, so mathematical modeling and simulation can help us as we work towards responsible ecological stewardship. Here are a couple examples where modeling and simulation could help: Recently, there has been interest in using CRISPR to introduce a gene for sterility into mosquito populations, in an attempt to fight mosquito-borne diseases like malaria, zika and dengue fever. From a public health perspective, this might seem promising, but there are additional ecological
considerations, one of which is that mosquitos are pollinators for a variety of plants, and plants are the foundation of most food webs, so inducing sterility in certain mosquito populations could have long-term ecological repercussions. Here's a second example: in the Florida Everglades, invasive Burmese pythons are threatening native mammal and bird populations. However, Currylow et al. recently observed that the native bobcat population seems to be developing a taste for python, and they hope this could restore balance to the Everglades ecosystem. That about wraps it up for our discussion of mathematical ecology. At the beginning of this video, I promised we'd talk about the Butterfly Effect, and now it's time to do just that. We've actually seen the Butterfly Effect already in this video. It's just a nickname for extreme sensitivity to initial conditions, one of the hallmarks of chaos.
The name comes from a rhetorical question: "Does the flap of a butterfly's wings in Brazil set off a tornado in Texas?" This was the title of a talk about chaos given by Edward Lorenz, a meteorologist and mathematician who discovered chaotic behavior in a simplified weather model, in which the atmosphere is represented as a thin layer of fluid that is heated from below and cooled from above. This model produces trajectories that eventually orbit chaotically around a strange attractor which, coincidentally, looks kind of like the wings of a butterfly. In case you want to experiment with Lorenz's model, the code for producing this animation is available on GitHub. I'll close by reiterating Lorenz's description of chaos: "when the present determines the future, but the approxi mate present does not approximately determine the future." Let's recap what we did in this video. We modeled different kinds of inter-species interaction with differential equations, and
we used Python to simulate these models. We saw the importance of each species to its food web, including prey, predators, omnivores, and scavengers. We also saw that, at least under certain conditions, chaos can arise in food webs consisting of three or more species, demonstrating that, indeed, some simple systems are capable of surprisingly complex behavior. We also discussed some of the implications of all this as it relates to uncertainty mitigation and to responsible stewardship. I hope this video has helped feed your curiosity about applying math and programming to dynamical systems and real world problems. If you'd like to learn more, feel free to check out the links to publications and code in the description below. Thanks for watching!

Ask anything
We've read this whole study set, so questions about it get the best answers.