Вы находитесь на странице: 1из 34

numerical methods for

differential equations and


applications

Supervisor: Camile Fraga Delfino Kunz

November 13th, 2018


What do we have for today?

Introduction to continuous models


Direction fields
Ordinary Differential Equations (ODE’s)
Euler Method
Introduction to continuous models
Example: Growth of microorganisms
Consider the simple experiment of growing bacteria on a
nutrient medium. If we put them in favorable conditions they
will have a constant growth rate λ over time. For N(t) as the
bacterial density at time (minutes) t, this situation can be
modeled by the equation:

N(t + 1) = N(t) + λ N(t)

or
N(t + 1) − N(t)
= λ N(t)
1
Introduction to continuous models
Example: Growth of microorganisms
Or if we consider the change over 30 sec = 0.5 min,
N(t + 0.5) − N(t)
= λ N(t)
0.5
or for an arbitrary time change h,
N(t + h) − N(n)
= λ N(t)
h
for h → 0,
N(t + h) − N(t)
lim = N 0 (t) = λ N(n)
h→0 h
Introduction to continuous models
Example: Growth of microorganisms
Thus for this example we get the following differential equation
that models the bacteria growth on a nutrient medium:

dN(t)
= K N(t)
dt

This equation was first studied by Malthus (1779) to


model populations growth.
What does it mean to say that we got a solution for this
equation?
And how we can find this solution?
Example: Growth of microorganisms
Find the solution for this equation means that we have a
function N(t) that satisfies the relation between it’s derivative
and itself over the time t. Writing:
dN
= Kdt
Z N Z
dN
= λ dt
N
ln(N) = Kt + c0
N = e Kt+c0

we get the solution N(t) = N0 e λt , where N0 is a constant


determined by the initial conditions.
Example: Growth of microorganisms
Using the obtained solution with λ = 1 and plotting for many
different initial densities N0 , we get the following solutions for
N(t):
Direction Fields
Taking into account that N 0 (t) represents the slope of the
tangent line at each point t, we can draw a small line of
segment of slope dN/dt (the solution is tangent to this lines).
Introduction to continuous models
Example: Growth of microorganisms
Or if we consider the change over 30 sec = 0.5 min, In
practice the microorganisms doesn’t grow indefinitely. There
are space and nutrients restrictions that slow down their
growing rate. For take into account these restrictions, we
could use the models:
dN  N
Verhulst (1837): = λN 1 −
dt K
dN K
Gompertz (1836): = λN ln
dt N
where λ is the growth rate and K is capacity of the
environment.
Example: Growth of microorganisms
For the Verhulst model with λ = 1 and K = 2, we have
following directions field graph:

What are the steady state for this equation?


Example: Growth of microorganisms

The solution for this equation is more difficult to be


obtained analytically, since it is nonlinear.
We can have an idea of the behavior of the solution by
studying the steady states and it’s stability.
By the direction field graph we see two steady states:
N̄1 = 0 and N̄2 = 2. The first one is unstable and the
second is stable.
Classification of Differential Equations

Ordinary Differential Equation (ODE): the unknown


function depends on a single variable. Example: consider
u = u(t),

du
= tu 2
dt
Partial Differential Equation (PDE): the unknown
function depends on more than on variable. Example:
consider u = u(x, t),

∂u ∂ 2u
= 2
∂t ∂t
Classification of Differential Equations

Systems of differential equations: when we have more


than one unknown function to solve, it is classified as a
system of ODE’s or PDE’s;
Order: the order of the equation or of the system is the
order of the highest derivative that appears on the
equation;
Linear and nonlinear: the equation is called linear if the
function that defines the unknown is linear, else it is
called non linear.
First Order ODE’s

The first order differential equation can be written like


dy
= f (y , t)
dt
We are going to consider the linear case for start:
dy
+ p(t)y = g (t)
dt
and use the Method of Integrating Factor to solve it.
Method of Integrating Factor

The idea is to determine an appropriate integrating factor µ(t)


to multiply the original EDO and make easier to find it’s
solution:
dy
µ(t) + µ(t)p(t)y = µ(t)g (t)
dt
The left side of this equation is the derivative of µ(t)y ,
provided that µ(t) satisfies the equation

dµ(t)
= p(t)µ(t)
dt
Method of Integrating Factor

So we have:
dµ(t)
= p(t)dt
µ(t)
Z Z
dµ(t)
= p(t)dt
µ(t)
Z
ln µ(t) = p(t)dt + C
Z
µ(t) = exp p(t)dt

we choose arbitrary the constant C to be zero.


Example (Method of Integrating Factor):
dy
Solve the equation dt
− 2y = 4 − t. The integrating factor is
µ(t) = e −2t :
dy
− 2y = 4 − t
dt
dy
e −2t − e −2t 2y = e −2t (4 − t)
dt
d
(−e −2t y ) = 4e −2t − te −2t
dt
Integrating the both sides of this equation we have:
1 1
−e −2t y = −2e −2t + e −2t + e −2t + c
2 4

7 1
So the general solution is y (t) = − + t + ce 2t
4 2
Example (Method of Integrating Factor):
dy
Solve the equation dt
− 2y = 4 − t. The integrating factor is
µ(t) = e −2t :
dy
− 2y = 4 − t
dt
dy
e −2t − e −2t 2y = e −2t (4 − t)
dt
d
(−e −2t y ) = 4e −2t − te −2t
dt
Integrating the both sides of this equation we have:
1 1
−e −2t y = −2e −2t + e −2t + e −2t + c
2 4

7 1
So the general solution is y (t) = − + t + ce 2t
4 2
Numerical Approximations: Euler’s Method
Initial Value Problem
Suppose that f is a continuous function, then the following
initial value problem (IVP) has unique solution:

dy
= f (t, y ) , y (t0 ) = y0
dt
Until now we saw ways to easily solve linear first order ODE’s.
But modelling the real world can be much more nonlinear and
obtaining a analytic solution can be a hard work.

That’s why we give up on trying to find an exact solution and


use computational methods to obtain an approximation
instead.
Numerical Approximations: Euler’s Method
Considering t0 we can obtain a first order approximation for y
around this point, because we know the value of the slope of
the tangent line on this point y 0 (t0 ) = f (t0 , y0 ).

Image from [2]


This line evaluated on the point t1 we call it y1 and we
consider it an approximation for the solution for the IVP, y .
Euler’s Method
Now we construct the line through (t1 , y1 ) using the slope
f (t1 , y1 ):

y = y1 + f (t1 , y1 )(t − t1 )

Proceeding like this successively we get the following


expression for the next point (tn+1 , yn+1 ) and considering that
(tn , yn ) was calculated:

yn+1 = yn + f (tn , yn )(tn+1 − tn ) , n = 0, 1, 2, . . .

If we have a fixed time step k = ti+1 − ti , we can write

yn+1 = yn + kf (tn , yn ) , n = 0, 1, 2, . . .
Example (Euler’s Method): Verhulst equation
Let us come back to the bacteria’s problem using Verhulst.
Considder that in the initial time t = 0 the bacteria’s density
is N(0) = 0.1, the intrinsic growth rate λ = 1 and the carrying
capacity K = 2.
dN  N
= λN 1 − = f (N)
dt K
The Euler’s method is given by Nn+1 = Nn + ∆t f (Nn ),
n = 0, 1, . . ..
Supose that we want to study the behavior of the IVP on the
interval I = [0, 1] and partitioning it by the points
P = {t0 = 0, t1 = 0.25, t2 = 0.5, t3 = 0.75, t4 = 1}.
So our time step will be ∆t = 0.25.
Example (Euler’s Method): Verhulst equation

t1 : N1 = 0.1 + 0.25 ∗ f (0.1) = 0.1237


t2 : N2 = 0.1237 + 0.25 ∗ f (0.1237) = 0.1528
t3 : N3 = 0.1528 + 0.25 ∗ f (0.1528) = 0.1880
t4 : N4 = 0.1880 + 0.25 ∗ f (0.1880) = 0.2306
Numerical Approximations: Euler’s Method
How good is our approximation?
A natural question is to know how good is our approximation,
or: how much are we mistaking?
On the Euler’s method we are doing a approximation using
first order Taylor polynomial at each point:
yn+1 = yn + ∆t f (yn , tn )

We already know that the error is


y 00 (c) 2
E (tn+1 ) = ∆t
2
for some c ∈ [tn , tn+1 ]. Obs: for calculating y 00 (c) we would
have to know the analytic solution.
System of linear ODE’s
Consider the system of ODE’s:
dx
= a11 x + a12 y
dt
dy
= a21 x + a22 y
dt
This system can be written as dX /dt = AX , where X = (x, y )
and A is the coefficient matrix for the system. As we already
studied for the difference equations, the solution for this
system will be
X (t) = v e λ t

where v is an eigenvector for A and λ the associated


eigenvalue.
Example (System of linear ODE’s):
Consider the system of ODE’s:
dx
= 3x − y
dt
dy
= 6x − 4y
dt
Find it’s analytic solution. (You can use the Matlab to obtain
that)
The eigenvalues are λ1 = 2 and λ2 = −3. The eigenvectors
are v1 = (0.0710, 0.0710)T and v2 = (0.1644, 0.9864)T . So by
these values we can determine the analytic solution.
System of linear ODE’s
Steady State
We can determine the steady states of the equation by setting
dx
= f (x̄, ȳ ) = 0
dt
dy
= g (x̄, ȳ ) = 0
dt
On the linear case it means find the solution (x̄, ȳ ) for the
system AX̄ = 0. If A is non-singular (invertible), the system
admits only the trivial solution (0, 0). Otherwise, it can have
nonzero steady states.
System of linear ODE’s

When a steady state is stable?


According to [1], “in a continuous model, a steady state will
be stable provided that the eigenvalues of the characteristic
equation (associated to the linearized problem) are both
negative (if real) or have negative real part (if complex).”

Question: how we linearizate an equation?


Dealing with nonlinearities
Consider the nonlinear system of equations:
X 0 (t) = F (X , Y )
Y 0 (t) = G (X , Y )

The point (X̄ , Ȳ ) is a steady state if F (X̄ , Ȳ ) = 0 and


F (X̄ , Ȳ ) = 0. Consider the behavior around the steady state
X (T ) = X̄ + x(t)
Y (T ) = Ȳ + y (t)

We are going to find a linear approximation for the system


using bidimensional Taylor series around the steady state.
Dealing with nonlinearities
Linear Taylor polynomial approximation in 2D around (X̄ , Ȳ ):

F (X̄ + x(t),Ȳ + y (t)) =


∂F ∂F
F (X̄ , Ȳ ) + x(t) + y (t)
∂x X̄ ,Ȳ ∂y X̄ ,Ȳ

G (X̄ + x(t),Ȳ + y (t)) =


∂G ∂G
G (X̄ , Ȳ ) + x(t) + y (t)
∂x X̄ ,Ȳ ∂y X̄ ,Ȳ

Dealing with nonlinearities
Considering that F (X̄ , Ȳ ) = 0 and F (X̄ , Ȳ ) = 0, we can write
it as:
dx ∂F ∂F
= x(t) + y (t)
dt ∂x X̄ ,Ȳ ∂y X̄ ,Ȳ

dy ∂G ∂G
= x(t) + y (t)
dt ∂x X̄ ,Ȳ ∂y X̄ ,Ȳ

or in a matrix notation
     
dx/dt ∂F /∂x ∂F /∂y x(t)
=
dy /dt ∂G /∂x ∂G /∂y X̄ ,Ȳ y (t)
Application: Epidemiology
An simple model to describe an infectious disease on a
population is described by the system:
dS
= −βSI + γI
dt
dI
= βSI − γI
dt
where S is the susceptible and I is the infected population.
We consider a small period of time such that the total
population is constant. We also have the parameters:
β : rate of transmission of the disease;
γ : rate of recuperation from the disease.
Application: Epidemiology
We can find the steady states by setting

0 = −β S̄ I¯ + γ I¯
0 = β S̄ I¯ − γ I¯

So we have the possible steady states:


(S̄, I¯) = (0, 0);
(S̄, I¯) = (0, γ/β);
for analyzing the stability we calculate the Jacobian matrix
and it’s eigenvalues.
References

1. Edelstein-Keshet, L. Mathematical models in biology.


SIAM, 2005.

2. Boyce, W.E., DiPrima, R.C. Elementary Differential


Equations and Boundary Value Problems. John Wiley &
Sons,10th ed., 2012.

3. http://mathworld.wolfram.com/LogisticEquation

Вам также может понравиться