# Math Insight

### From discrete dynamical systems to continuous dynamical systems

#### Introduction

From discrete dynamical systems to continuous dynamical systems.

One basic type of dynamical system is a discrete dynamical system, where the state variables evolve in discrete time steps. We used discrete dynamical systems to model population growth, from simple exponential growth of bacteria to more complicated models, such as logistic growth and harvesting populations.

#### Sometime discrete time isn't a good description

For some applications, though, the evolution in discrete time might not be the best description of the phenomena. For example, we modeled bacteria growth with a time step of 16 minutes. The 16 minute interval was chosen based on the interval between experimental measurements; it didn't reflect any time scale from the dynamics of the bacteria population. The bacteria didn't coordinate and all divide in half every 16 minutes. Instead, with a large bacteria population, bacteria were dividing essentially continuously in time, with different bacteria dividing at different times. The population size was increasing continuously in time rather than jumping up every 16 minutes. Maybe we could improve our model by allowing the dynamical variables to evolve continuously in time.

We modeled the bacteria growth using a logistic model of the form \begin{align} x_{n+1}-x_n = r \,x_n (1-x_n). \label{discrete_model} \end{align} For simplicity, we've set the carrying capacity to one. With this notation, $x_n$ is the bacteria population in time step $n$, i.e., the $n$th 16-minute time interval. If we write this model in function iteration form, it is $x_{n+1}=f(x_n)$ where $f(x)=x+rx(1-x)$. Although this wasn't even close to the parameters we found for the bacteria data, let's set $r=2.4$. You can look at the evolution of the model by typing in $x+2.4x(1-x)$ in the function iteration applet. Set the initial condition to $x_0=0.01$. You should see that the population, for large enough $n$, oscillates between values of about 0.64 and 1.19.

Function iteration. The effect of repeatedly applying the function $f(x)$ to the starting value $x_0$ is shown both by the list at the right and the graph at the left. At first, only the initial value $x_0$ is shown in the list and just the point $(0,x_0)$ is shown on the graph. (In the list heading, $x_n$ is written as x_n.) Each time you click the “iterate” button, the function is iterated by applying $f$ to the previous value, using the recursion $x_n = f(x_{n-1})$. Then, the new iterate $x_n$ appears in the list and the new point $(n,x_n)$ appears on the graph. Note that the iteration number $n$ is plotted on the horizontal axis (what you may normally think of as the $x$-axis), and the values of $x_{n}$ are plotted on the vertical axis (what you may normally think of as the $y$-axis). The values of each $x_{n}$ are also marked with horizontal lines and the last value $x_{n}$ is labeled. You can change the function $f(x)$ by typing a new function in the box. You can change the initial point $x_0$ by typing a new value in the box or dragging the blue point. You can zoom the vertical axis with the + and - buttons and pan up and down with the buttons labeled by arrows.

#### Moving to continuous time

As a first step to moving away from the 16-minute interval restriction, let's change the notation of our model. First, let $t$ denote time in minutes so that $t= 16n$. Then, rather than denoting the variables as $x_n$ for population size at time step $n$, we'll denote them as $x(t)$ for population size at time $t$. We can rewrite equation \eqref{discrete_model} as \begin{align} x(t+16)-x(t) = 2.4 \,x(t) (1-x(t)) \end{align} since increasing $n$ by one time step is the same as increasing $t$ by 16 minutes.

This change in notation helps us see what we could do if we wanted to come up with a different model for the population growth in, say, 8 minute intervals rather than 16 minute intervals. Although we don't expect the model to be exactly the same, we might say that if the change in 16 minutes is $2.4 \,x(t) (1-x(t))$, then the change in 8 minutes might be half that quantity, or something like $1.2 x(t) (1-x(t))$. It wouldn't be completely crazy to think of a model for eight minute intervals of the form \begin{align*} x(t+8)-x(t) =1.2x(t) (1-x(t)). \end{align*} While we're at it, we could postulate a model for four minute intervals by dividing the change in half again: \begin{align*} x(t+4)-x(t) = 0.6 x(t) (1-x(t)). \end{align*} By continuing in this path, we could have a whole series of models, by continuing to divide the time interval and the change in half: \begin{align*} x(t+2)-x(t) &= 0.3 x(t) (1-x(t))\\ x(t+1)-x(t) &= 0.15 x(t) (1-x(t))\\ x(t+0.5)-x(t) &= 0.075 x(t) (1-x(t)) \end{align*} At this point, we don't really have any reason to believe these models might have similar behavior. Instead of doing any complicated mathematical analysis to figure out what to expect, let's just experiment to see what happens.

To do this experimentation easily, we should first rewrite these models into the same form with a parameter $\Delta t$ for the time interval. Then, the change in population size in one time step is $x(t+\Delta t)-x(t)$, where $\Delta t$ is 16, 8, 4, 2, 1 or 0.5 minutes. Since the change for $\Delta t=1$ is $0.15 x(t) (1-x(t))$ and doubling $\Delta t$ just doubles the change, we can write all the above equations as \begin{align*} x(t+\Delta t)-x(t) &= \Delta t \, 0.15 x(t) (1-x(t)) \end{align*} or, dividing by $\Delta t$, as \begin{align} \frac{x(t+\Delta t)-x(t)}{\Delta t} &= 0.15 x(t) (1-x(t)) \label{model_deltat}\tag{3} \end{align}

The following applet will allow you to explore the behavior of these different models. The first step is to reproduce the result you got with the above function iteration applet and $\Delta t = 16$. Set the initial condition to $x(0)=0.01$ and type in $0.15 x(1-x)$ for the function. When $\Delta t = 16$, you should get exactly the same numbers as you did above using $x_{n+1}-x_{n} = 2.4x_n(1-x_n)$. The only difference is that the time will be in minutes rather than number of 16-minute time steps. You'll need to click the -h button a number of times to zoom out the horizontal axis to larger times.

From function iteration to continuous evolution. The evolution of the difference equation $x(t+\Delta t) - x(t) = \Delta t \, g(x(t))$ at discrete time steps of length $\Delta t$ is illustrated by a plot of $x(t)$ versus $t$ as well as in a list on the right. The format is nearly identical to the function iteration applet with $f(x) = x+\Delta t \, g(x)$. Clicking the “iterate” button calculates a value of $x(t+\Delta t)$ for the next time step $t+\Delta t$. The “refine” button cuts the time step $\Delta t$ in half and doubles the number of time points so that the same final value $x(t)$ is calculated with smaller time steps. You can also adjust $\Delta t$ independently by typing a value in its box. The function $g(x(t))$ is specified by entering a value in the box; however, for the applet to work, one must type the variables as $x$ rather than $x(t)$. When the “details” box is unchecked, the points and lines indicating the values of $x(t)$ at the discrete points disappear, revealing just a plot of the function $x(t)$. When $\Delta t$ is small, $x(t)$ approximates the solution to the differential equation $\diff{x}{t} = g(x)$. You can zoom the horizontal axis with the +h and -h buttons and the vertical axis with the +v and -v buttons. You can pan up and down with the buttons labeled by arrows.

Once you have performed this sanity check, it's time to see what happens if you decrease the time step $\Delta t$. You could type in a new value of $\Delta t$, say $\Delta t=8$, and then click the iterate button a bunch more times to bring you back to the same time values. Or, you can just click the “refine” button once to do this for you automatically. Clicking this button halves the time step $\Delta t$ and doubles the number of time points so that the solution is still calculated to the same final time point $t$. What do you observe? Is the solution $x(t)$ calculated at intervals $\Delta t=8$ more or less the same as the solution calculated at intervals $\Delta t= 16$? If it looks any different, describe those difference.

Continue this process by refining the time step $\Delta t$ to smaller and smaller values. Since this process makes the number of time steps get quite large, you may want to uncheck the “details” box so you can see the solution $x(t)$ without other points and lines cluttering it. Describe what changes you observe as you decrease $\Delta t$ from 16 down to 0.5. The “refine” button disappears if clicking it would create more than 1000 points, so will disappear before you get down to $\Delta = 0.5$ if you went past $t=500$. If that happens, either change $\Delta t$ to smaller values by hand or click “reset” to start over. (If you reset, you'll probably want to increase $\Delta t$ to something larger like 16 so you don't have to click “iterate” a gagillion times.)

#### The limit

If all went correctly, you should have found that, once $\Delta t$ is sufficiently small, making it even smaller didn't change the solution $x(t)$ much. These experiments should make it seem plausible that one could keep making $\Delta t$ closer and closer to zero, and the solution $x(t)$ would get closer and closer to some limiting value. What equation do we end up with if we take the limit as $\Delta \to 0$?

The form of the left hand side of equation \eqref{model_deltat} should look vaguely familiar. If we take the limit of that left hand side as we let $\Delta t \to 0$, what do we get? We get the derivative: \begin{align*} \lim_{\Delta t \to 0} \frac{x(t+\Delta t)-x(t)}{\Delta t} = \diff{x}{t}. \end{align*} In this limit, the difference equation \eqref{model_deltat} becomes the differential equation \begin{align} \diff{x}{t} = 0.15 x(t) (1-x(t)). \label{continuous_model}\tag{4} \end{align} This differential equation is a continuous dynamical system. Like the discrete dynamical system of equation \eqref{discrete_model}, it describes the evolution of the population size. The differential equation, though, describes continuous evolution in time; at every instant in time, the population size $x(t)$ will change a little bit according to the value of $\diff{x}{t}$.

Now, unfortunately, just like we couldn't come up with a nice formula for the solution to the difference equation $x_{n+1}-x_n = 2.4x_n(1-x_n)$, we also can't up with a nice formula for the solution to the differential equation \eqref{continuous_model}. For the difference equation, we can easily calculate the solution anyway just by writing it in function iteration form and using a computer tool (like the function iteration applet) to spit out all the values of $x_n$. Can we do something similar to calculate the solution to the differential equation \eqref{continuous_model}?

In fact, one way that we explore the solution to a differential equation is to do exactly what you did above. We pick a small time step $\Delta t$, approximate the derivative by \begin{align*} \diff{x}{t} \approx \frac{x(t+\Delta t)-x(t)}{\Delta t} \end{align*} to convert the differential equation into a difference equation. Without knowing it, when you made $\Delta t$ small above, you were using a well-known method (called the forward Euler method) to approximate the solution to the differential equation.

The above applet, though, is a bit cumbersome, as it requires you to click the iterate button of times. The below applet automates this process a bit more. In this applet, you just enter the time step $\Delta t$, the initial time $t_0$ and the final time $t_f$. Then, the applet automatically computes the iterates from the difference equation \begin{align*} \frac{x(t+\Delta t)-x(t)}{\Delta t} = f(x(t)) \end{align*} to approximate the solution to \begin{align*} \diff{x}{t} = f(x(t)). \end{align*} Enter the differential equation \eqref{continuous_model} in the below applet and verify that you get the same results for the same time steps $\Delta t$ that you did in the above applet. In the below applet, you can check smaller $\Delta t$'s more easily, as it will compute up to 10,000 iterations.

Forward Euler approximation to an autonomous differential equation. An approximate solution to the differential equation $\diff{x}{t}=f(x(t))$ with initial condition $x(t_0)=x_0$ is calculated with the Forward Euler algorithm up to time $t=t_f$. With time step $\Delta t$, the solution $x(t)$ is computed by iterating $x(t+\Delta t) = x(t)+\Delta t \, f(x(t))$ and is plotted by the green line segments. Specify $f(x)$ by entering a function in the box. Enter values for $\Delta t$, $t_0$ and $t_f$ by entering values in their corresponding boxes. Since the number of iterations $n_{\text{iter}}=(t_f-t_0)/\Delta t$ is limited in this applet to be less than 10,000, $\Delta t$ is increased if the current values would lead to too many iterations. You can specify the initial condition $x(t_0)$ by moving the blue point or entering a value in the box. Clearing the “details” checkbox removes the points showing individual time steps, making the plot more readable for small $\Delta t$. You can zoom the vertical axis with the + and - buttons and pan up and down with the buttons labeled by arrows.

#### Solution to the continuous logistic equation

You are now equipped to analyze the solution to the continuous logistic equation \begin{align} \diff{x}{t} = r\, x(t) \left(1-\frac{x(t)}{M}\right). \label{continuous_logistic}\tag{5} \end{align} In fact, it turns out the behavior of this equation is even simpler than the discrete logistic equation. The carrying capacity $M$ functions exactly the same way. As you'll see, the low density growth rate $r$ will do just that: it will simply change how fast the population grows. Unlike in the discrete case, it won't cause funny things to happen if it gets large.

To investigate the behavior of the model, look at three different values of $r$, say $r=1$ as well as 10 times larger and smaller (i.e., $r=10$ and $r=0.1$). To verify that the carrying capacity does what you think it should, try two values, such as $M=10$ and $M=100$. For these six cases, explore their behavior in the above Euler method applet. For each case, make sure you choose $\Delta t$ small enough. To verify that that $\Delta t$ is small enough, cut $\Delta t$ in half and make sure the solution didn't change much. If it changed dramatically, then it wasn't small enough. Remember, we are supposed to approximate the limit when $\Delta t$ is arbitrarily small.

Answer the following question about the models.

1. What happens to $x(t)$ as $t$ gets large? How does this behavior depend on the initial condition $x(0)$? Do you get the same long term behavior for any value of the initial population size $x(0)$? Or do you get different behavior for different ranges of $x(0)$?
2. How long does it take $x(t)$ to get to this long term behavior. One way to answer this might be to examine, if you think that $x(t)$ should approach a value $c$, how long does it take $x(t)$ to get to that 90% of value if you start halfway there, i.e., with $x(0)=c/2$? How does this time depend on $r$ or $M$?
3. What value of $\Delta t$ did you need to choose so that it was small enough to give accurate results? Did this value depend on the parameters $r$ or $M$, or did it depend on the initial condition $x(0)$?
4. What happens to the estimate solution if you take too large of a time step $\Delta t$?

#### Summary of questions

To aid you in writing up a report on your results, we summarize the main questions posed above that you should be able to answer and added a few more questions.

1. Sometime discrete time isn't a good description

Show a graph of the solution to the discrete model $x_{n+1}-x_n = 2.4 x_n(1-x_n)$ with initial conditions $x_0=0.01$. Be sure to carefully label what your values on your time axis mean.

2. Moving to continuous time

1. How did your solution to model \eqref{model_deltat} with $\Delta t$ compare with the solution to the original discrete model?
2. When changing $\Delta t$ to 8, what do you observe? Is the solution $x(t)$ calculated at intervals $\Delta t=8$ more or less the same as the solution calculated at intervals $\Delta t= 16$? If it looks any different, describe those difference.
3. Describe what changes you observe as you decrease $\Delta t$ from 16 down to 0.5. Do the changes become more or less dramatic as you continue to decrease $\Delta t$ to smaller values? Can you predict what might happen if you decreased $\Delta t$ to even smaller values?
3. The limit

Does the transformation from the difference equation to the differential equation seem reasonable? Or does it seem to be a bunch of nonsense? Why or why not?

4. Solution to the continuous logistic equation

From using the Forward Euler algorithm to estimate the solution to the continuous logistic equation with $r=0.1$, $1$, and $10$ and $M=10$ and $100$, answer the following questions.

1. What happens to $x(t)$ as $t$ gets large? How does this behavior depend on the initial condition $x(0)$? Do you get the same long term behavior for any value of the initial population size $x(0)$? Or do you get different behavior for different ranges of $x(0)$?
2. How long does it take $x(t)$ to get to this long term behavior. One way to answer this might be to examine, if you think that $x(t)$ should approach a value $c$, how long does it take $x(t)$ to get to that 90% of value if you start halfway there, i.e., with $x(0)=c/2$? How does this time depend on $r$ or $M$?
3. What value of $\Delta t$ did you need to choose so that it was small enough to give accurate results? Did this value depend on the parameters $r$ or $M$, or did it depend on the initial condition $x(0)$?
4. What happens to the estimate solution if you take too large of a time step $\Delta t$?