You are on page 1of 26

First order ordinary differential equations.

Qualitative
theory. Numerics.

Luis L. Bonilla

Universidad Carlos III de Madrid, 2.1.D17, bonilla@ing.uc3m.es

September 10, 2019

Bonilla (UC3M) Lecture 2 September 10, 2019 1 / 26


Outline

Outline

Qualitative analysis of autonomous first order ODEs.


Direction fields.
Numerical methods: Explicit and implicit Euler. Truncation error.
Existence and uniqueness.
Example.

Bonilla (UC3M) Lecture 2 September 10, 2019 2 / 26


Qualitative analysis of solutions

Long term behavior for autonomous ODEs


Theorem. Let f (y ), f 0 (y ) be continuous for all y . Let y (t) be a solution
of the ODE y 0 = f (y ) which is bounded for all t ≥ 0 (respectively for all
t < 0). Then as t → +∞ (resp. t → −∞),y (t) approaches an equilibrium
solution of the ODE (y ∗ such that f (y ∗ ) = 0).

Figure: State (phase) line and solution curves for logistic ODE with harvesting.

Bonilla (UC3M) Lecture 2 September 10, 2019 3 / 26


Qualitative analysis of solutions

Sensitivity to changes in data

Attractor, repeller and semistable equilibrium solutions.


Attractor: all solution curves in a neighborhood thereof approach it as
t → +∞. If y0 is an attractor, then small changes in the initial data
near y0 have no effect on the long time behavior of the solution.
Repeller: all solution curves in a neighborhood thereof depart from it
as t → +∞ (and approach it as t → −∞). If y0 is a repeller or a
semistable equilibrium solution, then small changes in the initial data
near y0 lead to drastic changes in the solution in the long term.
On a small enough neighborhood, an attractor/repeller or semistable
solution attracts all initial data to one side of it on the phase line and
repels all initial data to the other side.

Bonilla (UC3M) Lecture 2 September 10, 2019 4 / 26


Qualitative analysis of solutions

Bifurcations: a logistic harvested model

Bifurcation analysis of the ODE y 0 = f (y , c). Stages:


Track the equilibrium solutions as they move, merge, split up, or
disappear with changes in c.
Describe the qualitative effects of these changes in c on the long term
behavior of non-equilibrium solutions.
Summarize solution behavior as c changes in a bifurcation diagram.
Typical behaviors:
Saddle-node bifurcation y 0 = y (1 − y ) + c.
Pitchfork bifurcation y 0 = (c − y 2 )y .

Bonilla (UC3M) Lecture 2 September 10, 2019 5 / 26


Qualitative analysis of solutions

Bifurcations: a logistic harvested model


Saddle-node bifurcation y 0 = y (1 − y ) + c.

Bonilla (UC3M) Lecture 2 September 10, 2019 6 / 26


Qualitative analysis of solutions

Bifurcations
Pitchfork bifurcation y 0 = (c − y 2 )y .

Bonilla (UC3M) Lecture 2 September 10, 2019 7 / 26


Direction fields

Direction field

Direction field in the (x, y ) plane for the autonomous ODE y 0 = 9.8 − 0.2y
showing the equilibrium solution y ∗ = 9.8/0.2 = 49. This ODE describes
how a body weighting 1 kg falls, if its velocity is y (x) and its friction force
is ky , with k = 0.2 kg/s. y ∗ = 49 m/s is the limiting velocity.
Bonilla (UC3M) Lecture 2 September 10, 2019 8 / 26
Direction fields

Direction field
It is possible to draw the direction field by studying the function f (x, y ) in
the ODE y 0 = f (x, y ) as in the example: y 0 = xy (y − 2)

Figure: Sectors of (a) decreasing and increasing y (x), (b) concave and convex
y (x), (c) combined information about signs of y 0 and y 00 for the ODE
y 0 = xy (y − 2). We have used y 00 = ∂x
∂f ∂f
+ ∂y f = y (y − 2)(1 + 2x 2 y − 2x 2 ).

Bonilla (UC3M) Lecture 2 September 10, 2019 9 / 26


Direction fields

Direction field and solution curves

Bonilla (UC3M) Lecture 2 September 10, 2019 10 / 26


Direction fields

Direction field
It is faster to draw the direction field by using Mathematica or Matlab. In
Mathematica: f [x− , y− ] := xy (y − 2);
StreamPlot[{1, f [x, y ]}, {x, −5, 5}, {y , −2, 3}, Frame− > False, Axes− >
True, AspectRatio− > 1/GoldenRatio]
Streamlines
y

x
-4 -2 2 4
-1

-2
Bonilla (UC3M) Lecture 2 September 10, 2019 11 / 26
Direction fields

Direction field and solution curves

Seems: Solution curves come arbitrarily close for large positive and
negative values of t − t0 .

Bonilla (UC3M) Lecture 2 September 10, 2019 12 / 26


Direction fields

Direction field for periodic harvesting

Seems: y ∼ 1 + 0.2 cos t as t → +∞ for y (0) > 0.1, y → −∞ otherwise.

Bonilla (UC3M) Lecture 2 September 10, 2019 13 / 26


Numerical solutions: Euler methods

dy
Euler method for dt = f (t, y )

• Approximate derivative using forward difference: Explicit Euler method


dy yj+1 − yj
f (tj , y (tj )) = (tj + h) ≈ =⇒ yj+1 = yj + h f (tj , yj )
dt h
• Approximate derivative using backward difference: Implicit Euler
method
dy yj − yj−1
f (tj , y (tj )) = (tj ) ≈ =⇒ yj = yj−1 + h f (tj , yj )
dt h
yj+1 = yj + h f (tj + h, yj+1 )
In addition, we need to solve for yj+1 using a numerical method
(Newton-Raphson).

Implicit Euler = Explicit Euler with h → −h, j + 1 → j − 1.

Bonilla (UC3M) Lecture 2 September 10, 2019 14 / 26


Numerical solutions: Euler methods

dy
Euler method for dt = f (t, y )

Figure: The explicit (forward) Euler method yj+1 = yj + f (tj , yj )h, y0 = y (t0 ),
approximates a given trajectory y = ϕ(t) by segments that move it to nearby
trajectories ϕ1 (t), ϕ2 (t), . . . in the (t, y ) plane.

Bonilla (UC3M) Lecture 2 September 10, 2019 15 / 26


Numerical solutions: Euler methods

dy
Explicit Euler method for dt = 3 − 2t − y2 , y (0) = 1

Trajectories
y
2.0
1.5
1.0
0.5
t
0.5 1.0 1.5 2.0 2.5 3.0
-0.5
-1.0
Bonilla (UC3M) Lecture 2 September 10, 2019 16 / 26
Numerical solutions: Euler methods

dy
Explicit Euler method for dt = 3 − 2t − y2 , y (0) = 1

Figure: Error of the explicit Euler method is O(h), and it should decrease for large
t: exact solution y (t) = 14 − 4t − 13 e −t/2 .

Bonilla (UC3M) Lecture 2 September 10, 2019 17 / 26


Numerical solutions: Euler methods

dy
Explicit Euler method for dt = 4 − t + 2y , y (0) = 1

Trajectories
y
3

t
0.5 1.0 1.5 2.0
-1
Bonilla (UC3M) Lecture 2 September 10, 2019 18 / 26
Numerical solutions: Euler methods

dy
Explicit Euler method for dt = 4 − t + 2y , y (0) = 1

Figure: Error of the explicit Euler method is O(h), and it should increase for large
t: exact solution y (t) = − 74 + 2t + 11 2t
4 e . In this case, implicit Euler is better.

Bonilla (UC3M) Lecture 2 September 10, 2019 19 / 26


Numerical solutions: Euler methods

Truncation error. Suppose IVP y 0 = f (t, y ), y (t0 ) = y0 , is approximated


by one-step numerical scheme yj+1 = yj + Φ(tj , yj , yj+1 , h) h. Define the
local truncation error or discretization error of the scheme as:
y (tj+1 ) − y (tj )
τj+1 = − Φ(tj , y (tj ), y (tj+1 ), h), j = 0, 1, . . . , N − 1,
h
where we substitute the exact solution y (tj ) instead of yj . If τj → 0 as
h → 0, difference equations are consistent. A consistent one-step scheme
is also convergent, i.e., the global truncation error ej = y (tj ) − yj → 0 with
h. Note ej+1 − ej = hΦ(tj , y (tj ), y (tj+1 ), h) − hΦ(tj , yj , yj+1 , h) + hτj+1 .
For the Euler method Φ(tj , yj , yj+1 , h) = f (tj , yj ), the Taylor theorem gives

y (tj+1 ) − y (tj ) y (tj + h) − y (tj ) dy (tj ) h d 2 y (ξ)


= = +
h h dt 2 dt 2
2
h d y (ξ)
= f (y (tj ), tj ) =⇒ τj+1 = − = C · h = O(h).
2 dt 2
T −t0
Also the global error is first order: sum of N = h terms of order h2
each: ej = O(h).
Bonilla (UC3M) Lecture 2 September 10, 2019 20 / 26
Existence and uniqueness

Theorem

Theorem of existence and uniqueness. Provided f and ∂f /∂y are


continuous in a rectangle R and (t0 , y0 ) is inside R, the IVP:

y 0 = f (t, y ),
y (t0 ) = y0 ,

has a unique solution for |t − t0 | < δ (for some δ > 0 that leaves t in the
rectangle R). The IVP has a solution (existence) but no more than one
solution in R on any t-interval containing t0 (uniqueness).

Bonilla (UC3M) Lecture 2 September 10, 2019 21 / 26


Existence and uniqueness

What if assumptions of theorem do not hold?

y 0 = 2y 1/2 , y (t0 ) = y0 .
f (y ) =2y 1/2 continuous for all y ≥ 0 but f 0 (y ) = y −1/2 not continuous at
y = 0. One of the theorem conditions fails for rectangles about any point
1/2
(t0 , 0). Separation of variables give t − t0 = y 1/2 − y0 , i.e.,
1/2
y = (y0 + t − t0 )2 for any y0 > 0. This solution holds for y0 = 0 but
there are infinitely many solutions of the same IVP: y = 0 and:

0, t<s
y (t) = 2
(t − s) , t ≥ s ≥ t0 .

Bonilla (UC3M) Lecture 2 September 10, 2019 22 / 26


Existence and uniqueness

What if assumptions of theorem do not hold?

y
ty 0 − y = t 2 cos t, t>0 (f (t, y ) =
+ t cos t not continuous at t = 0).
t
Multiplying by 1/t 2 , we get (y /t)0 = cos t, and therefore
y = t sin t + Ct, t > 0.
This formula gives solutions also for t ≤ 0 and all these solutions satisfy
y (0) = 0. The IVP with: y (0) = 0 has infinitely many solutions whereas
any IVP with initial condition y (0) = y0 6= 0 has no solution at all!

Bonilla (UC3M) Lecture 2 September 10, 2019 23 / 26


Example

Homoclinic orbit for y 02 = y 2 − y 3

y 0 = −y 1 − y , t > 0, y (0) = 1.
p

∂f y p
( = √ − 1 − y not continuous at y = 1).
∂y 2 1−y
Separation of variables
Z y Z t
dy
√ =− dt = −t, t > 0.
1 y 1−y 0
√ √ √
z = 1 − y gives ln[1 − 1 − y ] − ln[1 + 1 − y ] = −t. After some
algebra: y (t) = cosh1 2 t . Note y (t) = 1 also solves IVP.
2
�������

���

���

���

���

���


-�� -� � ��

Bonilla (UC3M) Lecture 2 September 10, 2019 24 / 26


Example

Numerical solution by explicit Euler method

p
yj+1 = yj − hyj 1 − yj ,y0 = 0.99.
p
yj+1 = f (yj , h), f (yj , h) = (1 − h 1 − yj )yj .
Plot functions yj+1 = yj , yj+1 = f (yj , h) and iterate starting from y0 .

Fixed points are y = 0, 1. Note that ∂y ∂f
(y , h) = 1 − h 1 − y + √hy1−y
, so
∂f
that ∂y (0, h) = 1 − h. Near y = 0, yj+1 ≈ (1 − h)yj . Thus yj moves away
from y = 0 for |h − 1| > 1, or h > 2 (numerical instability).

Bonilla (UC3M) Lecture 2 September 10, 2019 25 / 26


Example

Numerical solution by implicit Euler method

p
yj+1 = yj − hyj+1 1 − yj+1 , y0 = 0.99.
p
yj = g (yj+1 , h), g (yj+1 , h) = (1 + h 1 − yj+1 )yj+1 .
Plot functions yj+1 = yj , yj = g (yj+1 , h) and iterate starting from y0 :

∂g √
= 1 + h 1 − y − √hy
∂y (y , h) 1−y
, so ∂g 1
∂y (0, h) = 1 + h. Then yj+1 ≈ 1+h yj
near y = 0, which converges to y = 0 because 1 + h > 1 for all h > 0.
Bonilla (UC3M) Lecture 2 September 10, 2019 26 / 26

You might also like