Dynamical Systems practical

Dynamical Systems

Dynamical systems are systems that change. We can build computational models of dynamical systems to model and simulate real-world phenomena. In this practical you will get to work through a series of interactive exercises. Then you will be challenged to build your own dynamical system model using a spreadsheet or in code.

First, work through the questions below. Work in a group if you can and discuss the answers as you go along. The questions are designed to get you to play with systems. Follow your curiosity. Feel free to work in a different order to that given below. If you do get stuck, please do ask for help.

After the questions, there is a challenge that you can take in different directions depending on your interest. You can work on this in a group as well, or work on your own.

Mathematics and Problem Solving

3. Dynamical Systems

David Gundry

Task 1.1: Animations

In a user interface the opacity of a button after it is clicked changes from 1 to 0 over 20 frames. The first attempt at this animation used the following model:

\[ o_{t+1} = o_{t} - \frac{1}{20} \]

\( a_1 = \)

\( a_n = \)

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

Frame: 01

  1. Calculate the values of the opacity \( o \) for frames 0 (the value before the animation), frame 1 (the first frame of animation) to 20 (the final frame of animation).
  2. What does the graph look like?
  3. What does the steepness of the line correspond to in the animation?
  4. The values of this sequence can also be given an explicit formula. Give such a formula.

\( a_n = \)

(Use n to refer to the index of the current element)

Frame: 01

Before moving on, experiment with different gradients. What other functions could you use to improve the appearance of the animation?

Task 1.2: Ball Animation

This animation does not look particularly good. Often animations look a lot better if they are smoothed so that the rate of change slows as it approaches its goal.

\[ y_t = y_{t-1} \times 0.85 \]

This time, an animation shows a ball that slows down smoothly.

\( a_1 = \)

\( a_n = \)

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

Frame: 01

  1. What is the value of \( o \) on the last frame? What if the length of the animation was extended?
  2. What proportion of the balls speed is lost each frame? What happens if this proportion is changed?
  3. The values of this sequence can also be given an explicit formula. Give such a formula.

\( a_n = \)

(Use n to refer to the index of the current element)

Frame: 01

Before moving on, experiment with different formulas that could be used for this animation.

Task 1.3: Animation 3

This animation does not look particularly good. Often animations look a lot better if they are smoothed so that the rate of change speeds up and then slows down. This smooths the step between the two end values.

This time an animation is made of a ball that slows down smoothly

\[ o_{t+1} = o_{t} + 0.3(o_{t}-1.2)o_{t} \]

Using a spreadsheet, work out the values of opacity for frames 0 to 20 and produce a graph of it. You can check the graph matches the one below. In your spreadsheet model you can change the number of frames of the animation. Does the value of $o$ ever reach 0? What problems might this lead to if this animation was implemented in code?

\( a_1 = \)

\( a_n = \)

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

Frame: 01

Task 1.4: Room temperature

The temperature of a room after a number of minutes \( t \) is modelled by the following dynamical system. The starting temperature of the room is given by \( z_0 \).

\[ z_{t+1} = 0.8z_t + 4 \]

\( a_1 = \)

\( a_n = \)

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

xy
115

Create a spreadsheet to calculate the values of \( z_t \) where \( z_0 = 15 \) up to \( t=16 \) and plot these on a graph. After approximately how many minutes does the temperature reach 19?

An equilibrium value is a value of a dynamical system where the system does not change. Explore different starting values of \( z_0 \) (i.e. different starting temperatures) for this system by substituting them in your spreadsheet. Use this to find the equilibrium value for this system.

Sequences Question

For the sequences you have seen so far, describe them in terms of:

  1. Lower and upper bounds (if these exist)
  2. Whether they are increasing / decreasing/ monotonic non-decreasing / monotonic non-increasing
  3. Whether they are arithmetic or geometric sequences, or neither of these
  4. Whether they are linear (i.e. $a_n$ is a linear function of \( a_{n-1} \). A linear function is a straight line: $m \times a_n + c$)

Task 2.1: Spreadsheets

If you have been using the interactive tools so far, it is time to use a spreadsheet. Using a spreadsheet is an easy way to build your own models and produce your own graphs. You can easily use a spreadsheet to find a numerical solutions to a dynamical system. Spreadsheets also allow you to build more complex models using multiple dimensions.

Create a spreadsheet to model a dynamical system, starting from the examples above.

You should be able to get the spreadsheet to update the calculated values and re-generate the graph to let you rapidly visualise the behaviour of this system.

Your difference equation \( z_{t+1} \) can be any function of \( z_{t} \) you like. See what kinds of behaviour you can get it to exhibit and make a note of anything interesting you find. For instance,

  1. Can you get it to oscillate between pairs of values?
  2. Can you generate a pseudo random sequence of values?
  3. Can you generate periodic behaviour?

Task 2.2: Multiple Dimensions

The following dynamical system models the position of a bead on a wire. $s$ is the displacement (position) of the bead, while $v$ is the bead's velocity. Construct a numerical solution to this dynamical system using a spreadsheet, for the values of \( T \) and \( F \) shown:

\[ s_{t+1} = s_t + v_t \]
\[ v_{t+1} =(v_t + 0.01(-(4s_t^3 - 4s_t))) \times 0.9 \qquad v_0 = 0 \]

Explore different starting values of displacement \( s_0 \), i.e. different starting positions for the bead on this wire. After this describe the shape of the wire as thoroughly as you can.

Task 2.3: Drag in a physics engine

A physics engine in a game simulates drag using the following dynamical system. For each time step $t$ it calculates displacement $s$ and velocity $v$ based on several constants about a given object. Each time step simulates \( \Delta_T = \frac{1}{60} \) seconds (approximately 0.0167 milliseconds).

\[ s_{t+1} = s_t + v_t \qquad v_0 = 0 \]
\[ v_{t+1} = v_t + \Delta_T (\frac{\frac{1}{2} \times \rho \times s_t^2 \times A \times C_d}{m}) \]
\[ m = 1 \qquad \rho = 10 \qquad A = 0.1 \qquad C_d = 0.5 \]

You will need to use a spreadsheet to construct a numerical solution to this dynamical system to answer these questions.

  1. If the starting velocity $v_0 = 10$, what is the displacement after 100 time steps \( s_{100} \)?
  2. There is one equilibrium point when $s_0=0$. Give the value of $v$ at this point

Challenge

You have now seen lots of examples. Taking your spreadsheet, or writing a program, create a model of a dynamical system of your choice. Your goal is to be able to construct a numerical solution for this system based on any starting state. Using a spreadsheet or writing a program will allow you to use multiple variables if you wish.

For ideas look at the reading (on Moodle) from A First Course in Mathematical Modelling.

Check out this example that uses a dynamical system approach to model probabilities in snakes and ladders.

Here are a few suggestions:

  • Population growth
  • Modelling the attributes of characters over time in games like The Sims or Dwarf Fortress
  • Bouncing ball, or other animations
  • PCG terrain height map
    1. Trigonometric functions
    2. Mod, floor
  • Random number generation
    1. Start from e.g. linear congruence
    2. How random? / how evenly distributed?

If you still don't have an idea, talk to me and I can try and help.

LecturePracticalAssessment