Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
2015 Holl Mini-Conference @ ISU MSMAmes, Iowa
A Few Good ODEs: An Introduction toModeling and Computation
James A. Rossmanith
Department of MathematicsIowa State University
June 20th, 2015
J.A. Rossmanith | ISU 1/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 2/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 3/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Ordinary differential equationsScalar initial value problem
Scalar ordinary differential equation (ODE):
A scalar ODE is an equation of the form:
dudt
= f (u), u(0) = u0
The solution is a function of a single-variable t (≡ time)
u0 is the initial condition
f (u) is a known function of u: (e.g., f (u) = u, f (u) = u2, . . . , f (u) = eu)
In principle (i.e., if you can evaluate the integrals and solve for u), solution is
duf (u)
= dt =⇒∫
1f (u)
du =∫
dt = t + c
For example f (u) = u:∫1u
du = t + c =⇒ ln(u) = t + c =⇒ u = ec et =⇒ u(t) = u0et .
J.A. Rossmanith | ISU 4/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Ordinary differential equationsSystem of initial value problems
System of ordinary differential equations:
A system of ODEs is an equation of the form:dudt
= f(u), u(0) = u0
The solution is a vector-valued function of a single-variable t (≡ time)
u0 is the initial condition (and it is a vector)
A solution is a trajectory in d-dimensional space (where u0 ∈ Rd ):
Trajectory: u(t) =(x(t),y(t),z(t)
)
J.A. Rossmanith | ISU 5/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 6/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Numerical approximation of ODEsEuler’s method
Recall: Taylor series for comparing the solution at t and t + k
u(t + k) = u(t)+ ku′(t)+12
k2u′′(t)+16
k3u′′′(t)+124
k4u(4)(t)+ . . .
Euler’s method
Let’s say that we have an approximation at time t = tn: Un ≈ u(tn)
Now, we want to get Un+1 ≈ u(tn + k):
u(tn +k)≈ u(tn)+k u′(tn) = u(tn)+k f (u(tn)) =⇒ Un+1 = Un +k f (Un)
Algorithm and example with f (u) = u:
1: U0 = u0, t0 = 02: for n = 0,1,2, . . . do3: tn+1 = tn + k4: Un+1 = Un + k f (Un)5: end for6: plot(t ,U)
J.A. Rossmanith | ISU 7/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Numerical approximation of ODEsRunge-Kutta method
Four-stage Runge-Kutta method:
Y1 = f (Un) , Y2 = f
(Un +
k2
Y1
), Y3 = f
(Un +
k2
Y2
), Y4 = f (Un + kY3) ,
Un+1 = Un +k6(Y1 +2Y2 +2Y3 +Y4)
Applied to f (u) = u:
Y1 = Un, Y2 =
(1+
k2
)Un, Y3 =
(1+
k2+
k2
4
)Un, Y4 =
(1+ k +
k2
2+
k3
4
)Un,
Un+1 =
(1+ k +
k2
2+
k3
6+
k4
24
)Un
=⇒ matches first five terms in Taylor series of u(t + k) = u(t)+ . . .
Extension to systems:
Y1 = f(Un) , Y2 = f(
Un +k2
Y1
), Y3 = f
(Un +
k2
Y2
), Y4 = f(Un + kY3) ,
Un+1 = Un +k6(Y1 +2Y2 +2Y3 +Y4)
J.A. Rossmanith | ISU 8/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 9/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Harmonic and Van der Pol OscillatorsExample from physics
Generic model (Newton’s second law F = Ma):
Mx ′′(t) =−RM x ′(t)− k x(t), u(t) =[
x(t)x ′(t)
],
ddt
[u1u2
]=
[u2
−RMM u2− k
M u1
]Example 1: Harmonic oscillator (no friction) (M = 1, k = 1):
RM ≡ 0, u(0) = (1,5) =⇒ harmonic_ex.m, harmonic.m
Example 2: Van der Pol oscillator (nonlinear friction) (M = 1, k = 1):
RM ≡ 10(u21 −1), u(0) = (1,5) =⇒ vanderpol_ex.m, vanderpol.m
J.A. Rossmanith | ISU 10/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 11/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Chemical reactionsExample from chemistry
Consider concentrations of the following chemicals:
S := substrate, E := enzyme, C := complex, P := product
Here is an example of a chemical reaction with these chemicals:
S+Ek1−→ C
Ck2−→ S+E
Ck3−→ P +E
Assuming everything is homogeneous in space this can be modeled as ODEs:
S′(t) =−k1 S(t)E(t)+ k2 C(t)
E ′(t) =−k1 S(t)E(t)+ k2 C(t)+ k3 C(t)
C′(t) = k1S(t)E(t)− k2 C(t)− k3 C(t)
P′(t) = k3C(t)
Example:(k1 = 106, k2 = 10−4, k3 = 0.1
)u(0) =
(5×10−7,2×10−7,0,0
)=⇒ chem_ex.m, chem.m
J.A. Rossmanith | ISU 12/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 13/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Population dynamicsRabbits vs. Foxes
Consider the following prey and predator species:
R := population of rabbits, F := population of foxes
Model assumptions:
(time rate of change
of population
)=
(birthrate
)−(
deathrate
)In the absence of foxes, rabbit population will grow exponentially:(
birthrate
)= k1 R(t) and
(deathrate
)= k2 R(t)F(t)
Death rate increases with larger rabbit pop. and larger fox pop.
In the absence of rabbits, fox population will decay exponentially:(deathrate
)= k4 F(t) and
(birthrate
)= k3 R(t)F(t)
Birth rate increases with larger rabbit pop. and larger fox pop.
The resulting model:
R′ = k1 R− k2 R F and F ′ = k3 R F − k4 F
Example:(k1 = 3, k2 = 2×10−3, k3 = 6×10−4, k4 = 0.5
)u(0) = (1000,500) =⇒ predprey_ex.m, predprey.m
J.A. Rossmanith | ISU 14/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 15/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Infectious disease modelingHuman-Zombie-Removed
Consider three populations:
H := humans, Z := zombies, R := temporarily removed zombies
Three conversion rate constants:
k1 := rate of conversion from (human) to (zombie)
k2 := rate of conversion from (temporarily removed zombie) to (zombie)
k3 := rate of conversion from (zombie) to (temporarily removed zombie)
Here is a model (again, assuming everything is space homogeneous):
H ′ =−k1 H Z
Z ′ = k1 H Z + k2 R− k3 H Z
R′ = k3 H Z − k2 R
Example: (k1 = 0.01, k2 = 0.02, k3 = 0.005)
(H(0), Z(0), R(0)) = (500, 10, 0) =⇒ zombie_ex.m, zombie.m
J.A. Rossmanith | ISU 16/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 17/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Pursuit problems1 Fox chasing 1 Rabbit
Rabbit moves along a prescribed path: (r(t), s(t))
Fox chases rabbit so that
1 speed of fox is always k times speed of rabbit
2 tangent vector to fox position points at rabbit
Tangent: x ′ = α(r − x) y ′ = α(s− y)
Speed: (x ′)2 +(y ′)2 = α2[(r − x)2 +(s− y)2
]= k
[(s′)2 +(t ′)2
]Full equations:
ddt
[xy
]= k
√(r ′)2 +(s′)2
(x− r)2 +(y− s)2
[r − xs− y
]
Example: k = 1.1, r(t) = (1+ t)12 cos(t), s(t) = (1+ t)
12 sin(t)
(x(0), y(0)) = (3, 0) =⇒ pursuit_ex.m, pursuit.m
J.A. Rossmanith | ISU 18/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 19/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Chaotic water wheelLorenz equation
x ′ = σ(y− x)
y ′ = r x− y− x z
z′ = x y−b z
Lorenz equation: simplified model of convection in the troposphere
Lorenz equation: simplified model of a leaky water wheel
Example: (σ = 10, b = 8/3, r = 28)
lorenz_ex.m, lorenz.m
See video of an experiment here: Link
J.A. Rossmanith | ISU 20/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Outline
1 Ordinary differential equations: some basics
2 Ordinary differential equations: numerical solutions
3 Harmonic and Van der Pol oscillators
4 Chemical reaction
5 Population dynamics: Rabbits vs. Foxes
6 Spreading disease: Human-Zombie-Removed
7 Non-trivial pursuit: 1 Fox chasing 1 Rabbit
8 Lorenz equations: Chaotic water wheel
9 Phase diagrams: Rabbits vs. Sheep
J.A. Rossmanith | ISU 21/22
Basics Numerics Oscillators! Chemistry! Rabbits vs. Foxes! Zombies! Pursuit! Chaos! Rabbits vs. Sheep!
Resource competition modelRabbits vs. Sheep
Consider two populations competing for the same food source:
x := rabbits, y := sheep
Each species follows logistic growth plus a competition term
x ′ = x(3− x−2y)
y ′ = y(2− x− y)
There are four fixed points in this system:
x(3− x−2y) = 0 and y(2− x− y) = 0
(x ,y) = (0,0)−unstable node
(x ,y) = (0,2)− stable node
(x ,y) = (3,0)− stable node
(x ,y) = (1,1)−unstable saddle
Create phase diagram:
pplane8.m, dfield8.m
J.A. Rossmanith | ISU 22/22