Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C...

44
Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns Center for Optimal Design And Control Interdisciplinary Center for Applied Mathematics Virginia Polytechnic Institute and State University Blacksburg, Virginia 24061-0531 A Short Course in Applied Mathematics 2 February 2004 – 7 February 2004 N M T Series Two Course Canisius College, Buffalo, NY

Transcript of Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C...

Page 1: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Computational Methods for Design Lecture 3 – Elementary Differential

Equations

John A. Burns

Center for Optimal Design And Control

Interdisciplinary Center for Applied MathematicsVirginia Polytechnic Institute and State University

Blacksburg, Virginia 24061-0531

A Short Course in Applied Mathematics

2 February 2004 – 7 February 2004

N∞M∞T Series Two Course

Canisius College, Buffalo, NY

Page 2: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Today’s Topics

Lecture 3 – Elementary Differential Equations A Review of the Basics Equilibrium Stability Dependence on Parameters: Sensitivity Numerical Methods

Page 3: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

A Falling Object

( ) ( )F t ma t“Newton’s Second Law”

. y(t)

( ) ( ) ( ) ( ) ( )g dampmy t F t F t mg y t y t

)()()( tytym

gty

)()()( tvtvm

gtv

)()( tvty

0)0(

000,10)0(

v

y

{

{

AIR RESISTANCE

Page 4: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Height: y(t)

)(ty

Page 5: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Velocity: v(t)=y’(t)

)()( tytv

Page 6: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

System of Differential Equations

)()(

)(

)(

)(tvtv

mg

tv

tv

ty

dt

d

)()()( tvtvm

gtv

)()( tvty

0)0(

000,10)0(

v

y

)()(

)(

)(

)()(

22

2

2

1

txtxm

g

tx

tx

tx

dt

dtx

dt

d

)(

)()(

2

1

tx

txtx

Page 7: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

State Space

)()(

)(

)(

)()(

22

2

2

1

txtxm

g

tx

tx

tx

dt

dtx

dt

d

))(),((

))(),((

)(

)(

)(

)(

212

211

2

1

2

1

txtxf

txtxf

tx

txf

tx

tx

dt

d

2

0

0

2

1

)0(

)0(R

v

y

x

x

STATE SPACE

Page 8: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

System of Differential Equations

2

2

1

)(

)()( R

tx

txtx

2

2

121 )(

)()(),()( R

tx

txftxtxftxf

)()( txftxdt

d

THE PHYSICS – BIOLOGY – CHEMISTRY IS FINDING 21, xxf

SELECTION OF THE “CORRECT STATE SPACE” IS A COMBINATION OF PHYSICS – BIOLOGY –

CHEMISTRY AND MATHEMATICS

Page 9: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Parameters

),,,,(),,,( 2122

2

mgxxfxx

mg

xmgxf

IN REAL PROBLEMS THERE ARE PARAMETERS

SOLUTIONS DEPEND ON THESE PARAMETERS

),,,( mgtx

WE WILL BE INTERESTED IN COMPUTINGSENSITIVITIES WITH RESPECT TO THESE PARAMETERS

),,,(

mgtx

MORE LATER

Page 10: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Logistics Equation

10)0( Rpp

)()(1

1)( 0 tptpK

rtpdt

d

LE

),),(()()(1

1)( 00 KrtpftptpK

rtpdt

d

ppK

rKrpf

11),,( 00

Page 11: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Analytical Solution

0 5 10 150

1000

2000

3000

4000

5000

6000

7000

8000

9000

10000

K

trepKp

KpKrtp

000

00 ),,(

Page 12: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Initial p0: 1 < p0 < 20,000

0 5 10 15 20 250

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2x 10

4

500,9 ,9163.0 Kr

1000 p

10 p

000,150 p

100 p

000,200 p

7500 p

15000 pK

Page 13: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Equilibrium States

)()(1

1)( 0 tptpK

rtpdt

d

LE

EQUILIBRIUM STATES ARE CONSTANT SOLUTIONS

constant a )( eptp

Kpp ee or 0

0)( tp

0)( tp ee ppK

r

110 0

0)( tp

0)( ee ptp Kptp ee )(

Page 14: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Equilibrium States

0 5 10 15 20 250

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2x 10

4

Kpp ee or 0

K

0

UNSTABLE STABLE

Page 15: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

A Falling Object

)()()( tvtvm

gtv

)()( tvty {

. y(t)

)()(0 tvtvm

g

)(0 tv

0

0

)(

)(

tv

ty

0 0

0gNO EQUILIBRIUM STATES

Page 16: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Terminal Velocity2 /

2 /

1( )

1

t g mmg mgt

t g m

ev t

e

220 ft/sec 150 m/hr

( ) ( )v t y t

Page 17: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

A Falling Object

)(ty)()( tytv

terter vvm

g

0 /gmvter

)()()( tytym

gty (0) 10,000 (0) 0y y

Page 18: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Systems of DEs

)()(

)(

)(

)(

)(

)(

22

2

2

1

2

1

txtxm

g

tx

tx

txf

tx

tx

dt

d

n

nn

n

n

nn

R

txtxtxf

txtxtxf

txtxtxf

tx

tx

tx

f

tx

tx

tx

dt

d

))(),...(),((

))(),...(),((

))(),...(),((

)(

)(

)(

)(

)(

)(

21

212

211

2

1

2

1

MORE EQUATIONS

Page 19: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Epidemic Models SIR Models (Kermak – McKendrick, 1927)

Susceptible – Infected – Recovered/Removed

( ) ( ) ( )dS t S t I t

dt

( ) ( ) ( ) ( )dI t S t I t I t

dt

( ) ( )dR t I t

dt

( ) ( ) ( ) constantS t I t R t N

Page 20: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Epidemic Models SIR Models (Kermak – McKendrick, 1927)

Susceptible – Infected – Recovered/Removed

)()()( tItStSdt

d

)()()()( tItItStIdt

d

)()( tItRdt

d

)()(

)()(

)()(

3

2

1

tRtx

tItx

tStx

),,(

),,(

),,(

3213

3212

3211

2

221

21

3

2

1

xxxf

xxxf

xxxf

x

xxx

xx

x

x

x

f

)()()( 211 txtxtxdt

d

)()()()( 2212 txtxtxtxdt

d

)()( 23 txtxdt

d

Page 21: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Systems of DEs

n

nn

n

n

nn

R

txtxtxf

txtxtxf

txtxtxf

tx

tx

tx

f

tx

tx

tx

dt

d

))(),...(),((

))(),...(),((

))(),...(),((

)(

)(

)(

)(

)(

)(

21

212

211

2

1

2

1

)()( txftxdt

d

n

n

Rx

x

x

x

2

1

nn RRf :)(

Page 22: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Initial Value Problems

)()( txftxdt

d nRxtx 00 )(

MOST OF THE TIME WE FORGET THE ARROW

)()( txftxdt

d nRxtx 00 )(

AND f CAN DEPEND ON TIME t AND PARAMETERS q

qtxtftxdt

d),(,)( nRxtx 00 )(

Page 23: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Basic Results

A solution to the ordinary differential equation (Σ) is adifferentiable function

)(,)( txtftxdt

d(Σ)

nRbatx ),(:)(

defined on a connected interval (a,b) such that x(t)

satisfies (Σ) for all t (a,b).

2)()( txtxdt

d

ttx

1

1)(

1 ,1

1)(

t

ttxl

tt

txr 1 ,1

1)(

TWO SOLUTIONS

Page 24: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Solutions

-3 -2 -1 0 1 2 3 4-20

-15

-10

-5

0

5

10

15

20

1 ,1

1)(

t

ttxl

tt

txr 1 ,1

1)(

Page 25: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Initial Condition

-3 -2 -1 0 1 2 3 4-20

-15

-10

-5

0

5

10

15

20

1)0( x

1 ,1

1)(

t

ttxl

Page 26: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Basic Theorems

Theorem 1. Let f: Rn ---> Rn be a continuous function on a domain D Rn, and x0 D. Then there exists at least one solution to the initial value problem (IVP).

)(,)( txtftxdt

d nRxtx 00 )((IVP)

),...,(

),...,(

),...,(

),...,,(

21

212

211

21

nn

n

n

n

xxxf

xxxf

xxxf

xxxtf

),...,,( 21 nij

xxxtfx

TO GET UNIQUENESS WE NEED MORE

Page 27: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Basic Theorems

Theorem 2. If there is an open rectangle about (t0, x0) such that

is continuous at all points (t, x) , then there a unique solution to the initial value problem (IVP).

),...,,( 21 nij

xxxtfx

nR

t

x0

t0

)(tx

Page 28: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

SIR Model

)()()( 211 txtxtxdt

d

)()()()( 2212 txtxtxtxdt

d

)()( 23 txtxdt

d

2

221

21

3213

3212

3211

),,(

),,(

),,(

x

xxx

xx

xxxf

xxxf

xxxf

21211 ),,,( xxxxf

12122

),,,( xxxfx

22121

),,,( xxxfx

0),,,( 2123

xxfx

12112

),,,( xxxfx

22111

),,,( xxxfx

0),,,( 2113

xxfx

221212 ),,,( xxxxxf

Page 29: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

SIR Model

00

0

0

),,( 12

12

3,...13,..1

321

xx

xx

xxxfx

ji

ij

ALL ENTRIES ARE CONTINUOUS FOR ALL

),,,,( 321 xxx

Theorem 1. IS OK

Page 30: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

A Falling Object

),,,,(

),,,,(),,,,(

212

211

22

2

21

mgxxf

mgxxfxx

mg

xmgxxf

2211 ),,,,( xmgxxf

0 ,)(

0 ,)(),,,,(

22

2

22

2

212

xxm

g

xxm

gmgxxf

0),,,,( 21

2111

xx

mgxxfx

1),,,,( 22

2112

xx

mgxxfx

NO PROBLEM SO FAR

Page 31: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

A Falling Object

0 ,)(

0 ,)(),,,,(

22

2

22

2

212

xxm

g

xxm

gmgxxf

0),,,,( 2121

mgxxfx

0 ,2

0 ,2

),,,,(

22

22

2122 xx

m

xxmmgxxf

x

AGAIN … CONTINUOUS FOR ALL ),,,,( 21 mgxx

Theorem 1. IS OK

Page 32: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Parameter Dependence

n

mnn

mn

mn

mn R

qqqxxxf

qqqxxxf

qqqxxxf

qqqxxxf

),...,,,...,(

),...,,,...,(

),...,,,...,(

),...,,,...,(

2121

21212

21211

2121

nn RRqf :),(

),,,,(

),,,,(),,,,(

212

211

22

2

21

mgxxf

mgxxfxx

mg

xmgxxf

FOR THE FALLING OBJECT …

Page 33: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Examples: n=m=1

5)0( ),()( xtqxtxdt

d

qxqxf ),(

qqxfx

),(

CONTINUOUS EVERYWHEREqteqtxtx 5),()(

UNIQUE SOLUTION

1)0( ,)(

)(

xqt

txtx

dt

d

qt

xqxtf

),,(

qtqxf

x

1

),(

CONTINUOUS WHEN 0 qt

22 /)(),( qqqtqtxq

qqtqtxtx /)(),()(

UNIQUE SOLUTION

qtteqtxq

5),(

Page 34: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Logistic Equation

2

2121

1),,( x

qxqqqxf x

qqqqxf

x 2121

2),,(

)()(1

1)( 0 tptpk

rtpdt

d

0)0( pp

)()(1

1)(2

1 txtxq

qtxdt

d

0)0( xx

kqrqtptx 101 , ),()(

tqexqx

xqqqtx

1020

0221 ),,(

),,( 211

qqtxq

),,( 212

qqtxq

Page 35: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Numerical Methods

))(,()()( 1

kk

kk

txtft

txtx

FORWARD EULER

)(,)( txtftxdt

d nRxtx 00 )((IVP)

))(,()()( 1 kkkk txttftxtx

t0

x0

t

kt1t 2t 1kt

Page 36: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Explicit Euler

t0

x0

t

kt1t 2t 1kt

1))(,()()( 0001 xtxttftxtxdefine

2),()( 1112 xxttfxtxdefine

))(,()()( 1112 txttftxtx

1),()( 1 k

define

kk xxttfxtx kk

Page 37: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Explicit Euler

t0

x0

t

kt1t 2t 1kt

ihttth i 0 ,

),(1 kkkk xtfhxx

Page 38: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Example 1

tetx 21)( 0)0( ),()( xxtqxtx

dt

d

qtextx 0)(

Page 39: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Explicit Euler

h=.2

h=.01

h=.1

tetx 21)(

k

kkk

qxhx

xtfhxx

k

k

),(1

qtextx 0)( 0)0( ),()( xxtqxtxdt

d

Page 40: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Example 2

02 )0( ,)()( xxtxqtx

dt

d

ttx

1

1)(

Page 41: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Example 2

h=.2

h=.1

02 )0( ,)()( xxtxqtx

dt

d

]1[

][

),(2

1

kk

k

k

qxhx

xqhx

xtfhxx

k

kkk

Page 42: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Typical MATLAB m files

Eeuler_1.m Eeuler_2.m

Page 43: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Simple Example 3

101)( ,1

101)( ,)),((

tx

txtxf(t)x

10 )x(

0

10 ),10(101

100 ,1

tt

ttx(t)

10

1

10

Page 44: Computational Methods for Design Lecture 3 – Elementary Differential Equations John A. Burns C enter for O ptimal D esign A nd C ontrol I nterdisciplinary.

Simple Example 3

10 x),(1 kkk xfhxx

hfhxfhxx 1),1(1),( 01 0

,epsh IF

10

1

PROBLEM ISFINITE PRECISION

ARITHMETIC

MESH REFINEMENTMAKES THE PROBLEM

WORSE

11... 11 hxxx kk

101 ,1

101 ,),(

x

xxf ),1(f

hx 11 1