You are on page 1of 16

A CRASH COURSE ON DIFFERENTIAL EQUATIONS

AND ITS APPLICATIONS

RAFAEL GRANERO-BELINCHON
Abstract. In this notes we present some autonomous differential equations and applications. We also provide some examples with solutions
(in blue).

Contents
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Introduction
Malthus law
Limited growth and equilibrium
Logistic growth
Integrating factors
Forward Euler method
Exercises
The Lotka and Volterra predator-prey model
SIR models for epidemics
A model for a zombie outbreak
A model for Bieber fever
Exercises

1
1
2
4
6
7
9
10
12
14
16
16

1. Introduction
Remember that a differential equation has the general form
dn
dn1

P
(t)
=
F
(P
(t),
P
(t),
P
(t),
...,
P (t), t).
dtn
dtn1
In what follows (excerpt in the integrating factors part), we will restrict
ourselves to the case with n = 1 and where the function F does not depend
explicitly on t. Thus, we consider the case
P (t) = F (P (t)).
2. Malthus law
Lets start from the very beginning: Malthus Law. This population
dynamics model was introduced by Thomas Robert Malthus (XVIII). There
are 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


R. GRANERO-BELINCHON

The ordinary differential equation (ODE) is


dP
= rP (t), P (0) = P0 ,
dt
where P0 0 is the initial population and r R is the constant of proportionality. We solve that using that its a separable equation:
dP
dP
= aP (t)
= rdt,
dt
P
and, integrating,
Z
Z
dP
= r dt ln(P (t)) ln(P0 ) = r(t 0) P (t) = P0 ert .
P
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 to
Malthus 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 = P0 er9 = 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 finite
or the available resources are finite), the previous model doesnt apply and
should be modified.
(1) the rate of change of the population is a linear function of the population.
(2) there is growth restriction.
With these hypotheses we get
dP
= r(N P (t)), P (0) = P0 ,
dt
where r > 0 is the rate of growth and N is the maximum amount of individuals. We can solve the ODE as before,
dP

= rdt ln(|N P |) = rt + C N P (t) = ert+C ,


N P
where C is the constant appearing from the integration procedure. We need
to find this constant C. We have
P (t) = N ert+C , P (0) = N eC = P0 ln(N P0 ) = C.

17B NOTES

Figure 1. a) Cable about the muskrats to the New York


Times b) A muskrat.
We conclude
P (t) = N ert (N P0 ).
We notice that
lim P (t) = N,

and also that if P (t) = 0 if P (t) = N . This is an example of an extremely


important 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) or
unstable (i.e. the solution try to avoid them). Lets state these concepts in
a rigorous way:


R. GRANERO-BELINCHON

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 its
stable.
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
P (t)
= rP (t)(1
), P (0) = P0 .
dt
N
where r > 0 is the rate of growth and N is the maximum population. Both
parameters are data. As before, we have a separable equation, so
dP
2 = rdt,
P PN
Z
Z
dP
rdt,
2 =
P PN
using partial fractions, we get
Z
1
1
N
+
dP = rt + C,
P
P
1 N
where C is the constant appearing from the indefinite integration. Thus,
ln |1

N P (t)
P
| + ln |P | = rt + C
= ert+C ,
N
N 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) = P0 ,
so


N P0
N P0
N eC
C

= e C = ln
.
P (0) =
N + eC
N P0
N P0
When we introduce this expression for C we get
P (t) =

P (t) =

P0
N ert NNP
0
P0
N + ert NNP
0

1
N P0 ert N P
0
0
1 + ert N PP
0

N P0 ert
.
N + (ert 1)P0

This will be our final expression.


In the Figure 2, you can see the evolution of solutions corresponding to
different initial data, P0 .

17B NOTES
Logstica x = r x (1 x/N)

r=1

5
N=5

10
9
8
7

6
5
4
3
2
1
0
0

5
t

10

Figure 2. Solutions corresponding to different initial data, P0


Example 2. Lets assume that the world population follows a logistic growth.
Using the table
Year Population (millions)
1990
5263
1995
5674
2000
6070
2005
6454
2010
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) = P0 = 5263.
We have
5263N er5
,
P (5) = 5674 =
N + 5263(e5r 1)
5263N er10
.
N + 5263(e10r 1)
From these two equations we get N as a function of r in two
equivalent ways:
5674 5263(e5r 1)
,
N=
5263e5r 5674
6070 5263(e10r 1)
N=
.
5263e10r 6070
As both expressions are for the same value N (which is a unique
number), we have an equation for r
P (10) = 6070 =

6070 5263(e10r 1)
5674 5263(e5r 1)
=
.
5263e5r 5674
5263e10r 6070
Using e10r 1 = (e5r + 1)(e5r 1), after some simplifications,
6070(e5r + 1)
5674
=
,
5263e5r 5674
5263e10r 6070


R. GRANERO-BELINCHON

and
5674(5263e10r 6070) = 6070(e5r + 1)(5263e5r 5674).
If we write x = e5r the previous equation is a second order
algebraic equation thar we can solve with the second order
equation 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 7123
million people on Earth. ***]
Lets notice that the equilibria for the logistic equation are
y = 0 and y = N.
In this case the derivative is
d
d
(rP (1 P/N )) =
(rP rP 2 /N ) = r 2rP/N.
F (P ) =
dP
dP
When we evaluate F (P ) at the equilibria, using r > 0, we get
F (0) = r > 0 and F (N ) = r 2r = r < 0,
so, y = 0 is an unstable equilibrium and y = N is a stable equilibrium (see
Figure 2).
5. Integrating factors
Lets assume that we have the following equation
P (t) = (t)P (t) + f (t), P (0) = P0 .
Notice that this equation is NOT autonomous. We are going to use the
Fundamental theorem of Calculus with the chain rule to solve this equation.
The idea is to find a function (the integrating factor) such that, by multiplying by this function, we get an exact derivative on the left hand side.
Notice that
Z
d t
(s)ds = (t),
dt 0
and notice that

d  (t)
e P (t) = e(t) P (t) + P (t) (t)e(t) .
dt
Our equation can be written
P (t) + (t)P (t) = f (t), P (0) = P0 ,
so, if we multiply both sides by
Rt

(s)ds

we get
Rt

(s)ds

Rt

P (t) + e

(s)ds

Rt

(t)P (t) = e

(s)ds

f (t), P (0) = P0 .

17B NOTES

Rt
Now we use the previous formula with (t) = 0 (s)ds, and we get

Rt
d  R t (s)ds
e0
P (t) = e 0 (s)ds f (t).
dt
Integrating
 Rt
 Z t Ru
(s)ds
0
e
e 0 (s)ds f (u)du + C,
P (t) =
0

Z t R
Rt
u
e 0 (s)ds f (u)du + C .
P (t) = e 0 (s)ds
0

To fix the constant, notice that

P (0) = P0 = e

R0
0

(s)ds

Z

0 Ru

(s)ds

f (u)du + C

= C.

Example 3. Solve
P (t) = 4P (t) + f (t), P (0) = P0 .
[*** We need to find the integrating factor. As before, notice that the equation reads
P (t) + 4P (t) = f (t), P (0) = P0 ,
and, multiplying by e4t we get,

d 4t
e P (t) = e4t f (t), P (0) = P0 .
e4t P (t) + 4e4t P (t) =
dt
Integrating,
Z t
Z t
4s
4t
4t
e f (s)ds + C P (t) = e
e4s f (s)ds + e4t C.
e P (t) =
0

To find the constant we use the initial data:


Z t
P0 = C P (t) = e4t
e4s f (s)ds + e4t P0 .
0

***]
6. Forward Euler method
In general its very difficult (or even impossible) to find the exact solution
of a given differential equation. As you can imagine, we are going to use
the computer to find an approximate solution. The construction of numerical 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) = P0 .
Integrating we get
P (t) P (0) =

F (P (s))ds.

The problem is that, as we dont have the expression for P (s), the RHS has
no meaning. Then we are going to approximate the RHS as
Z t
F (P (s))ds tF (P (0)).
0


R. GRANERO-BELINCHON

This is just some sort of Riemann sum (as it was presented in the very
beginning of the course) taking the height of the rectangle equal to the
left endpoint. To achieve a better accuracy, if we want to approximate
the solution up to time T > 0, we are going to define a partition (with n
subintervals) of the time interval
0 = t0 < t1 = T /n < t2 = 2T /n, ..., tn = T,
and we are going to compute n step:
Z t1
F (P (s))ds (t1 t0 )F (P (t0 )),
P (t1 ) P (t0 ) =
t0

P (t2 ) P (t1 ) =

t2

F (P (s))ds (t2 t1 )F (P (t1 )),

t1
Z t3

P (t3 ) P (t2 ) =

F (P (s))ds (t3 t2 )F (P (t2 )),

t2

until
P (tn ) P (tn1 ) =

tn

F (P (s))ds (tn tn1 )F (P (tn1 )).


tn1

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, lets compute the solution. As before,
dy
1
1
= t + C y(t) =
.
= dt
2
y
y(t)
t C
Now we use the initial data to fix the constant C:
1
C = 1,
y(0) = 1 =
C
so
1
y(t) =
.
1t
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 AFTER
t = 1!!! and we know that the exact solution (red) doesnt!!!
***]
%% Forward Euler Method
%% Number of time steps
N=50;
%% Final time

17B NOTES

90

80

70

60

50

40

30

20

10

0.2

0.4

0.6

0.8

1.2

1.4

Figure 3. Exact solution (red) and approximate solution


(blue) corresponding to the same initial data, P0 = 1.
T=2;
dt=T/(N-1);
t=[0:dt:T];
%% Initial data
y0=1;
y(1)=y0;
for j=1:length(t)-1
y(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 (0) = 1
P (t)

c)P (t) =

P (t)
, P (1) = 4
3t

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


R. GRANERO-BELINCHON

10

Exercise 3. Find the integrating factor and solve the following ODE
a)P (t) + t2 P (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 20s, an italian biologist, DAncona, was studying the variations in the populations of different fish in the Mediterranean sea.
40

Proporcin de tiburones capturados

35

30

25

20

15

10

Aos

Figure 4. Evolution of the shark captures (percentage)

Year % sharks
1914
11.9
1915
21.4
1916
22.1
1917
21.2
1918
36.4
1919
27.3
1920
16.0
1921
15.9
Table 1. Shark captures

He noticed that from 1914 to 1918 the captures go from 11.9 to 36.4
%. Lets recall that the Great War or World War I devastate Europe and
Africa during the same years. DAncona ask Vito Volterra, an italian mathematician, about the problem. Volterra simplified the problem with some
hypotheses:
(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 Malthus
law.
(3) The number of encounters between preys and predators depends
from the populations itself as F S.

17B NOTES

11

(4) In absence the preys, the predators starve and die with an exponential 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 = F SF
dt
dS

= cS + SF
dt
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 very
interesting as it represent the absence of animals in the sea. Around the
point (1, 1), we find closed curves (see Figure 5). This means that the fish
and shark population oscillates (the qualitative behaviour is like sin(x) and
cos(x)).
prey = (A B predator) prey
predator = (D prey C) predator

A = 0.4
C = 0.3

LotkaVolterra

B = 0.01
D = 0.005

80

70

60

predator

50

40

30

20

10

0
0

20

40

60
prey

80

100

120

Figure 5. Fishes vs. Sharks


To prove rigorously this qualitative behaviour is not so easy. So, we are
going to address the problem in a different way. Lets assume that the
populations are
S(t) = 1 + s(t), F (t) = 1 + f (t) with || << 1.
This means that initially our populations are close to (1,1). If we plug our
assumption in the equations, we get
d
d
d
d
S = s,
F = f.
dt
dt dt
dt


R. GRANERO-BELINCHON

12

df = 1 + f (1 + s)(1 + f )
dt
ds


= (1 + s) + (1 + s)(1 + f )
dt

df = 1 + f (1 + f + s + sf )
dt
ds


= 1 s + 1 + f + s + f s
dt

df = s sf
dt
ds


= f + f s
dt
Now, we simplify

df = s sf
dt
ds

= f + f s
dt
As << 1 we can approximate the system by the simpler system

df = s
dt
ds

=f
dt
Now, notice that, if we take a second derivative in any of the previous
equation, we get
d2 f
d
= s = by the second equation = f.
2
dt
dt
Recall that

d2
sin(x) = sin(x),
dt2
so, we can expect (kind of) periodic solutions close to the equilibrium (1,1).
9. SIR models for epidemics
Lets assume that we have a population that can be split in three subsets:
Susceptible (S)
Infected (I)
Recovered (they cant get sick again)(R)
The flow of an epidemic is
S I R.
The model is

(1)

dS

= rS(t)I(t)

dt
dI
= rS(t)I(t) I(t)

dt

dR

= I(t)
dt

17B NOTES

13

where r is the rate of new infected coming from encounters between infected
individuals 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 et , we get
dI
+ et I(t) = rS(t)et I(t),
et
dt

d  t
e I(t) = rS(t)et I(t),
dt
Z
t

S(s)es I(t)ds,

I(t) = I(0)et + et r

***]
Notice that the total population is
N (t) = S(t) + R(t) + I(t),
and its variation is
d
d
d
d
N (t) = S(t) + R(t) + I(t) = using the system = 0.
dt
dt
dt
dt
So, the total population doesnt change. Then as the total population
doesnt change,
N (t) = N (0) = S(0) + R(0) + I(0) R(t) = N (0) I(t) S(t).
To simplify, lets take N (0) = 1 (thus, S, R, I are percentages). The system
(1) now reads

dS = rS(t)I(t)
dt
(2)
dI

= rS(t)I(t) I(t)
dt
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 on
the amount of healthy people in a straightforward way:

d
if S(t) = I(t) = 0,
r
dt

d
if S(t) > I(t) > 0,
r
dt

d
if S(t) < I(t) < 0.
r
dt
So, we conclude a very interesting fact: if initially

S(0) > the number of infected individuals grows,


r


R. GRANERO-BELINCHON

14
s=rsi
i=rsibi

r = 0.2
b = 0.1

Modelo SIR

1
0.9
0.8
0.7

0.6
0.5
0.4
0.3
0.2
0.1
0
0

0.1

0.2

0.3

0.4

0.5
s

0.6

0.7

0.8

0.9

Figure 6. SIR Model

the number of infected individuals decays.


r
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 dont need to vaccinate everyone in the population, only
the required amount.
S(0) <

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, its his real name), When zombies
attack!: mathematical modelling of an outbreak oz zombie infection. Now
the 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 defeated
zombies. 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 SIR model:

17B NOTES

15

/Z
O

 

Figure 7. Dr. Zombie by Jorge David (Wikipedia)


The system for this situation is, where , , , are positive constants,

dS

= S(t)Z(t) S(t)

dt
dZ
(3)
= S(t)Z(t) S(t)Z(t) + R(t)

dt

dR = S(t) + S(t)Z(t) R(t)


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


R. GRANERO-BELINCHON

16

11. A model for Bieber fever


We are going to explain the model by V. Tweedle and R. Smith? (notice
that the ? is not a typo, its his real name), A mathematical model of Bieber
Fever: The most infectious disease of our time?. Now the population can
be split (again) in three subsets:
Susceptible (S)
Bieber infected or Belieber (B)
Recovered (R)
We assume that susceptible people can become Bieber infected according to
some rate (due Biebers music) and rate P due to (positive) media effect.
Susceptible people, due to (negative) media effect, can become recovered at
rate N . Beliebers can become bored of Bieber (recovered) at rate b and due
to (negative) media effect may become susceptible again (due to negative
media effect) at rate N . Due to (positive) media effect, a recovered person
may become susceptible again at rate P . The flow now is
S _ o

/B

 

The system is

(4)

dS
= N B(t) N S(t) S(t) P S(t) + P R(t)
dt
dB
= N B(t) bB(t) + S(t) + P S(t)
dt
dR
= N S(t) + bB(t) P R(t)
dt
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: rgranero@math.ucdavis.edu
Department of Mathematics, University of California, Davis, CA 95616,
USA

You might also like