Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Technische Universität München WS 2017/18

Lehrstuhl für Informatik V Scientific Computing


Univ.-Prof. Dr. M. Bader 11.12.2017/13.12.2017
M.Sc. S. Seckler

Worksheet 6
Sample Solutions
Continuous Models: Ordinary Differential Equations

(H) Exercise 1: Critical Points and Direction Fields for Higher-Order ODEs

An ordinary differential equation of the form

f (t, y(t), dy/dt, d2 y/dt2 , . . . , dn y/dtn ) = 0 (1)

is called ODE of order n, i.e. the index of the highest derivative corresponds to the order of the
ODE. In order to facilitate the analysis of ODEs, every ODE of order n > 1 can be transformed
into a system of ODEs of order n = 1 as explained below.
First, assume our ODE from equation (1) to have order n > 1. Then, we can introduce helper
functions y0 , . . . , yn−1 :
y0 ( t ) : = y ( t ),
dy(t)
y1 ( t ) : = ,
dt
..
.
d n −1 y ( t )
y n −1 : = .
dtn−1

Second, using the helper functions, we can transform the ODE from equation (1) into the fol-
lowing system of ODEs:
dy0
= y1 ,
dt
dy1
= y2 ,
dt
..
.
dy0 dy1 dyn−1
f (t, y0 , , ,..., ) = 0.
dt dt dt
The latter system only consists of first-order derivatives with respect to the helper functions.
Complete the folowing tasks for the ODE

d2 y
= −y, (2)
dt2
which is defined on an interval t ∈ [0, π/2].
(a) Determine the order of this ODE.

1
(b) Transform the ODE into a system of first-order ODEs. Write the transformed system as

dy0
 
 
 dt  y0
 ..  . 

 .   .. 
 = A· (3)
dyn−1 y n −1
 
dt
with a system matrix A ∈ Rn×n .
(c) Similar to the one-dimensional case, homogeneous systems of ODEs, that is ODEs which
are of the form from equation (3) (without a constant vector b), can be solved analytically
using the exponential function for matrices. In case of equation (3) and initial conditions
y0 (0) = c0 , y1 (0) = c1 ,. . . , yn−1 (0) = cn−1 , the solution is given by:
   
y0 ( t ) c0
..  . 
 = exp( A · t)  ..  (4)
 
 .
y n −1 ( t ) c n −1

Use the results from the Worksheet 4 Exercise 4 to determine the general solution of equa-
tion (2). Which information is required to obtain a unique solution? Find at least two
approaches to obtain a unique solution for the given ODE.
(d) Consider the ODE from equation (2) and its respective matrix-vector form (equation (3)).
What can you say about its critical points and stability? Draw the direction field on
[−1; 1] × [−1; 1].
(e) Write a python script which plots the direction field to validate your theoretical results
from (d).
(f) Consider the modified ODE
d2 y ( t )
= −µ · y(t)
dt2
with µ ≥ 0. How does the parameter µ affect the critical point, stability and the direction
field from (d)? Modify your python script for this purpose.
(g) Consider the ODE
d2 y ( t ) dy(t)
2
= −µ · y(t) +
dt dt
with µ ∈ R \ {0}. What happens to the critical point, stability and direction field in this
case?

Solution:

(a) The index of the highest derivative in equation (2) is two. Hence, the order of the ODE is
n = 2.
(b) We introduce two functions y0 (t) and y1 (t) as follows:

y0 ( t ) = y ( t )
dy(t)
y1 ( t ) =
dt

2
From this, we obtain the following relation for the first derivatives of y0 , y1 :

dy0 (t) dy(t)


= = y1 ( t ) = 0 · y0 ( t ) + 1 · y1 ( t )
dt dt
dy1 (t) d2 y ( t )
= = − y ( t ) = − y0 ( t ) = −1 · y0 ( t ) + 0 · y1 ( t )
dt dt2
Now, we can write our first-order system of ODEs in the matrix-vector form:
 
dy0 (t)
    
 dt  0 1 y0 ( t )

= ·
−1 0 y1 ( t )

 dy1 (t) 
dt
with matrix  
0 1
A := ∈ R2×2 .
−1 0

(c) From Worksheet 4 Exercise 4 we know that the exponential exp( A · t) for our matrix A
from above has the form
 
cos(t) sin(t)
exp( A · t) = I · cos(t) + A · sin(t) =
− sin(t) cos(t)

The general solution of our ODE hence looks as follows:


     
y0 ( t ) cos(t) sin(t) c0
= ·
y1 ( t ) − sin(t) cos(t) c1

Different possibilities exist to determine a unique solution, for example:


• Fix the solution of y(t) = y0 (t) at both sides of the defined interval, i.e. prescribe
y(0) := K0 and y(π/2) := K1 . Inserting these relations into the first equation of our
system delivers c0 = K0 , c1 = K1 .
• Fix the solution of y(t) = y0 (t) at one side and also fix its derivative. For this purpose,
we can prescribe y(0) := K0 and dy(0)/dt = y1 (0) := K1 . Inserting these relations
into the solution of the ODE system from above yields c0 = K0 and c1 = K1 .
(d) The eigenvalues of the underlying matrix
 
0 1
A := ∈ R2×2
−1 0

are given by λ = ±i. The eigenvalue is complex and its real part is zero. Following the
table on “Stability of Linear Systems” (cf. Slide 27 of the lecture population2.pdf), the
system is therefore expected to be stable and to have a “centered” critical point. Since A
has full rank and since our system is homogeneous, the critical point is given by A−1~0 =
~0.
(e) See ws6 ex1.py.

(f) See ws6 ex1.py. The eigenvalues arise in this case to be λ = ± µi. The stability is
– according to the overview from the lecture – still guaranteed. The matrix A has full

3
rank for all µ 6= 0; the critical point remains at ~0 in this case. The direction field has an
ellipsoidal shape.
For µ = 0, the ODE reads d2 y(t)/dt2 = 0 and has the solution y(t) = c · t + d with
constants c, d ∈ R. The only eigenvalue of A is λ = 0 in this case.
(g) See ws6 ex1.py. Re-writing the ODE as a system of first-order ODEs yields a homoge-
neous system (y0 (t), y1 (t))> = A · (y0 (t), y1 (t))> with matrix
 
0 1
A := .
−µ 1
p
1± 1 − 4µ
The eigenvalues are λ0,1 = . Since µ 6= 0, the inverse of A exists and is given
2
by  
1 1 −1
A −1 : = .
µ µ 0
For
• µ = 0.25, we have only one real eigenvalue λ0 = λ1 = 0.5 > 0. From the overview in
the lecture, we expect the system to have a single node as critical point and unstable
behaviour. Since the system is homogeneous, the critical point is again given by ~0.
• µ < 0.25, we have two real-valued eigenvalues. If
– 0 < µ < 0.25, all eigenvalues are bigger than zero ⇒ critical point is a node,
system is unstable
– µ < 0, one eigenvalue is bigger and one eigenvalue is smaller than zero ⇒
critical point is a saddle point, system is unstable
• µ > 0.25, we have complex eigenvalues, λ0,1 = 12 ± 4µ − 1i. Since the real part
p

of the eigenvalues is always bigger than zero, we expect a spiral point and unstable
behavior.

(I) Exercise 2: Nonlinear ODE – Logistic Function

The logistic function is given as


dx
= ax − bx2 . (5)
dt
(a) Calculate the critical points x ∗ and derive their stability for b > 0.
(b) Plot the value of the critical points as function of a/b for a/b ∈ [−1, 1]. Mark their stabil-
ity.

Solution:

(a) For the critical points x ∗ the time derivative vanishes.



dx
=0
dt x∗

This holds true at the points x1∗ = 0 and x2∗ = ba .

4
To determine the stability of these points one has to calculate the spatial derivative of dx dt .
If the real part of the derivative is less than zero at the critical points, it is stable, otherwise
it is unstable. 
  < 0 : stable
∂ dx 
Re > 0 : unstable
∂x dt 
= 0 : both possible

∂ dx
The spatial derivative of the logistic function is ∂x dt = a − 2bx. Thus the critical point

x1 = 0 is stable for a < 0 and unstable for a > 0. For a = 0 equation (5) can be rewritten
as dx 2 ∗ ∗ a
dt = − bx . The point x = 0 then is a saddle point. For x2 = b the derivative becomes
∂ dx
∂x dt = − a. The point is stable when a > 0, unstable for a < 0 and is a saddle point for
a = 0.
(b) Figure 1 shows the bifurcation diagram for the logistic function. Stable points are marked
green, unstable red. Remark: in the bifurcation point a = 0 the two critical points collide
and swap their stability. This behavior is called transcritical bifurcation.

Figure 1: Bifurcation diagram of the continuous logistic equation. Stable points are marked
green, unstable red.

(I) Exercise 3: Nonlinear Dynamic System – Linear Stability Analysis

The stability of a nonlinear system of ODEs can be determined by considering the linear behav-
ior of this system in the neighborhood of the critical points. Without loss of generality, consider
two first-order differential equations:

dx
= u( x, y)
dt (6)
dy
= v( x, y)
dt

If x0 and y0 are critical points of the general system of ODEs (6), we can expand this system

5
about ( x0 , y0 )
∂2 u

d(δx ) ∂u ∂u
= δx + δy + δxδy + . . .
dt ∂x (x,y)=(x0 ,y0 ) ∂y (x,y)=( x0 ,y0 ) ∂x∂y (x,y)=( x0 ,y0 )
(7)
∂2 v

d(δy) ∂v ∂v
= δx + δy + δxδy + . . .
dt ∂x (x,y)=( x0 ,y0 ) ∂y (x,y)=( x0 ,y0 ) ∂x∂y (x,y)=( x0 ,y0 )

where we denoted δx = x − x0 and δy = y − y0 .


The first order approximation then is given by
!
  ∂u ∂u    
d δx ∂x ∂y δx δx
= ∂v ∂v · = J· (8)
dt δy ∂x ∂y
δy δy
( x,y)=( x0 ,y0 )

The matrix J is called the Jacobian or stability matrix. By analysing the eigenvalues of this
matrix in the same way as for linear systems we determine the stability and type of the critical
points.
As an example consider a general competing species model
dx
= 36x − 12x2 − 2xy
dt (9)
dy
= 30y − 6y2 − 6xy
dt
where two species are denoted by x ≥ 0 and y ≥ 0.
To analyze the evolution of the species complete the following tasks:
(a) Find all the critical points of the dynamic system.
(b) Compute the Jacobian matrix of the dynamic system and analyze the stability and type
of the critical points.
(c) Sketch a phase portrait or direction field of the given two species model, marking all the
critical points on your sketch.

Solution:

(a) To find the critical points we solve the system of equations with all time derivatives set to
zero
x (36 − 12x − 2y) = 0
y(30 − 6y − 6x ) = 0
The elementary solution of this system of equations is ( x, y)1 = (0, 0).
Next, we set x = 0 and solve 30 − 6y = 0 to find y, what gives ( x, y)2 = (0, 5).
Similarly, for y = 0 and 36 − 12x = 0 we obtain ( x, y)3 = (3, 0).
Finally, to find the last root of the system we solve the following linear system
12x + 2y = 36
6y + 6x = 30
which yields ( x, y)4 = (2.6, 2.4).

6
(b) The Jacobian matrix takes the form
 
36 − 24x − 2y −2x
J=
−6y 30 − 12y − 6x

Next, we analyze the stability and type of the critical points by computing eigenvalues of
the Jacobian matrix at this points.
• Point ( x, y)1 = (0, 0):  
36 0
J (0, 0) =
0 30
The eigenvalues of this Jacobian are both positive λ1 = 36 and λ2 = 30, so this is an
unstable node.
• Point ( x, y)2 = (0, 5):  
26 0
J (0, 5) =
−30 −30
The eigenvalues of the matrix are λ1 = 26 > 0 and λ2 = −30 < 0, so we have a
saddle point.
• Point ( x, y)3 = (3, 0):  
−36 −6
J (3, 0) =
0 12
The eigenvalues of the Jacobian matrix are λ1 = −36 < 0, λ2 = 12 > 0 and we
obtain another saddle point.
• Point ( x, y)4 = (2.6, 2.4):
 
2 −78 −13
J (2.6, 2.4) =
5 −36 −36

The characteristic polynomial takes the form µ2 + 6 


· 19µ − 36 ·65 = 0, where µ =
q
2λ/5. The roots of this polynomial are µ1,2 = −57 1 ± 101 361 and we have two
negative eigenvalues λ1,2 < 0 and the critical point is a stable node.
(c) The direction field for the system of ODEs (9) is shown in Figure 2.

(H) Exercise 4: Nonlinear Dynamic System – Lyapunov Function Method

In some cases determining the linear behavior of a dynamic system dx dt = f ( x ), where x ∈ R ,


n

at a critical point x is not enough to characterize its stability. There are various methods to
determine the stability of such a point. One of these requires finding a scalar Lyapunov function
V ( x ) : Rn 7→ R with the properties:
• V ( x ) > 0, ∀ x 6= x∗
• V (x∗ ) = 0
dV ( x )
The existence of Lyapunov function for which dt = ∇V ( x ) · f ( x ) ≤ 0, ∀ x 6= x ∗ , guaran-
tees the stability of the critical point x ∗ .

7
6 Direction Field for x'=36x-12x^2-2xy, y'=30y-6y^2-6xy System of ODEs

3
y

0.5 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0
x

Figure 2: Direction field of the nonlinear system of ODEs (9)

As an example consider the following two-dimensional dynamic system

dx
= − xy
dt (10)
dy
= x2 − y
dt
dy
(a) Plot the nullclines ( dx
dt = 0 or dt = 0) of the system and sketch the direction field.
(b) Compute the eigenvalues of the Jacobian matrix on the critical point of the system. Can
you classify the critical point based on the eigenvalues?
(c) Use V ( x, y) = x2 + y2 as a Lyapunov function to show that the critical point is stable.

8
Solution:

(a) For the nullclines at least one of the time derivatives has to vanish.
dx
= 0 ⇔ x = 0∨y = 0
dt
dy
= 0 ⇔ y = x2
dt
Figure 3 shows the nullclines and the vectorfield of the system. Note the critical point at
( x, y) = (0, 0).

dy dx
Figure 3: Vectorfield and nullclines ( dt = 0, dt = 0) of the problem

(b) The Jacobian of the system is given by


   
−y − x 0 0
J= = .
2x −1 x∗ =(0,0) 0 −1

Its eigenvalues are λ1 = 0 and λ2 = −1.


It is not possible to determine the stability just from the eigenvalues, since the eigenvalues
need to be less than zero to determine the stability with certainty.
(c) The time derivative of the Lyapunov function V is
dV dx dy
( x, y) = 2x + 2y
dt dt dt
= 2x (− xy) + 2y( x2 − y)
= −2y2 ≤ 0 ∀ x 6= x ∗
dV ( x,0)
This is sufficient to prove the stability of the critical point. Note that even though dt =
dy
0, since dt 6= 0 ∀y = 0, x 6= 0, y will not remain zero and the function V gets smaller over
time. The value of the function V thus steadily decreases and reaches the minimum at
x = x∗ .

9
(H*) Exercise 5: Discrete Dynamic System – Logistic Map

Let xn+1 = f ( xn ) be a map with

f ( x ) = ax (1 − x ), a≥0 (11)

(a) Determine the critical points of the map, i. e. the points x ∗ for which f ( x ∗ ) = x ∗ holds.
In addition, discuss their stability as a function of the parameter a.
(b) Determine the critical points of the map f (2) ( x ) := f ( f ( x )).
Hint: f ( x ) and f (2) ( x ) share two critical points. Make use of this and apply polynomial
division.
(c) Sketch the stable critical points as a function of 0 ≤ a ≤ 4.

Solution:

(a) For critical points the relation f ( x ∗ ) = x ∗ holds. In the trivial case a = 0 the map reads
xn+1 = 0, i. e. there is one stable critical point x ∗ = 0. Otherwise we have
!
f ( x ∗ ) = ax ∗ (1 − x ∗ ) = x ∗ ⇔ x ∗ [− ax ∗ + ( a − 1)] = 0
a −1
and therefore x1∗ = 0 and x2∗ = a .

To determine the stability of the critical points we look at f 0 ( x ∗ ). If | f 0 ( x ∗ )| < 1, the


considered critical point is stable and for | f 0 ( x ∗ )| > 1 the critical point is unstable. For
the logistic map f 0 ( x ) = a[1 − 2x ]. We already considered the trivial case a = 0. Hence
we assume a 6= 0.

For x1∗ = 0, we have f 0 (0) = a, which means we have a stable critical point at x1∗ = 0
for 0 < a < 1 and an unstable critical point for a > 1.

On the other hand, we have f 0 ( x2∗ ) = 2 − a for x2∗ = a−a 1 . If 1 < a < 3 we obtain
| f 0 ( x2∗ )| < 1 and therefore a stable critical point. The choices 0 < a < 1 or a > 3 result in
| f 0 ( x2∗ )| > 1 and an unstable critical point.

In total there are three different cases.


a −1
• 0 < a < 1: x1∗ = 0 stable, x2∗ = a unstable
a −1
• 1 < a < 3: x1∗ = 0 unstable, x2∗ = a stable
a −1
• a > 3: x1∗ = 0 unstable, x2∗ = a unstable
For the parameter values a = 1 and a = 3 the stability properties of the critical points and
therefore the behaviour of the system changes. This is called bifurcation.
(b) The critical points of xn+1 = f ( f ( xn )) are defined by x ∗ = f ( f ( x ∗ )).

x ∗ = f ( f ( x ∗ ))
= a f ( x ∗ )(1 − f ( x ∗ ))
= a( ax ∗ (1 − x ∗ ))(1 − ax ∗ (1 − x ∗ ))

10
There are four solutions (critical points) of this equation because the corresponding poly-
nomial is of degree four. For the critical points x1∗ and x2∗ of xn+1 = f ( xn ) it holds
∗ ∗ ∗
f ( f ( x1,2 )) = f ( x1,2 ) = x1,2 .

Hence, critical points of xn+1 = f ( xn ) are also critical points of xn+1 = f ( f ( xn )). We
can use this result to transform the fourth order polynomial equation with the help of
polynomial division into a second order polynomial equation, this results in the new
critical points
p
∗ −( a3 + a2 ) ± ( a3 + a2 )2 − 4(− a3 )(− a2 − a)
x3,4 = .
−2a3
Those are real for a > 3 and fulfil the following relations

f ( x3∗ ) = x4∗ and f ( x4∗ ) = x3∗ .

(c) For 0 < a < 1 only the critical point x1∗ is stable. At a = 1 the critical points exchange their
stability properties (transcritical bifurcation) and the critical point x2∗ is stable and plotted
in Figure 4. At a = 3 the critical points of xn+1 = f ( f ( xn )) (see (b)) become real-valued.
The simple logistic map shows chaotic behaviour for higher a.

Figure 4: Stable critical points of the logistic map over the parameter a.

11

You might also like