of 16
8/18/2019 differential1921
1/16
A CRASH COURSE ON DIFFERENTIAL EQUATIONS
AND ITS APPLICATIONS
RAFAEL GRANERO-BELINCHÓN
Abstract. In this notes we present some autonomous differential equa-tions and applications. We also provide some examples with solutions(in blue).
Contents
1. Introduction 12. Malthus law 13. Limited growth and equilibrium 24. Logistic growth 45. Integrating factors 66. Forward Euler method 77. Exercises 98. The Lotka and Volterra predator-prey model 109. SIR models for epidemics 12
10. A model for a zombie outbreak 1411. A model for Bieber fever 1612. Exercises 16
1. Introduction
Remember that a differential equation has the general form
dn
dtnP (t) = F (P (t), P ′(t), P ′′(t),...,
dn−1
dtn−1P (t), t).
In what follows (excerpt in the integrating factors part), we will restrictourselves to the case with n = 1 and where the function F does not dependexplicitly on t. Thus, we consider the case
P ′(t) = F (P (t)).
2. Malthus law
Let’s start from the very beginning: Malthus’ Law. This populationdynamics model was introduced by Thomas Robert Malthus (XVIII). Thereare two basic hypotheses:
(1) the population change is proportional to itself.
(2) there is no growth restriction (as it might be caused by finite space,...)1
8/18/2019 differential1921
2/16
2 R. GRANERO-BELINCHÓN
The ordinary differential equation (ODE) is
dP
dt = rP (t), P (0) = P 0,
where P 0 ≥ 0 is the initial population and r ∈ R is the constant of propor-tionality. We solve that using that it’s a separable equation:
dP
dt = aP (t) ⇒
dP
P = rdt,
and, integrating, dP
P = r
dt ⇒ ln(P (t)) − ln(P 0) = r(t − 0) ⇒ P (t) = P 0e
rt.
Remark 1. When r < 0, Malthus law models exponential decay and it is widely used as a model of radiactive decay.
Example 1. In Figure 1, we can see how the muskrats appear in Europe.The question is: Assuming that the muskrat population grows according toMalthus law, estimate using the numbers and dates in the cable to The New York Times the constant of proportionality/rate of growth r.
[*** We take the initial time 1905. We have
P (0) = the population in Czech Republic at 1905 = 20,
P (9) = the population in Czech Republic at 1914 = 200000.
Thus, using the formula for the solution, we have
P (9) = 200000 = P 0er9 = 20e9r,
so,10000 = e9r ⇒ ln(10000)/9 = r ≈ 1.02.
***]
3. Limited growth and equilibrium
When the growth is restricted (for instance because the space is finiteor the available resources are finite), the previous model doesn’t apply andshould be modified.
(1) the rate of change of the population is a linear function of the pop-ulation.
(2) there is growth restriction.With these hypotheses we get
dP
dt = r(N − P (t)), P (0) = P 0,
where r > 0 is the rate of growth and N is the maximum amount of indi-viduals. We can solve the ODE as before,
− dP
N − P = −rdt ⇒ ln(|N − P |) = −rt + C ⇒ N − P (t) = e−rt+C ,
where C is the constant appearing from the integration procedure. We needto find this constant C . We have
P (t) = N − e−
rt+C , P (0) = N − eC = P 0 ⇒ ln(N − P 0) = C.
8/18/2019 differential1921
3/16
17B NOTES 3
Figure 1. a) Cable about the muskrats to the New YorkTimes b) A muskrat.
We concludeP (t) = N − e−rt(N − P 0).
We notice that
limt→∞
P (t) = N,
and also that if P ′(t) = 0 if P (t) = N . This is an example of an extremelyimportant concept in differential equations:
Definition 1. Let P ′(t) = F (P (t)) be the considered ODE. Assume that y ∈ R is a number such that
F (y) = 0,
then y is called an equilibrium point.
These equilibria can be stable (i.e. the solution moves towards them) orunstable (i.e. the solution try to avoid them). Let’s state these concepts in
a rigorous way:
8/18/2019 differential1921
4/16
4 R. GRANERO-BELINCHÓN
Definition 2. Let P ′(t) = F (P (t)) be the considered ODE. Assume that y ∈ R is an equilibrium point. Compute F ′(y). Then
• if F ′(y) < 0 the equilibrium is stable.• if F ′(y) > 0 the equilibrium is unstable.
Now we see that y = N is an equilibrium and F ′(y) = −r < 0, so it’sstable.
Remark 2. This equation is called von Bertalanffy eq. and it can be used to describe the length of some fish.
4. Logistic growth
Now the hypotheses are
(1) if the population is small , its change is proportional to itself.(2) there is growth restriction.(3) as the population grows, the growth restriction is higher.
It is then when we use the logistic equation:
dP
dt = rP (t)(1 −
P (t)
N ), P (0) = P 0.
where r > 0 is the rate of growth and N is the maximum population. Bothparameters are data. As before, we have a separable equation, so
dP
P − P 2
N
= rdt,
dP P − P
2
N
=
rdt,
using partial fractions, we get 1N
1 − P N
+ 1
P
dP = rt + C,
where C is the constant appearing from the indefinite integration. Thus,
− ln |1 − P
N | + ln |P | = rt + C ⇒
N P (t)
N − P (t) = ert+C ,
P (t) = N ert+C
N + ert+C .
We need to find the constant C . We use that at t = 0 we have P (0) = P 0,so
P (0) = N eC
N + eC ⇒
N P 0N − P 0
= eC ⇒ C = ln
N P 0N − P 0
.
When we introduce this expression for C we get
P (t) =N ert NP 0
N −P 0
N + ert NP 0N −P 0
=N P 0e
rt 1N −P 0
1 + ert P 0N −P 0
= N P 0e
rt
N + (ert − 1)P 0.
This will be our final expression.In the Figure 2, you can see the evolution of solutions corresponding to
different initial data, P 0.
8/18/2019 differential1921
5/16
17B NOTES 5
0 1 2 3 4 5 6 7 8 9 10
0
1
2
3
4
5
6
7
8
9
10
t
x
Logística x ’ = r x (1 − x/N) r = 1 N = 5
Figure 2. Solutions corresponding to different initial data, P 0
Example 2. Let’s assume that the world population follows a logistic growth.Using the table
Year Population (millions)1990 5263 1995 56742000 6070 2005 64542010 6972
Compute the parameters r and N . What is your approximation to the human population in 2015? (The UN estimation is 7324 millions)
[*** Taking 1990 as our initial time we get P (0) = P 0 = 5263.We have
P (5) = 5674 = 5263N er5
N + 5263(e5r − 1),
P (10) = 6070 = 5263N er10
N + 5263(e10r − 1).
From these two equations we get N as a function of r in twoequivalent ways:
N = 5674 · 5263(e5r
− 1)5263e5r − 5674
,
N = 6070 · 5263(e10r − 1)
5263e10r − 6070 .
As both expressions are for the same value N (which is a uniquenumber), we have an equation for r
5674 · 5263(e5r − 1)
5263e5r − 5674 =
6070 · 5263(e10r − 1)
5263e10r − 6070 .
Using e10r − 1 = (e5r + 1)(e5r − 1), after some simplifications,
5674
5263e5r − 5674 =
6070(e5r + 1)
5263e10r − 6070 ,
8/18/2019 differential1921
6/16
6 R. GRANERO-BELINCHÓN
and
5674(5263e10r − 6070) = 6070(e5r + 1)(5263e5r − 5674).
If we write x = e5r the previous equation is a second orderalgebraic equation thar we can solve with the second orderequation formula getting
r ≈ 0.036.
With this value of r we recover
N ≈ 9400 million people.
Using these two values we estimate that, in 2015, would be 7123million people on Earth. ***]
Let’s notice that the equilibria for the logistic equation are
y = 0 and y = N.
In this case the derivative is
F ′(P ) = d
dP (rP (1 − P/N )) =
d
dP (rP − rP 2/N ) = r − 2rP/N.
When we evaluate F ′(P ) at the equilibria, using r > 0, we get
F ′(0) = r > 0 and F ′(N ) = r − 2r = −r
8/18/2019 differential1921
7/16
17B NOTES 7
Now we use the previous formula with β (t) = t
0 α(s)ds, and we get
d
dt
e t
0 α(s)dsP (t)
= e t
0 α(s)dsf (t).
Integrating e t
0 α(s)dsP (t)
=
t0
e u
0 α(s)dsf (u)du + C,
P (t) = e− t
0 α(s)ds
t0
e u
0 α(s)dsf (u)du + C
.
To fix the constant, notice that
P (0) = P 0 = e−
0
0 α(s)ds
00
e u
0 α(s)dsf (u)du + C
= C.
Example 3. Solve P ′(t) = −4P (t) + f (t), P (0) = P 0.
[*** We need to find the integrating factor. As before, no-tice that the equation reads
P ′(t) + 4P (t) = f (t), P (0) = P 0,
and, multiplying by e4t we get,
e4tP ′(t) + 4e4tP (t) = d
dt
e4tP (t)
= e4tf (t), P (0) = P 0.
Integrating,
e4tP (t) = t
0e4sf (s)ds + C ⇒ P (t) = e
−
4t t
0e4sf (s)ds + e
−
4tC.
To find the constant we use the initial data:
P 0 = C ⇒ P (t) = e−4t
t0
e4sf (s)ds + e−4tP 0.
***]
6. Forward Euler method
In general it’s very difficult (or even impossible) to find the exact solutionof a given differential equation. As you can imagine, we are going to usethe computer to find an approximate solution . The construction of numeri-
cal methods to approximate solutions of differential equations is an area of expertise by itself.
Assume that we have the ODE
P ′(t) = F (P (t)), P (0) = P 0.
Integrating we get
P (t) − P (0) =
t0
F (P (s))ds.
The problem is that, as we don’t have the expression for P (s), the RHS hasno meaning. Then we are going to approximate the RHS as
t
0 F (P (s))ds ≈ tF (P (0)).
8/18/2019 differential1921
8/16
8 R. GRANERO-BELINCHÓN
This is just some sort of Riemann sum (as it was presented in the verybeginning of the course) taking the height of the rectangle equal to the
left endpoint. To achieve a better accuracy, if we want to approximatethe solution up to time T > 0, we are going to define a partition (with nsubintervals) of the time interval
0 = t0 < t1 = T /n < t2 = 2T/n,...,tn = T ,
and we are going to compute n step:
P (t1) − P (t0) =
t1t0
F (P (s))ds ≈ (t1 − t0)F (P (t0)),
P (t2) − P (t1) =
t2t1
F (P (s))ds ≈ (t2 − t1)F (P (t1)),
P (t3) − P (t2) = t3t2
F (P (s))ds ≈ (t3 − t2)F (P (t2)),
until
P (tn) − P (tn−1) =
tntn−1
F (P (s))ds ≈ (tn − tn−1)F (P (tn−1)).
This method is known as Forward Euler method.Let me show with an example why one should know about differential
equations before approximating it solution.
Example 4. Consider
y′(t) = y(t)2, y(0) = 1.
Approximate this equation using the forward Euler method and compare with the exact solution.
[*** First, let’s compute the solution. As before,
dy
y2 = dt ⇒−
1
y(t) = t + C ⇒ y(t) =
1
−t − C .
Now we use the initial data to fix the constant C :
y(0) = 1 = 1
−C ⇒ C = −1,
so
y(t) =
1
1 − t .If we use Matlab to approximate the solution and we compare
with the exact solution obtained before, we get the Figure 3.Notice that the approximate solution (blue) EXISTS AFTERt = 1!!! and we know that the exact solution (red) doesn’t!!!***]
%% Forward Euler Method
%% Number of time steps
N=50;
%% Final time
8/18/2019 differential1921
9/16
17B NOTES 9
0 0.2 0.4 0.6 0.8 1 1.2 1.40
10
20
30
40
50
60
70
80
90
Figure 3. Exact solution (red) and approximate solution(blue) corresponding to the same initial data, P 0 = 1.
T=2;
dt=T/(N-1);
t=[0:dt:T];
%% Initial data
y0=1;
y(1)=y0;
for j=1:length(t)-1y(j+1)=y(j)+((y(j))^2)*dt;
end
7. Exercises
Exercise 1. Solve the following ODE
a)P ′(t) = k(P (t))3, P (0) = 1
b)P ′(t) = 1
P (t), P (0) = 1
c)P ′(t) = P (t)
3t , P (1) = 4
d)P ′(t) = t2(P (t))2, P (3) = 2
Exercise 2. Compute the equilibria and decide whether the equilibria are stable or unstable:
a)P ′(t) = sin(P (t)),
b)P ′(t) = eP (t)−5 − 1,
c)P ′(t) = ln(P (t) + 1),
d)P ′
(t) = P (t)(1 − P (t))(2 − P (t))
8/18/2019 differential1921
10/16
10 R. GRANERO-BELINCHÓN
Exercise 3. Find the integrating factor and solve the following ODE
a)P ′(t) + t2P (t) = 0, P (0) = 1,
b)P ′(t) + sin(t)P (t) = cos(t), P (1) = 3,
8. The Lotka and Volterra predator-prey model
In the mid 20’s, an italian biologist, D’Ancona, was studying the varia-tions in the populations of different fish in the Mediterranean sea.
1 2 3 4 5 6 7 810
15
20
25
30
35
40
Años
P r o p o r c i ó n
d e
t i b u r o n e s c a p
t u r a d o s
Figure 4. Evolution of the shark captures (percentage)
Year % sharks1914 11.91915 21.41916 22.11917 21.21918 36.41919 27.31920 16.01921 15.9
Table 1. Shark captures
He noticed that from 1914 to 1918 the captures go from 11.9 to 36.4%. Let’s recall that the Great War or World War I devastate Europe andAfrica during the same years. D’Ancona ask Vito Volterra, an italian math-ematician, about the problem. Volterra simplified the problem with somehypotheses:
(1) There are only preys, F , and predators, S .(2) There is no growth restriction for the preys. This means that, in
absence of sharks, the prey population grows according to Malthuslaw.
(3) The number of encounters between preys and predators depends
from the populations itself as F S .
8/18/2019 differential1921
11/16
17B NOTES 11
(4) In absence the preys, the predators starve and die with an exponen-tial decay.
(5) The predator population grows when the sharks are fed.(6) There is no other effect (like fishing...).
With these hypotheses, the system of equations is
dF
dt = F − SF
dS
dt = −cS + SF
To find the equilibria of this system we need to solve
0 = F − SF
0 = −S + SF
The solutions are (0, 0) and (1, 1). The first point, the origin is not veryinteresting as it represent the absence of animals in the sea. Around thepoint (1, 1), we find closed curves (see Figure 5). This means that the fishand shark population oscillates (the qualitative behaviour is like sin(x) andcos(x)).
prey ’ = (A − B predator) preypredator ’ = (D prey − C) predator
B = 0.01D = 0.005
A = 0.4C = 0.3
0 20 40 60 80 100 120
0
10
20
30
40
50
60
70
80
prey
p r e d a t o r
Lotka−Volterra
Figure 5. Fishes vs. Sharks
To prove rigorously this qualitative behaviour is not so easy. So, we aregoing to address the problem in a different way. Let’s assume that thepopulations are
S (t) = 1 + δs(t), F (t) = 1 + δf (t) with |δ |
8/18/2019 differential1921
12/16
12 R. GRANERO-BELINCHÓN
δ df
dt = 1 + δf − (1 + δs)(1 + δf )
δ dsdt
= −(1 + δs) + (1 + δs)(1 + δf )
δ df
dt = 1 + δf − (1 + δf + δs + δsδf )
δ ds
dt = −1 − δs + 1 + δf + δs + δfδs
δ df
dt = −δs − δsδf
δ ds
dt = δf + δfδs
Now, we simplify δ
df
dt = −s − sδf ds
dt = f + f δs
As δ
8/18/2019 differential1921
13/16
17B NOTES 13
where r is the rate of new infected coming from encounters between infectedindividuals and susceptible individuals and β is the amount of people that
are healthy again.
Example 5. Use the integrating factor method to compute the number of infected individuals:
[*** Multiplying by eβt, we get
eβtdI
dt + βeβtI (t) = rS (t)eβtI (t),
d
dt
eβtI (t)
= rS (t)eβtI (t),
I (t) = I (0)e−βt + e−βtr
t0
S (s)eβsI (t)ds,
***]Notice that the total population is
N (t) = S (t) + R(t) + I (t),
and its variation isd
dtN (t) =
d
dtS (t) +
d
dtR(t) +
d
dtI (t) = using the system = 0.
So, the total population doesn’t change. Then as the total populationdoesn’t change,
N (t) = N (0) = S (0) + R(0) + I (0) ⇒ R(t) = N (0) − I (t) − S (t).
To simplify, let’s take N (0) = 1 (thus, S, R, I are percentages). The system(1) now reads
(2)
dS
dt = −rS (t)I (t)
dI
dt = rS (t)I (t) − βI (t)
The equilibria are solutions of
−rSI = 0 and rSI − βI = 0,
so, from the first equation, S = 0 or I = 0, and, from the second equation,I (rS − β ) = 0. Thus, writing (S, I )
(0, 0), (β/r, 0).Then notice that the evolution of the amount of infected people depends onthe amount of healthy people in a straightforward way:
if S (t) = β
r ⇒
d
dtI (t) = 0,
if S (t) > β
r ⇒
d
dtI (t) > 0,
if S (t) < β
r ⇒
d
dtI (t) < 0.
So, we conclude a very interesting fact: if initially
S (0) >
β
r ⇒ the number of infected individuals grows,
8/18/2019 differential1921
14/16
14 R. GRANERO-BELINCHÓN
s ’ = − r s ii ’ = r s i − b i
r = 0.2b = 0.1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
s
i
Modelo S−I−R
Figure 6. SIR Model
S (0) < β
r ⇒ the number of infected individuals decays.
This means that a vaccination procedure that ensure a low number of S (depending on the particular illness) is enough to guarantee the health of the group. So, we don’t need to vaccinate everyone in the population, onlythe required amount.
10. A model for a zombie outbreak
We are going to explain the model by P. Munz, I, Hudea, J. Imad, R.Smith? (notice that the ’?’ is not a typo, it’s his real name), When zombies attack!: mathematical modelling of an outbreak oz zombie infection . Nowthe population can be split (again) in three subsets:
• Susceptible (S )
• Zombie (Z )
• Removed (R)
The removed set is formed by the people who recently died and defeatedzombies. A zombie can appear from two different situations:
(1) Resurrected from the recently deceased (from R group).(2) People recently bitten by a zombie (from S group).
A zombie can move from group Z to group R if its brain is destroyed. The
flow of this situation is more complicated than the standard S IR model:
8/18/2019 differential1921
15/16
17B NOTES 15
S
❄ ❄ ❄ ❄ ❄ ❄ ❄ ❄
Z
R
Figure 7. Dr. Zombie by Jorge David (Wikipedia)
The system for this situation is, where α,β, γ,δ are positive constants,
(3)
dS
dt
= −αS (t)Z (t) − βS (t)
dZ
dt = αS (t)Z (t) − γS (t)Z (t) + δR(t)
dR
dt = βS (t) + γS (t)Z (t) − δR(t)
where
αS (t)Z (t) the rate of alive people that are bitten,
βS (t) the rate of alive people that die by other reasons (traffice accident, say),
γS (t)Z (t) the rate of zombies that die (again),
δR(t) the rate of dead people that resurrect as a zombie.
8/18/2019 differential1921
16/16
16 R. GRANERO-BELINCHÓN
11. A model for Bieber fever
We are going to explain the model by V. Tweedle and R. Smith? (noticethat the ’?’ is not a typo, it’s his real name), A mathematical model of Bieber Fever: The most infectious disease of our time? . Now the population canbe split (again) in three subsets:
• Susceptible (S )
• Bieber infected or ’Belieber’ (B)
• Recovered (R)
We assume that susceptible people can become Bieber infected according tosome rate β (due Bieber’s music) and rate P due to (positive) media effect.Susceptible people, due to (negative) media effect, can become recovered atrate N . Beliebers can become bored of Bieber (recovered) at rate b and dueto (negative) media effect may become susceptible again (due to negativemedia effect) at rate N . Due to (positive) media effect, a recovered personmay become susceptible again at rate P . The flow now is
S
❅ ❅ ❅ ❅ ❅ ❅
❅
B
R
❅ ❅ ❅ ❅ ❅ ❅ ❅
The system is
(4)
dS dt
= N B(t) − N S (t) − βS (t) − P S (t) + P R(t)
dB
dt = −N B(t) − bB(t) + βS (t) + P S (t)
dR
dt = N S (t) + bB(t) − P R(t)
12. Exercises
Exercise 4. Define N (t) = S (t) + Z (t) + R(t) as in (3). Study its evolution in time and define a new system, equivalent to (3) with only to unknown.(HINT: Compare (1) and (2))
Exercise 5. Find the equilibria for the system (3).
Exercise 6. Define N (t) = S (t) + B(t) + R(t) as in (4). Study its evolution in time and define a new system, equivalent to (4) with only to unknown.(HINT: Compare (1) and (2))
Exercise 7. Find the equilibria for the system (4).
Exercise 8. Find the equilibria for the system (4) without media effects ( P = N = 0).
E-mail address : [email protected]
Department of Mathematics, University of California, Davis, CA 95616,USA