Dynamical Systems lecture

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.

Mathematics and Problem Solving

3. Dynamical Systems

David Gundry

Learning Outcomes

    Understand and apply notation and terminology about sequences
    1. Notate and interpret sequences in enumerated form
    2. Notate elements of sequences using indexes
    3. Define and recognise (monotonically) increasing and (monotonically) decreasing sequences
    4. Define boundedness and identify the upper and lower bounds of a sequence
    5. Define and recognise arithmetic sequences
    6. Define and recognise geometric sequences
    Create simple sequence and dynamical system models and find numerical solutions
    1. Use explicit functions to describe a sequence
    2. Use formulas in function iteration form to describe a sequence
    3. Find analytic solutions for simple recursively defined sequences
    4. Discuss how sequences and dynamical systems can be used to model real-world systems
    5. Use a spreadsheet to find the numerical solution to simple dynamical systems

Learning Outcomes

  1. Understand and apply notation and terminology about sequences
  2. Create simple sequence and dynamical system models and find numerical solutions

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.

Modelling

Creating models that help us

  • Understand
  • Design
  • Control

Patterns

Mathematics is often described as the science of patterns

  • Nature
  • Behaviour of physical systems
  • Behaviour of logical systems

We want tools to be able to model these patterns

Modelling Change

Almost every real-world system involves change over time

  • Physical systems
  • Economic systems
  • Social systems

We can model change using mathematics

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.

Overview

  1. Terminology and notation
  2. Defining Sequences
  3. Dynamical Systems
  4. Multiple dimensions

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:

\[ a = \{ 4, 2, 2, 6, 8, 3, 5 \} \]

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.

Terminology and Notation

Sequences

A sequence is a progression of numbers, e.g.

\[ \{ 1, 10, 4, 2, 4, 77, 6, 4, \dots \} \]

Sequences are patterns that usually involve change

Sequences

Describe patterns over successive values of $n$, e.g.

  • Website hits per day
  • Investment that pays interest each month
  • Rabbit population each spring
  • The time taken by an algorithm for inputs of increasing size

Sequences are discrete

E.g. \( a = \{ 1, 2, 3 \} \) there is no \( a_{1.01} \)

Compare with a continuous function, e.g.

\[ f(x) : \mathbb{R} \rightarrow \mathbb{R} = 2x \]
\[ f(1.01) = 2.02 \]

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.

\[ a = \{ 1, 2, 3, 4 \} \]

Here we can refer to each element of the sequence by using a subscript. For example, the first element of this sequence is

\[ a_1 = 1 \]

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:

\[ a_{n+1} \]

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.

Indices

Subscripts are used to refer to a given index in a sequence

\[ b = \{ 1, 3, 6, 10, 15 \} \]
  • \( b_1 = 1 \)
  • \( b_2 = 3 \)
  • \( b_3 = 6 \)

Indices

We will often talk about the $n$th and $n+1$th element of a sequence

\[ a_n \quad a_{n+1} \]

Pay attention to subscripts

\[ a_{n+1} \neq a_n + 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,

\[ \{ 1, 2, 4, 5 \} \]

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,

\[ \{ 5, 3, 2, 1 \} \]

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:

\[ \{ 1, 1, 2, 3, 4, 4 \} \]

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:

\[ \{ 5, 4, 4, 3, 2, 1, 1 \} \]

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.

Increasing and Decreasing

A sequence \( \{ a_n \} \) is increasing if, for every $n$

\[ a_n < a_{n+1} \]

A sequence \( \{ a_n \} \) is decreasing if, for every $n$

\[ a_n > a_{n+1} \]

Monotonicity

  • Monotonically increasing
  • \[ a_n < a_{n+1} \]
  • Monotonically decreasing
  • \[ a_n > a_{n+1} \]
  • Monotonically non-decreasing
  • \[ a_n \leq a_{n+1} \]
  • Monotonically non-increasing
  • \[ a_n \geq a_{n+1} \]

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.

Bounded Below

For some $m$, if

\[ m \leq a_n \quad \text{for all }n \]

$m$ is a lower bound of the sequence

Bounded Above

For some $m$, if

\[ m \geq a_n \quad \text{for all }n \]

$m$ is an upper bound of the sequence

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
  1. \( \{ \} \)
  2. \( \{ \} \)
  3. \( \{ \} \)
  4. \( \{ \} \)

Sequences

Describe the following sequences:

  1. \( \{ \} \)
  2. \( \{ \} \)
  3. \( \{ \} \)
  4. \( \{ \} \)

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:

\[ \{f(n)\}_{n=1}^{\infty} \]

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:

\[ \{n^2\}_{n=2}^{6} = \{4, 9, 16, 25, 36 \} \]

It might be helpful to visualise this with a table:

\( n \)23456
\( n^2 \)49162536

Defining Sequences

Formulas

\[ \{ a_n \}_{n=1}^\infty \]
  • Lower limit ($n=1$)
  • Upper limit (infinity)
  • Formula $a_n$
  • Each value of the sequence is the formula with $n$ substituted

Formula example

\[ \{n^2\}_{n=2}^{6} = \{4, 9, 16, 25, 36 \} \]
\( n \)23456
\( n^2 \)49162536

Formula example

\[ \{n \text{ mod } 3 + 1 \}_{n=1}^{\infty} = \{2, 3, 1, 2, \dots \} \]
\( n \)1234...
\( n \text{ mod } 3 + 1 \)2312...

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:

\[ a_n = 2^n \]

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.

Explicit Definition

An alternative notation for a sequence is as follows, where $n$ is a variable

\[ a_n = \dots \]

The right hand side is some function of $n$.

Interpreting formulas

Give the first 4 values of the following sequences. What is the length of each sequence?

  1. \( a_n = n^2 + 3 \)
  2. \( \{ \frac{n}{n+1} \}_{n=1}^{\infty} \)
  3. \( b_n = n+3 \)
  4. \( \{ k + \frac{n}{2} \}_{n=k}^{k+4} \)

Interpreting formulas

Give the first 4 values of the following sequences. What is the length of each sequence?

  1. \( a_n = n^2 + 3 \)
  2. \( \{ \frac{n}{n+1} \}_{n=1}^{\infty} \)
  3. \( b_n = n+3 \)
  4. \( \{ 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.

\[ a_n = 2 \times a_{n-1} \qquad a_1 = 1 \]
\[ a = \{1, 2, 4, 8, 16, 32, \dots \} \]

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.

\[ a_2 = 2 \times a_{1} \qquad a_3 = 2 \times a_{2} \qquad a_4 = 2 \times a_{3} \qquad a_5 = 2 \times a_{4} \qquad \dots \]
\[ a_5 = 2 \times 2 \times 2 \times 2 \times 1 \]

Recursive Definition

$a_n$ is defined in terms of previous elements in the sequence, e.g.

\[ \begin{numcases}{a_n = } x & if n = 1 \\ F(a_{n-1}) & otherwise \end{numcases} \]

Recursion Pseudocode

\[ \begin{numcases}{a_n = } 2 & if n = 1 \\ a_{n-1} + 1 & otherwise \end{numcases} \]
1 2 3 4 5 Function a(n: number): number if (n == 1) return 2 else return a(n-1) + 1

Recamán's sequence

$a_n$ is defined in terms of previous elements in the sequence,

\[ \begin{numcases}{a_n = } 0 & if $n = 0$ \\ a_{n-1} - n & if $a_{n-1} -n > 0$ and is not already in the sequence\\ a_{n-1} + n & otherwise \end{numcases} \]

Pseudorandom sequences

Linear congruential generators take the form:

\[ X_{n+1} = (aX_n + c) \mod m \]

For some $a$, $c$, $m$, and $X_1$

\[ \begin{numcases}{X_{n+1} = } 1 & if $n = 1$ \\ (75X_n + 74) \mod (2^{16}+1) & otherwise \\ \end{numcases} \]

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:

\[ a = \{ 4, 6, 8, 10, \dots \} \]

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.

\[ a_n = a_{n-1} + 2 \qquad a_1 = 4 \]

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:

\[ a_5 = 4 + 2 + 2 + 2 + 2 = 12 \]

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 \):

\[ a_n = 4 + 2(n-1) \]

Using this formula, the fifth value of the sequence \( a \) can be found as a function of \( n \), without recursion:

\[ a_5 = 4 + 2(5-1) = 12 \]

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 \)12345
\( a_n \)4681012
\( \Delta a_n \)22222

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.

\[ a_n = a_{n-1} + d \]

Experiment with different values for $a_1$ and $d$ in this interactive graph:

\( a_1 = \)

\( a_n = \)

(use prev to reference \( a_{n-1} \))

Arithmetic Sequences

Arithmetic Sequences

Each value in the sequence is the previous value plus the common difference

\[ a_n = a_{n-1} + d \]
\[ \{ 5, 10, 15, 20, 25, \dots \} \]

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)

\[ a_n = a_{n-1} + d \]

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

Numerical Solution

Transform into a difference equation:

\[ a_{n+1} = a_{n} + d \]

Iterate from \( a_{1} = x \), e.g. for $a_1 = 5$, $d =2$

$n$12345...
$a_n$5791113...
$\Delta a_n$22222...

Numerical Solution Pseudocode

\[ \begin{numcases}{a_{n} = } 5 & if $n = 1$ \\ a_{n-1} + 2 & otherwise \end{numcases} \]
1 2 3 4 5 Function numerical(n: number): number let xi: number = 5 for i in 2 to n: xi = xi + 2 return xi;

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.

\[ a_n = a_1 + d(n-1) \]

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

\[ a_2 = a_1 + d \]
\[ a_3 = (a_1 + d) + d \]
\[ a_4 = ((a_1 + d) + d) + d \]

We always have $a_1$ and add \( n-1 \times d \)

\[ a_n = a_1 + d(n-1) \]

Or we can use a table to look for patterns

n12345...
\( 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 \)

\[ a_n = a_1 + d(n-1) \]

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)

Finding an Analytic Solution

An analytic solution is a formula in terms of the initial value

n12345...
\( a_n \)\( a_1 \)\( a_1+d \)\( a_1+2d \)\( a_1+3d \)\( a_1+4d \)\( \dots \)

We add \( (n-1) \times d \) to the initial value

\[ a_n = a_1 + d(n-1) \]

Analytic Solution Pseudocode

\[ a_n = 5 + 2(n-1) \]
1 2 Function analytic(n: number): number return 5 + 2 * (n-1);

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:

\[ g_n = g_{n-1} \times r \quad g_n = g_1 \times r^{n-1} \]

For example, with an initial value of 2 and a common ratio of 3, we get the sequence that starts:

\[ g = \{ 2, 6, 18, 54, 162, \dots \} \]

The recursive and explicit formulas for this sequence would be:

\[ g_1 = 2 \quad g_n = g_{n-1} \times 3 \quad g_n = 2 \times 3^{n-1} \]

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 \)12345
\( g_n \)261854162
\( \Delta g_n \)41236108
\( \Delta\Delta g_n \)82472

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 \).

\[ m = \{ 4, 4.04, 4.0804, 4.121204, 4.16241604, 4.2040402004, 4.246080602404, \dots \} \]

Geometric Sequences

Geometric Sequence

Each value in the sequence is the previous value multiplied by the common ratio

\[ g_n = g_{n-1} \times r \]
\[ \{ 1, 2, 4, 8, 16, \dots \} \]

Analytic Solution

We can work algebraically and look for patterns

\[ a_2 = a_1 \times r \]
\[ a_3 = (a_1 \times r) \times r = g_1 \times r^2 \]
\[ a_4 = ((a_1 \times r) \times r ) \times r = g_1 \times r^3 \]

We multiply $a_1$ by \( r_{n-1} \)

\[ g_n = g_1 \times r \]
\[ n-1 \]

Analytic Solution

Look for patterns in the algebra

\[ g_2 = g_1 \times r \]
\[ \dots \]
\[ g_4 = ((g_1 \times r) \times r ) \times r \]
\[ \dots \]
\[ g_n = g_1 \times 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:

\[ a_{t+1} = a_t + 1 \]

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.

\[ a_{1} = a_0 + 1 \qquad a_{2} = a_2 + 1 \qquad a_{3} = a_3 + 1 \quad \dots \]

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 \).

Dynamical Systems

Dynamical Systems

A dynamical system is a system that changes over time

  • A ball rolling down a slope
  • Airflow over a bird's wing
  • Launching a rocket into space
  • The stock market
  • A bank account that gains interest
  • The human brain

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:

\[ \underline{v} = \left[ {\begin{array}{c} x_{1} \\ x_{2} \\ \end{array} } \right] \]

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_{2\times2} = \left[ {\begin{array}{cc} a_{11} & a_{12} \\ a_{21} & a_{22} \\ \end{array} } \right] \]

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

\[ \frac{dx}{dt} = F(x) dx \]
  • A function for the change in $x$ over time
  • Time $t$ is continuous
  • This requires calculus, which is beyond the scope of this course

    State

    A dynamical system has a state variable, e.g. x

    The minimal representation of all information needed to describe that state

    A screenshot from the film The Matrix showing computer monitors covered in code.

    State

    For example, a state of a dynamical system model might be

    • The amount in a bank account, e.g.
    • \[ x = 100 \]
    • The angle and velocity of a pendulum, e.g.
    • \[ x = 0.7 \theta + 0.3 v \]

    Discrete Dynamical Systems

    A discrete dynamical system is in one of a set of a discrete states

    It can be defined by a difference equation

    \[ x_{t+1} = F(x_t) \]

    Here $F$ is a function that describes the dynamics of the system

    The value of time $t$ goes up in steps of 1

    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:

    \[ b_0 = 1 \quad b_{t+1} = 2b_t \]

    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 \).

    \[ p_{t+1} = p_t + k(c - p_t)p_t \qquad k = 0.05 \qquad c= 10 \]

    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.

    Linear Dynamical System Example

    Bacteria Example

    Imagine we bacteria in a dish

    • Each bacteria duplicates every time step
    • How many bacteria will we have after $n$ time steps?

    A dynamical system modelling this is defined by the difference equation

    \[ x_{t+1} = x_t \times 2 \]

    Spreadsheets

    Set the initial value, e.g. in cell B2

    =1

    Rewrite the difference equation as a spreadsheet formula

    \[ x_{t+1} = x_t \times 2 \]
    =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$.

    Example

    We can produce a numerical solution for this system for a given value of $a_0$

    \[ x_{t+1} = x_t \times 2 \]
    \[ x_0 = 1 \]

    The best way to do this is to use a spreadsheet

    Bacteria growth example

    \( a_1 = \)

    \( a_n = \)

    xy
    11

    Analytical Solution

    This generates a geometric sequence

    \[ \{ 1, 2, 4, 8, 16, 32, \dots \} \]

    Thus we know an analytic solution for this dynamical system

    \[ x_t = x_0 \times r^t \]

    Note we are indexing $x$ from 0

    Linear Dynamical Systems

    This is a linear dynamical system because \( x_{t+1} \) is a linear function of $x_t$

    \[ x_{t+1} = m \times x_t + c \]

    Linear dynamical systems can be solved analytically

    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

    \[ x_{t+1} = x_t + k(c - x_t)x_t \]

    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
    \( x_{t+1} = x_t + 0.01(100 - x_t)x_t \)

    Non-Linear Dynamical System Example

    Example

    Does this model give sensible results?

    \[ x_{t+1} = x_t \times 2 \]
    \[ x_{100} \approx 1.27 \times 10^{30} \]

    In reality, growth is constrained by a carrying capacity

    Differences

    We can write a difference equation as

    \[ x_{n+1} = x_n + \Delta x_n \]
    • The same as last time $x_n$
    • Plus the change from last time $\Delta x_n$

    Differences

    How many bacteria are there in the dish?

    Let $\Delta x_n$ be proportional to the difference between the current bacteria and the carrying capacity $c$, multiplied by a growth rate constant $k$

    \[ x_{t+1} = x_t + k(c - x_t)x_t \]

    Bacteria growth example

    \( a_1 = \)

    \( a_n = \)

    xy
    11

    Differences

    This is a non-linear dynamical system

    \[ x_{t+1} = x_t + k(c - x_t)x_t \]

    \( x_{t+1} \)is a non-linear function of $x_t$

    Generally non-linear dynamical systems cannot be solved analytically

    Spreadsheet

    Choose values for $c$ and $k$.

    \[ c = 100 \quad k = 0.01 \]

    Set the initial value, e.g. in cell B2

    =1

    Rewrite the difference equation as a spreadsheet formula

    \[ x_{t+1} = x_t + k(c - x_t)x_t \]
    =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 \).

    \[ x_{t+1} = F(x_t) \quad x_{1} = F(x_0) \quad x_{2} = F(F(x_0)) \]
    \[ x_{3} = F(F(F(x_0))) \]

    Take for example the model of bacteria growth bounded by a carrying capacity given above:

    \[ F_p(x) = x + k(c - x)x \qquad k = 0.05 \qquad c = 10 \]

    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:

    \[ F(1) = 1.45 \]
    \[ F(1.45) = 2.069875 \]
    \[ F(2.069875) = 2.89059337421875 \]
    \[ F(2.89059337421875) = 3.91811355857426 \]
    \[ F(3.91811355857426) = 5.10958964496722 \]

    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.

    \[ \underline{x}_{t+1} = F(\underline{x}_t) \]

    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.

    \[ a_{t+1} = F_1(a_t, b_t) \quad b_{t+1} = F_2(b_t, a_t) \]

    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].

    \[ y = x^4 - 2x^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:

    \[ \frac{dy}{dt} = 4x^3 -4x \]

    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:

    \[ s_{t+1} = s_t + v_t \]

    Where the velocity \( v \) of the bead is given by the difference equation:

    \[ v_{t+1} =(v_t + T(-(4s_t^3 - 4s_t))) \times F \]

    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

    Multiple Dimensions

    Adding Complexity

    Dynamical systems can get as complex as you want to make them

    Instead of a single variable, we can use multiple variables

    We can express this either with

    • vectors
    • matrices
    • multiple difference equations

    Multiple Difference Equations

    We can define two (or more) functions $F_1$, $F_2$, such that

    \[ a_{t+1} = F_1 (a_t , b_t) \]
    \[ b_{t+1} = F_2 (b_t , a_t ) \]

    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

    Using Dynamical Systems

    Use cases

    You can use dynamical systems for

    • Simulation
    • Prediction
    • Engineering and Control
    • Design and Optimisation
    • Understanding

    Extending Dynamical Systems

    We can extend the dynamics $F$ of our dynamical system

    \[ x_{t+1} = F(x_t, u, b, e) \]

    to incorporate

    • $u$ - a control signal
    • $b$ - parameters
    • $e$ - error/uncertainty
    • $\dots$ and whatever else we want!

    Machine Learning

    Creating models by hand requires expert knowledge

    We can use machine learning to learn dynamical system models from data

    • Linear Regression
    • Non-linear Regression
    • Neural networks

    Summary

    Summary

    Sequences

    A sequence is a progression of numbers, e.g.

    \[ a = \{3, 6, 9, 12, \dots \} \]

    We can index the values in a sequence

    \[ a_1 = 3 \]

    We can give formulae for many sequences, e.g. arithmetic and geometric sequences

    Dynamical Systems

    A dynamical system is a system that changes state over time

    Discrete dynamical systems can be modelled with difference equations

    \[ x_{t+1} = x_t + \Delta x_t \]

    Dynamical Systems

    Linear dynamical systems have analytic solutions, e.g.

    \[ x_t = x_0 \times r^t \]

    Non-linear dynamical systems may not be solvable

    Spreadsheets can be used to find a numerical solution

    LecturePracticalAssessment