applied differential calculus lecture 1: first-order...

29
Applied Differential Calculus Lecture 1: First-order ordinary differential equations Authors: Manuel Carretero, Luis L. Bonilla, Filippo Terragni, Sergei Iakunin, Roc´ ıo Vega Bachelor’s Degree in Computer Science and Engineering and Dual Bachelor in Computer Science and Engineering and Business Administration. Applied Differential Calculus (OCW-UC3M) Lecture 1 1 / 29

Upload: others

Post on 22-Mar-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Applied Differential CalculusLecture 1: First-order ordinary differential equations

Authors:Manuel Carretero, Luis L. Bonilla, Filippo Terragni, Sergei Iakunin,

Rocıo Vega

Bachelor’s Degree in Computer Science and Engineering andDual Bachelor in Computer Science and Engineering and Business Administration.

Applied Differential Calculus (OCW-UC3M) Lecture 1 1 / 29

Page 2: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Outline

Outline

Modeling.

General concepts. Existence and uniqueness. Direction field for afirst-order ODE.

Exact solutions for special ODEs.

Numerical solutions: Euler, Heun and Runge-Kutta methods.

Long term behavior of solutions. Qualitative analysis of solutions.

Applied Differential Calculus (OCW-UC3M) Lecture 1 2 / 29

Page 3: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Modeling

Problem solving via mathematical modeling

Real-worldproblem

Math model

Result Solution

Modeling

AnalysisPrediction

Interpretation

Applied Differential Calculus (OCW-UC3M) Lecture 1 3 / 29

Page 4: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Modeling

Problem solving via mathematical modeling

Interpretation of results

ValidationPreparation for

modeling

ModelSolution in special

cases

Natural processReady for prediction

No

Yes

Applied Differential Calculus (OCW-UC3M) Lecture 1 4 / 29

Page 5: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Modeling

Galileo’s model

y ′′ = −g , 0 ≤ t ≤ T ,

y(0) = 0, y ′(0) = v0.

(a) y0 = 0, v0 = 2, 4, 6. (b) y0 = 2, v0 = 2, 4, 6.

Applied Differential Calculus (OCW-UC3M) Lecture 1 5 / 29

Page 6: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Modeling

Newton’s model

my ′′ = −mg − cy ′, 0 ≤ t ≤ T ,

y(0) = 0, y ′(0) = v0.

(a) c/m = 3; (b) c/m = 10.

Applied Differential Calculus (OCW-UC3M) Lecture 1 6 / 29

Page 7: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Modeling

Modeling a fish population, 1

y ′ = (Birth rate)− [(Death rate) + (Harvesting rate)],

measured in tons per year. Simplest model: birth and death ratesproportional to y(t). a = b − d > 0 is growth rate:

y ′ = ay − H, y(t0) = y0.

Solution by integrating factor:

−eµ(t)H = eµ(t)(y ′ − ay) =d

dt

(eµ(t)y

)= eµ(t)(y ′ + µ′y) =⇒ µ′ = −a.

Then µ = −at and we get e−aty = c + Ha e−at or y(t) = H

a + ceat .

y(t) =H

a+

(y0 −

H

a

)ea(t−t0).

Applied Differential Calculus (OCW-UC3M) Lecture 1 7 / 29

Page 8: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Modeling

Modeling a fish population, 2

(a) (b)

Exponential population growth with no harvesting: IVP with a = 1, H = 0in (a) and H = 5/3 in (b), and various values for y0.

y(t) =H

a+

(y0 −

H

a

)eat (t0 = 0).

Applied Differential Calculus (OCW-UC3M) Lecture 1 8 / 29

Page 9: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Modeling

Fish population with logistic growth

Limitation to growth due to overcrowding

y ′ = ay − cy2 − H, y(0) = y0, t ≥ 0.

Solution formula is complicated. We find it later by separation of variables.Qualitative behavior of solution curves. We do one example: a = 1,c = 1

12 , H = 53 , so that

y ′ = − 1

12(y − 10)(y − 2) := f (y), y(0) = y0, t ≥ 0.

f (y) = 0 for y = 10, y = 2. These are equilibrium solutions.

2 10y

0

f(y) = − (y− 2)(y− 10)

12

t

2

10y

Applied Differential Calculus (OCW-UC3M) Lecture 1 9 / 29

Page 10: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Modeling

Separation of variables

By analysis of phase line, solution curves go to equilibrium solutions withf ′ < 0 as t → +∞ and to equilibrium solutions with f ′ > 0 as t → −∞.

Separation of variables:

y ′ = − 1

12(y − 10)(y − 2) =⇒ −dt

12=

dy

(y − 10)(y − 2).

− t

12+ C =

1

8

∫ (1

y − 10− 1

y − 2

)dy =

1

8ln

∣∣∣∣y − 10

y − 2

∣∣∣∣.10− y

y − 2= Ke−2t/3 =⇒ y(t) =

10 + 2Ke−2t/3

1 + Ke−2t/3,

with K = 10−y0y0−2 e2t0/3 provided 2 < y0 < 10.

As t increases from −∞ to +∞, solution curves go from 2 to 10.

Applied Differential Calculus (OCW-UC3M) Lecture 1 10 / 29

Page 11: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Existence and uniqueness

Theorem

Theorem of existence and uniqueness. Provided f and ∂f /∂y arecontinuous in a rectangle R and (t0, y0) is inside R, the IVP:

y ′ = f (t, y),

y(t0) = y0,

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

Applied Differential Calculus (OCW-UC3M) Lecture 1 11 / 29

Page 12: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Existence and uniqueness

What if assumptions of theorem do not hold?

y ′ = 2y1/2, y(t0) = y0.

f (y) = 2y1/2 continuous for all y ≥ 0 but f ′(y) = y−1/2 not continuous aty = 0. One of the theorem conditions fails for rectangles about any point

(t0, 0). Separation of variables give t − t0 = y1/2 − y1/20 , i.e.,

y = (y1/20 + 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:

y(t) =

{0, t < s

(t − s)2, t ≥ s ≥ t0.

0.0 0.5 1.0 1.5 2.0 2.5 3.0t

1

0

1

2

3

4

5

y

y ′ = 2y1/2, y(0) = 0

s1

s2

s3

Applied Differential Calculus (OCW-UC3M) Lecture 1 12 / 29

Page 13: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Existence and uniqueness

What if assumptions of theorem do not hold?

ty ′ − y = t2 cos t, t > 0 (f (t, y) =y

t+ t cos t not continuous at t = 0).

Multiplying by 1/t2, we get (y/t)′ = cos t, and therefore

y = t sin t + Ct, t > 0.

This formula gives solutions also for t ≤ 0 and all these solutions satisfyy(0) = 0. The IVP with: y(0) = 0 has infinitely many solutions whereasany IVP with initial condition y(0) = y0 6= 0 has no solution at all!

10 5 0 5 10t

20

10

0

10

20

y

ty ′ − y= t2cost, y(0) = 0

Applied Differential Calculus (OCW-UC3M) Lecture 1 13 / 29

Page 14: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Direction fields

Direction field

Direction field in the (x , y) plane for the ODE y ′ = 9.8− 0.2y showing theequilibrium solution y∗ = 9.8/0.2 = 49. This ODE describes how a bodyweighting 1 kg falls, if its velocity is y(x) and its friction force is ky , withk = 0.2 kg/s. y∗ = 49 m/s is the limiting velocity.

Applied Differential Calculus (OCW-UC3M) Lecture 1 14 / 29

Page 15: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Direction fields

Direction field

x

y

2

0

y ′ > 0y ′ < 0

y ′ < 0y ′ > 0

y ′ > 0y ′ < 0

x

y

2

0

y ′′ > 0

y ′′ > 0y ′′ > 0

y ′′ < 0

y ′′ < 0y ′′ < 0

12

√2−1

2

√2

x

y

2

012

√2−1

2

√2

Figure: Sectors: (left) decreasing and increasing y(x), (center) concave andconvex y(x), (right) combined information about signs of y ′ and y ′′ for the ODEy ′ = xy(y − 2). We have used y ′′ = ∂f

∂x + ∂f∂y f = y(y − 2)(1 + 2x2y − 2x2).

Applied Differential Calculus (OCW-UC3M) Lecture 1 15 / 29

Page 16: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Direction fields

Direction field and solution curves

Figure: Slope field and trajectories in the (x , y) plane for the ODE y ′ = xy(y −2).

Applied Differential Calculus (OCW-UC3M) Lecture 1 16 / 29

Page 17: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Direction fields

Direction field and solution curves

Figure: Solution curves come arbitrarily close for large positive andnegative values of t − t0.

Applied Differential Calculus (OCW-UC3M) Lecture 1 17 / 29

Page 18: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Direction fields

Direction field for periodic harvesting

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

Applied Differential Calculus (OCW-UC3M) Lecture 1 18 / 29

Page 19: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Exact solutions

Exact solutions

Separable ODE:M(x) + N(y)y ′ = 0 =⇒

∫M(x)dx = −

∫N(y)dy + c .

Exact ODE: M(x , y) + N(x , y)y ′ = 0, ∂M∂y = ∂N∂x .

Linear ODE: y ′ + a(x)y = F (x). Use integrating factor I = e∫a(x)dx

to get trivial ODE (Iy)′ = F (x)I (x). Theny = e−

∫a(x)dx [

∫F (x ′)e

∫a(x ′)dx ′dx ′ + c].

Bernoulli ODE: y ′ = a(x)y + b(x)yP . Use u = y1−P to get linearODE.

Riccati ODE: y ′ = a(x)y + b(x)y2 + c(x). Find particular solution,transform in Bernoulli by y = yp(x) + u(x).

Substitutions: For y ′ = F (y/x), u = y/x gives u′ = [F (u)− u]/x .x = av + bw + c, y = dv + ew + f , with appropriate a, . . . , f ,converts y ′ = (Ax + By + C )/(Dx + Ey + F ) in a separable ODE forw(v).

Applied Differential Calculus (OCW-UC3M) Lecture 1 19 / 29

Page 20: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Numerical solutions: Euler, Heun and RK methods

Euler method for dydt = f (t, y)

t

y

(t1, y1)

(t2, y2)

(t3, y3)

t0 t1 t2 t3

y0y = ϕ(t)

y = ϕ1(t)

y = ϕ2(t)

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 nearbytrajectories ϕ1(t), ϕ2(t), . . . in the (t, y) plane.

Applied Differential Calculus (OCW-UC3M) Lecture 1 20 / 29

Page 21: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Numerical solutions: Euler, Heun and RK methods

Truncation error. Suppose IVP y ′ = f (t, y), y(t0) = y0, is approximatedby one-step numerical scheme yj+1 = yj + Φ(tj , yj , yj+1, h) h. Define thelocal truncation error or discretization error of the scheme as:

τj+1 =y(tj+1)− y(tj)

h− Φ(tj , y(tj), y(tj+1), h), j = 0, 1, . . . ,N − 1,

where we substitute the exact solution y(tj) instead of yj . If the τj vanishas h→ 0, we say that the difference equations are consistent with thedifferential equation. A consistent one-step scheme is also convergent, i.e.,the global truncation error ej = y(tj)− yj tends to 0 with h.Note: ej+1− ej = hΦ(tj , y(tj), y(tj+1), h)− hΦ(tj , yj , yj+1, h) + hτj+1. Forthe Euler method Φ(tj , yj , yj+1, h) = f (tj , yj), the Taylor theorem gives

y(tj+1)− y(tj)

h=

y(tj + h)− y(tj)

h=

dy(tj)

dt+

h

2

d2y(ξ)

dt2

= f (y(tj), tj) +h

2

d2y(ξ)

dt2=⇒ τj+1 =

h

2

d2y(ξ)

dt2= O(h).

Applied Differential Calculus (OCW-UC3M) Lecture 1 21 / 29

Page 22: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Numerical solutions: Euler, Heun and RK methods

Heun and RK2 methods

Heun:

yj+1 = yj +h

2[f (tj , yj) + f (tj + h, pj+1)], pj+1 = yj + hf (tj , yj).

RK2:

yj+1 = yj + Ahf (tj , yj) + Bh f (tj + Ph, yj + Qhf (tj , yj)),

with

A + B = 1, BP =1

2, BQ =

1

2.

Heun is RK2 with A = 12 . Modified Euler (midpoint) is RK2 with A = 0.

Applied Differential Calculus (OCW-UC3M) Lecture 1 22 / 29

Page 23: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Long term behavior of solutions

Long term behavior and control of linear IVPs

First order linear ODE:

y ′ + p(t)y = q(t), y(0) = y0, t ≥ 0.

Solution:

y(t) = y0e−P(t) + e−P(t)

∫ t

0eP(s)q(s) ds, P(t) =

∫ t

0p(s) ds.

Bounded Input-Bounded Output (BIBO): p(t) continuous, q(t) piecewisecontinuous on t ≥ 0, p0, M positive numbers,

p(t) ≥ p0, |q(t)| ≤ M, t ≥ 0.

Then the solution of the IVP:

|y(t)| ≤ |y0|+M

p0, t ≥ 0.

.Applied Differential Calculus (OCW-UC3M) Lecture 1 23 / 29

Page 24: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Long term behavior of solutions

Control of a chemical reactor

First order linear ODE (reaction A→ B with leaky entrance of A inreactor):

y ′ =r(t)

V (t)− ky =⇒ y ′ + ky =

r(t)

V (t).

Assume: V (t) ≥ V0 > 0 (reactor never runs dry), bounded inflow rater(t) ≤ r0. Then

0 ≤ r(t)

V (t)≤ r0

V0,

BIBO theorem (p0 = k > 0, M = r0/V0, y(0) > 0):

|y(t)| ≤ y(0) +r0kV0

.

Assume y(t) cannot exceed K > 0 by design specifications. Criteria aremet for:

y(0) ≤ K

2, r0 ≤

kV0K

2=⇒ |y(t)| ≤ K .

.Applied Differential Calculus (OCW-UC3M) Lecture 1 24 / 29

Page 25: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Qualitative analysis of solutions

Long term behavior for autonomous ODEs

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

0 1 2 3 4 5t

0

5

10

15

20

y

y ′ = y− y2/12, 0<y0 < 20

attractor

repeller

0 1 2 3 4 5t

0

5

10

15

20

y

y ′ = y− y2/12− 5/3, 0<y0 < 20

attractor

repeller

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

Applied Differential Calculus (OCW-UC3M) Lecture 1 25 / 29

Page 26: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

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 ast → +∞. If y0 is an attractor, then small changes in the initial datanear y0 have no effect on the long time behavior of the solution.

Repeller: all solution curves in a neighborhood thereof depart from itas t → +∞ (and approach it as t → −∞). If y0 is a repeller or asemistable equilibrium solution, then small changes in the initial datanear y0 lead to drastic changes in the solution in the long term.

On a small enough neighborhood, an attractor/repeller or semistablesolution attracts all initial data to one side of it on the phase line andrepels all initial data to the other side.

Applied Differential Calculus (OCW-UC3M) Lecture 1 26 / 29

Page 27: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Qualitative analysis of solutions

Bifurcations: a logistic harvested model

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

Track the equilibrium solutions as they move, merge, split up, ordisappear with changes in c .

Describe the qualitative effects of these changes in c on the long termbehavior of non-equilibrium solutions.

Summarize solution behavior as c changes in a bifurcation diagram.

Typical behaviors:

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

Pitchfork bifurcation y ′ = (c − y2)y .

Applied Differential Calculus (OCW-UC3M) Lecture 1 27 / 29

Page 28: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Qualitative analysis of solutions

Bifurcations: a logistic harvested model

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

0 1 2 3 4 5s

0.5

0.0

0.5

1.0

1.5

y f > 0

f< 0

f< 0

y2 = 1

y1 = 0

dy/ds= f(y, 0) = y(1− y)

0.4 0.3 0.2 0.1 0.0 0.1bifurcation parameter c

0.5

0.0

0.5

1.0

1.5

y-co

ord

inate

of

equili

bri

um

poin

t c= -0.33 -0.25 -0.16 -0.09 0.0

bifurcationpoint

y ′ = y(1− y) + c

Applied Differential Calculus (OCW-UC3M) Lecture 1 28 / 29

Page 29: Applied Differential Calculus Lecture 1: First-order ...ocw.uc3m.es/...calculus/.../lecture_1_slides.pdf · Theorem Theorem of existence and uniqueness. Provided f and @f=@y are continuous

Qualitative analysis of solutions

Bifurcations

Pitchfork bifurcation y ′ = (c − y2)y .

0.0 0.5 1.0 1.5 2.0 2.5 3.0t

2.0

1.5

1.0

0.5

0.0

0.5

1.0

1.5

2.0

y

f > 0

f> 0

f< 0

f< 0y2 =√

2

y1 = 0

y3 = −√

2

y ′ = f(y, 2) = (2− y2)y

1.0 0.5 0.0 0.5 1.0 1.5 2.0bifurcation parameter c

2.0

1.5

1.0

0.5

0.0

0.5

1.0

1.5

2.0

y-co

ord

inate

of

equili

bri

um

poin

t

Attractor Repeller y1 = 0

f< 0

f> 0

Attractor y2 =√c

Attractor y3 = −√c

f> 0

f< 0Bifurcation point

y ′ = (c− y2)y

Applied Differential Calculus (OCW-UC3M) Lecture 1 29 / 29