Dynamical Systems
Dynamical systems are powerful tools for simulating and modelling the real world.
Our goal in this lecture is to be able to model interesting real-world phenomena using a basic dynamical system.
Along the way we will learn some key mathematical concepts, terminology and notation.
Learning Outcomes
- Notate and interpret sequences in enumerated form
- Notate elements of sequences using indexes
- Define and recognise (monotonically) increasing and (monotonically) decreasing sequences
- Define boundedness and identify the upper and lower bounds of a sequence
- Define and recognise arithmetic sequences
- Define and recognise geometric sequences
- Use explicit functions to describe a sequence
- Use formulas in function iteration form to describe a sequence
- Find analytic solutions for simple recursively defined sequences
- Discuss how sequences and dynamical systems can be used to model real-world systems
- Use a spreadsheet to find the numerical solution to simple dynamical systems
Introduction
Mathematics can be used to model the real-world. A key property that many-real world systems exhibit is that they change over time. A dynamical system is any system where state of the system and perhaps even the rules that the system obeys (also called its dynamics) change as a function of time.
A pendulum at rest is not a dynamical system, as it does not change; however if you give it a push it will start swinging: the position and velocity of the pendulum will change over time. The pendulum is a dynamical system and the changes we observe are not random; they are governed by rules.
We can use dynamical systems to model complex, real-world systems that change over time and in response to a control signal. This is used in the design of aircraft, launching rockets into space, developing control software for robots and much more. In games, dynamical systems are used for physics simulations. The stock market, and the human brain are also dynamical systems. In addition, dynamical systems also gives us general tools to construct and explore systems with novel behaviour.
Overview
The mathematics that we are going to look at can be described as either sequences or dynamical systems.
We are going to start discussing the terminology of sequences and look at a number of basic examples.
Then we will talk about dynamical systems and suggest some of the more interesting uses of the same ideas. Here we are going to just scratch the surface of dynamical systems.
Terminology and Notation
A sequence is an ordered list of numbers. Note that we write sequences between braces { }. Confusingly, this is the same as how we notate sets. However, in a sequence we can have repeated elements. For example, consider the following sequence:
Here the variable \( a \) equals this particular sequence. We often need to refer to elements of sequences. To refer to the first element in the sequence \( a \) we would write \( a_1 \). The second element is \( a_2 \), and the \( n \)th element is \( a_n \).
Sequences can be finite (like the one above) or infinite. A sequence might represent a set of values that have been gathered from a real-world application -- a particular collection of arbitrary numbers -- or it might be purely theoretical and defined by a particular formula. For example, a sequence might contain:
- the closing price of a given stock for the last 365 days;
- the sum of the first \( n \) natural numbers, for increasing values of \( n \);
- the average yearly rainfall for the last 20 years.
Each of these sequences is useful. A stock market trading algorithm might use the former in developing a mathematical model of the movements of the stock and thus work out the best time to buy or sell. The sum of the natural numbers is a formula that is needed in various places in mathematics, such as simplifying summations. A climate scientist might want to find a formula fitting the last sequence to predict rainfall for future years.
Notating sequences
As with sets, we can take two approaches to notating sequences. We can write out each element, i.e. give an extensional definition. Obviously this only works when the number of elements is relatively small, e.g.
Here we can refer to each element of the sequence by using a subscript. For example, the first element of this sequence is
Sometimes sequences can be indexed from 1 and sometimes from 0. If we were indexing $a$ from 0, we would instead say that $a_0 = 1$. Mostly in this module we will be indexing sequences from 1. However, when working with dynamical systems that change over time, it is very common to index time starting from 0.
We will often talk about the $n+1$th element of a sequence. This is the element that comes after the $n$th element. It is notated as:
Be careful not to confuse \( a_{n+1} \) with \( a_{n}+1 \). While they look very similar, the former is the $n+1$th element of a sequence. The latter is the $n$th element of the sequence plus 1.
Increasing and Decreasing
The values in an increasing sequence always get bigger. A sequence \( \{ a_n \} \) is increasing if, for every $n$, \( a_n < a_{n+1} \). In other words, each successive value of the sequence must be larger than the one before it. For example,
The values in a decreasing sequence always get smaller. A sequence \( \{ a_n \} \) is decreasing if, for every $n$, \( a_n > a_{n+1} \). In other words, each successive value of the sequence must be smaller than the one before it. For example,
A sequence is non-decreasing if the numbers never get smaller, thus for \( a_k \) and \( a_{k+1} \), \( a_k \leq a_{k+1} \). See that, as in the example below, numbers can get bigger or stay the same. For example:
Similarly, a sequence is non-increasing if the numbers never get bigger, thus for \( a_k \) and \( a_{k+1} \), \( a_k \geq a_{k+1} \). In this case, numbers can stay the same or get smaller. For example:
When a sequence is either increasing, non-decreasing, non-increasing, or decreasing, it never changes direction. This property of never changing direction is called monotonicity. This such a sequence would be called monotonic.
Bounds
Sequences may (or may not) be bounded. Upper and lower bounds are values that are either above or below all values in the sequence. An upper bound is a value \( m \) such that \( m \geq a_n \) for every \( n \). Similarly, a lower bound is a value \( m \) such that \( m \leq a_n \), for every \( n \).
For the sequence \( \{ 2, 3, 4 \} \) we can give an infinite number of upper and lower bounds. Upper bounds include \( 4 \), \( 10 \), and \( 972 \). Lower bounds include \( 2 \), \( 1 \), and \( -123 \). A sequence like this one which has both upper and lower bounds is called bounded.
If a sequence has a lower bound, the sequence is said to be bounded below. If it has an upper bound, it is said to be bounded above. A sequence that has both upper and lower bounds is called bounded.
A sequence that is bounded below has an infinite number of lower bounds. We usually care about the greatest lower bound. Similarly, a sequence that is bounded above has an infinite number of upper bounds, and we care about the least upper bound.
Describing sequences
For the following sequences:
- state whether they are increasing, non-decreasing, non-increasing, or decreasing
- state whether they are monotonic and/or bounded
- give an upper and lower bound for each
- \( \{ \} \)
- \( \{ \} \)
- \( \{ \} \)
- \( \{ \} \)
Defining Sequences
We can write a formula for the sequence. This is necessary when dealing with infinite sequences. One notation for giving the formula for a sequence is as follows:
The above formula has three parts. First, the value of a given term is given by the function \( f(n) \). The second part defines the values of \( n \). At the bottom, we see the lower bound of \( n \). Here \( n \) starts at 1. At the top, we see the upper board. Here \( n \) continues to infinity, so this is an infinite sequence. We could define the squares of the natural numbers between \( n=2 \) and \( n=4 \) this way:
It might be helpful to visualise this with a table:
\( n \) | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|
\( n^2 \) | 4 | 9 | 16 | 25 | 36 |
Explicit Definition
Sometimes we can identify an explicit definition for a sequence. This is a formula for any value \( a_n \) which does not refer to any other values of \( a \). Taking a sequence and finding such an explicit formula is also called an analytic solution. For example, the explicit definition for the above sequence \( a \) is:
This formula is easier to work with as no recursion is required. It allows us to quickly find the value of the sequence for \( n \). However, in practice it can be hard to find such a solution to a sequence. It is generally easier to work out how a system changes relative to its previous state, than find a solution for any state as an explicit formula.
Interpreting formulas
Give the first 4 values of the following sequences. What is the length of each sequence?
- \( a_n = n^2 + 3 \)
- \( \{ \frac{n}{n+1} \}_{n=1}^{\infty} \)
- \( b_n = n+3 \)
- \( \{ k + \frac{n}{2} \}_{n=k}^{k+4} \)
Recursive Definition
We could also define a sequence by giving its initial term and a rule to generate subsequent terms. This is called a recursive definition. This formula is said to be in function iteration form.
Here we have really defined an infinite set of equations for all values of \( n \). In each, the value of \( a_n \) is related to the value of \( a_{n-1} \). Thus to work out the value of the sequence for any \( n \), we would need to recursively substitute all of the formulas back to \( a_1 \). This is also called finding a numerical solution of this sequence. For long or complex sequences this can be slow.
Arithmetic Sequences
Some sequences with well-known characteristics have names. An arithmetic sequence is a particular kind of sequence completely defined by an initial value and a common difference. Say you have a bank account with a starting balance of £4 (initial value) and you deposit £2 each day (common difference). The money in the account at the end of each day would follow the sequence:
The sequence \( \{ 4, 6, 8, 10, \dots \} \) is given by the recursive definition below. The value of \( a \) at each step \( n \) is the previous value, \( a_{n-1} \), plus 2. Note that we need to specify the value for \( a_1 \) as that is the first element in the sequence and it cannot be recursively defined in terms of anything else.
With our sequence so defined, we can find a numerical solution for the 5th value in this sequence. We do this by taking the formula above where \( n=5 \) and substituting the formula for \( a_4 \), then \( a_3 \), then \( a_2 \), and finally \( a_1 \). This gives us the result below:
Alternatively, we can define the same sequence with an explicit formula. Here we start with an initial value of \( 4 \), and add on our common difference \( 2 \) a number of times equal to \( n-1 \):
Using this formula, the fifth value of the sequence \( a \) can be found as a function of \( n \), without recursion:
The difference between successive terms of an arithmetic sequence is constant. In the above sequence, the difference between each pair of terms \( \Delta a_n = a_{n+1} - a_n = 2 \). The symbol \( \Delta \) (the Greek capital letter delta) is used to refer to a difference.
\( n \) | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
\( a_n \) | 4 | 6 | 8 | 10 | 12 |
\( \Delta a_n \) | 2 | 2 | 2 | 2 | 2 |
If we plot this sequence on a graph, you will see that it is increasing a constant rate. As the differences between each step are constant, the gradient of the graph is constant.
We can give both recursive and explicit formulas for any arithmetic sequence. Here \( a_n \) is the \( n \)th value of the sequence \( a \), \( a_1 \) is the initial value, and \( d \) is the common difference. By substituting values of \( a_1 \) and \( d \) we can get the formulas for any arithmetic sequence.
Experiment with different values for $a_1$ and $d$ in this interactive graph:
\( a_1 = \)
\( a_n = \)
(use prev
to reference \( a_{n-1} \))
Finding a Numerical Solution
Recursive definitions can be awkward to work with as they require recursion which is computationally inefficient.
Instead, we can rewrite our recursive definition as a difference equation (which is the discrete version of a differential equation)
This defines a system of equations; an infinite set of equations for all values of $n$
- \( a_2 = a_{2-1} + d \)
- \( a_3 = a_{3-1} + d \)
- \( a_4 = a_{4-1} + d \)
- \( \dots \)
We can work forwards, calculating all values of a from $a_1$ to $a_n$. This is called a numerical solution. This is most easily done using a spreadsheet
Finding an Analytical Solution
Instead we can give an explicit formula in terms of the initial value. In dynamical systems this is called an analytic solution to the dynamical system.
Analytic solutions may be easier to work out by hand and are far more computationally efficient than numerical solutions. However, finding an analytical solution is possible for only relatively simple dynamical systems.
We can work algebraically and look for patterns
We always have $a_1$ and add \( n-1 \times d \)
Or we can use a table to look for patterns
n | 1 | 2 | 3 | 4 | 5 | ... |
---|---|---|---|---|---|---|
\( a_n \) | \( a_1 \) | \( a_1+d \) | \( a_1+2d \) | \( a_1+3d \) | \( a_1+4d \) | \( \dots \) |
We always have $a_1$ and add \( n-1 \times d \)
Experiment with different values for $a_1$ and $d$ in this interactive graph:
\( a_n = \)
(Use n
to refer to the index of the current element)
Geometric Sequences
A geometric sequence is defined by an initial value and a common ratio. Geometric sequences can be defined by can also give recursive or explicit formulas:
For example, with an initial value of 2 and a common ratio of 3, we get the sequence that starts:
The recursive and explicit formulas for this sequence would be:
The difference between successive terms of a geometric sequence is not constant. In the above sequence, the difference between each pair of terms \( \Delta g_n \) is also a geometric sequence! This means that the difference between pairs of differences \( \Delta \Delta g_n \) is also geometric! All of these sequences are increasing exponentially.
\( n \) | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
\( g_n \) | 2 | 6 | 18 | 54 | 162 |
\( \Delta g_n \) | 4 | 12 | 36 | 108 | |
\( \Delta\Delta g_n \) | 8 | 24 | 72 |
We can see this exponential growth if we plot \( g_n \) on a graph:
This is the same pattern we observe for compound interest. If we put money in a bank account and earned %1 interest each day, the money at the end of each day would follow the geometric sequence \( m_n = 4 \times 1.01^n \).
Analytic Solution
We can work algebraically and look for patterns
We multiply $a_1$ by \( r_{n-1} \)
Dynamical Systems
A dynamical system is a system (i.e. a thing that can be in multiple states) that changes its state as a function of time. Discrete dynamical systems can be described by systems of difference equations. These equations represents some variable or state that changes between discrete time steps \( t=0 \), \( t=1 \), etc. For example:
The above dynamical system defines an infinite set of equations that relate the value of \( a \) at time \( t+1 \) as a function of the value of \( a \) at time \( t \). In this example, the value of \( a \) always increases by 1 each time step. As \( t \) can keep increasing indefinitely, this set of equations is infinite.
You may noticed that the value of \( a \) follows an arithmetic sequence, just like we have seen above. Each successive value in the sequence is the state of our dynamical system at each subsequent time step. The \( n \)th value of the sequence is the state of the dynamical system at time \( t \). The only difference is that we usually take the initial state in a dynamical system to be \( t=0 \) rather than \( n=1 \).
State
The state of a dynamical system is the current value of the system. We have been looking at sequences of numbers, for example the amount of money ina bank account. This value might be the state of the dynamical system.
Other mathematical objects than numbers can be the state of a system. For example, the state could be a vector:
A vector is like a list of numbers. You might think of it as an array. For example, the first number might store the angle of a pendulum, and the second might store the velocity.
The state could also be a matrix:
A matrix is like a grid of numbers, or a list of vectors. You might think of it as a two dimensional array
There exist mathematical operations for manipulating vectors and matrices that we will not get into in this module.
Continuous Dynamical Systems
A continuous dynamical system can be evaluated at any point in time
It can be defined by a differential equation
This requires calculus, which is beyond the scope of this course
Example of Bacteria Growth
Imagine we were modelling the number of bacteria in a petri dish. At time 0 there is 1 bacteria in the dish, that is \( b_0 = 1 \). At each time step, the value of \( b \) (the number of bacteria in the dish) doubles. The number of bacteria in the dish can be modelled by the dynamical system:
This dynamical system defines the geometric sequence \( \{ 1, 2, 4, 8, 16, \dots \} \) where the starting index of the sequence is 0, thus \( b_0 = 1 \). If we plot this on a graph we see a familiar exponential growth:
Will this system really keep increasing exponentially forever? A better model might be given by \( p \) below. Again we have defined \( p_{t+1} \) in terms of \( p_t \).
This equation is a more complicated model of the dynamical system. However the behaviour of this model are perhaps more realistic. Here \( c \)is the carrying capacity. The number of bacteria in the dish increases but slows as it approaches the limit of the number of bacteria the food source can support.
Spreadsheets
Set the initial value, e.g. in cell B2
=1
Rewrite the difference equation as a spreadsheet formula
=B2 * 2
Duplicate this formula for subsequent rows. Each subsequent row references the previous cell. The spreadsheet can calculate the values for you until the desired value of $t$.
Non-Linear Dynamical System Example
In reality, growth is constrained by a carrying capacity - a limit that the ecosystem can support. In the model above, the number of bacteria just keep increasing without end. If we simulated this model for 100 time steps, we would find the number of bacteria to be \( x_{100} = 1.27 \times 10^{30} \). This is not very realistic. Our formula is not an accurate model of reality.
Instead, let's consider the change each time step. We will call this $\Delta x_n$, which is the the $n$th first difference
The change at each time step $\Delta x_n$ should be:
- Proportional to the current number of bacteria (grows faster when there are more bacteria)
- Proportional to the difference between the number of bacteria and the carrying capacity (as the number of bacteria approaches the limit the ecosystem can support gets closer, there is more competition for survival, so the population grows more slowly)
This gives the dynamical system
Fixed Point / Equilibrium Point
A fixed point is a state in a dynamical system where no change occurs
In the system described above there are two fixed points
- 100
- 0
Spreadsheet
Choose values for $c$ and $k$.
Set the initial value, e.g. in cell B2
=1
Rewrite the difference equation as a spreadsheet formula
=B2 + 0.01 * (100 - B2) * B2
Duplicate this formula for subsequent rows. Each subsequent row references the previous cell. The spreadsheet can calculate the values for you until the desired value of $t$.
A spreadsheet can also produce a graph of the model to let us observe the dynamics of the system. you will find that it converges on the carrying capacity (100).
Numerical solution to this system
If we have a dynamical system with a state variable \( x \) and dynamics defined by function \( F \), we can find solutions for a given \( x_t \) by repeatedly applying \( F \).
Take for example the model of bacteria growth bounded by a carrying capacity given above:
We can work out a numerical solution for the number of bacteria in the dish after 5 time steps have passed by repeatedly applying this function to its own output:
Dynamical Systems with Multiple Dimensions
The dynamical systems we have seen involve only a single scalar value, such as opacity or temperature. Many real-world dynamical systems involve more than a single variable. For instance, to model a ball rolling down a slope we need to model both its position and its velocity.
To do this mathematically we need to replace our variable \( x \) with a vector \( \underline{x} \). Vectors contain multiple values. This significantly complicates the definition of \( F \) as we would need to use vector and matrix arithmetic.
However, we can extend our spreadsheets to model systems with multiple variables without worrying about vector and matrix math. Instead of having a single column of values of \( x_t \) at increasing values of \( t \), we have multiple variables, each with their own column. A simple way to express this mathematically as a pair of difference equations that reference each other.
For example, using a dynamical system, we could model the movement of a bead strung on a wire. Imagine we had a wire whose position through two-dimensional space is given by the function[^2].
To make it easier to understand, let's plot this function on a graph:
The bead is going to move downhill from its starting position. By differentiating the above function, we get the function for the gradient of the wire at any point. Again, differentiation is part of calculus, which is beyond the scope of this course, so trust me when I say the gradient of the above function at any point \( x \) is given by the function:
Which looks like this:
If the bead is going to behave as it would in the real world, it will accelerate proportionally to this gradient, i.e. its velocity will increase (well, decrease, as it is going down hill) according to the function above. The displacement \( u \) of the bead in the \( x \) dimension is just the last position plus the velocity. The displacement is given by the difference equation:
Where the velocity \( v \) of the bead is given by the difference equation:
which incorporates the formula for \( \frac{dy}{dt} \) above. \( T \) is a small number representing the time scale of each step in our discrete dynamical system. \( F \) is a fractional value that represents friction.
We can use a spreadsheet to create create a numerical solution using the formulas:
=B2 +C2
=(C2 + 0.01*(-(4*B2^3 - 4*B2)))*0.9
Using Dynamical Systems
Dynamical systems can be used for a wide range of scientific and engineering purposes.
If we have a model of a system, we can predict future states of the system. We can adjust the starting conditions to create alternative simulations. There are a wide range of scientific purposes that dynamical systems models can be applied to to help us understand real-world systems.
Dynamical systems models can be used for real-time control. If we have a model of a system, we can model interventions in that system. For example, an autonomous vehicle might use a model to predict its future position.
- If it detects an imminent crash, it may want to take some action (e.g. brake or swerve)
- It may need to model the effect of different actions to find the safest response