Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

Lecture slides for UCLA LS 30B, Spring 2020

Views: 14466
License: GPL3
Image: ubuntu2004
Kernel: SageMath 9.3

All of our models so far (differential equations) have assumed that time (tt) is continuous.

Continuous time

This was why we needed to use Euler's method, with a “small” Δt\Delta t, to approximate solutions to our differential equations. And this was always just an approximation: we can make it more accurate by using a smaller Δt\Delta t, but we can never get the exact solution using Euler's method.

But sometimes, it makes sense to think of time as discrete. This means that the tt variable can only be a whole number.

Discrete time

Discrete time with lines

This makes sense, for example, for models of populations that have a distinct mating season, or a very fixed life cycle that repeats each year (such as many insects).

Discrete time models

(Also known as difference equations)

f(X) = 2*X X0 = 5
X1 = f(X0) X1
10
X2 = f(X1) X2
20
X3 = f(X2) X3
40
X4 = f(X3) X4
80
X5 = f(X4) X5
160
f(X) = 2*X X0 = 5 X_list = [X0] for n in srange(0, 10): current_X = X_list[n] next_X = f(current_X) X_list.append(next_X) X_list
[5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120]
list_plot(X_list, size=30, axes_labels=("$n$ (or $t$)", "$X$"))
Image in a Jupyter notebook
f(X) = 4*X*(1 - X) X0 = 0.4
X1 = f(X0) X1
0.960000000000000
X2 = f(X1) X2
0.153600000000000
X3 = f(X2) X3
0.520028160000000
X4 = f(X3) X4
0.998395491228058
X5 = f(X4) X5
0.00640773729417265
f(X) = 4*X*(1 - X) solution = [0.4] t_list = srange(0, 10000) for t in t_list: solution.append(f(solution[-1])) solution = list(zip(t_list, solution))
p = list_plot(solution[:16], size=30) p.show(axes_labels=("$t$", "$X$"))
Image in a Jupyter notebook
p = list_plot(solution[:61], size=30) p.show(axes_labels=("$t$", "$X$"))
Image in a Jupyter notebook
p += list_plot(solution[:61], plotjoined=True, color="gray") p.show(axes_labels=("$t$", "$X$"))
Image in a Jupyter notebook
p = list_plot(solution[9300:9500], size=20) p.show(axes_labels=("$t$", "$X$"))
Image in a Jupyter notebook
p += list_plot(solution[9300:9500], plotjoined=True, color="gray") p.show(axes_labels=("$t$", "$X$"))
Image in a Jupyter notebook