numerical integration of ordinary differential...

10
Numerical Integration of Ordinary Differential Equations Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield Reading: NDAC Secs. 2.8 and 6.1 1

Upload: others

Post on 08-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integrationof

Ordinary DifferentialEquations

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

Reading: NDAC Secs. 2.8 and 6.1

1

Page 2: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Dynamical System:

State Space:State:

Dynamic:

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

{X , T }

X

T : X ! X

x ! X

X

x

x

X X

x!

2

Page 3: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Dynamical System ... For example, continuous time ...

Ordinary differential equation:

State:

Initial condition:

Dynamic:

Dimension:

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

!x = !F (!x)

!x(t) ! Rn

!F : Rn! R

n

!x(0)

( ˙ =d

dt)

!x = (x1, x2, . . . , xn)

!F = (f1, f2, . . . , fn)

n

3

Page 4: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Geometric view of an ODE:

Each state has a vector attached

that says to what next state to go: .

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

X = R2

!x!x1 = f1(!x)

!x2 = f2(!x)

!x! = !x + !t!F (!x)

!x !F (!x)

!x! = !x + !t · !F (!x)

d!x

dt= !F (!x)

d!x

dt! !!x

!t=

!x! " !x

!t

!x = (x1, x2)!F = (f1(!x), f2(!x))

4

Page 5: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Vector field for an ODE (aka Phase Portrait) A set of rules: Each state has a vector attached That says to what next state to go

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

X = R2

5

Page 6: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Time-T Flow:

The solution of the ODE, starting from some IC Simply follow the arrows

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

Point: ODE is only instantaneous, flow gives state for any time t.

!x(0)

!x(T )

!T

!x(T ) = "T (!x(0)) =! T

0dt !x =

! T

0dt !F (!x(t))

6

Page 7: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Euler Method in 1D:

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

x = f(x)

x(t0 + !t) ! x1 = x0 + f(x0)!t

xn+1 = xn + f(xn)!t

dx

dt! !x

!t=

xn+1 " xn

!t

A discrete-time map!

7

Page 8: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Improved Euler Method in 1D:

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

x = f(x)

A trial (Euler) step:

The resulting better estimate (averaged at and ):

xn+1 = xn + 12 [f(xn) + f(!xn)]!t

tn tn+1

!xn = xn + f(xn)!t

8

Page 9: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Fourth-order Runge-Kutta Method in 1D:

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

k1 = f(xn)!t

k2 = f(xn + 12k1)!t

k3 = f(xn + 12k2)!t

k4 = f(xn + k3)!t

xn+1 = xn + 16 [k1 + 2k2 + 2k3 + k4]

Intermediate estimates:

Final estimate:

Good trade-off between accuracy and time-step size.

9

Page 10: Numerical Integration of Ordinary Differential Equationscsc.ucdavis.edu/~chaos/courses/nlp/Software/PartG_Code/Numerica… · The solution of the ODE, starting from some IC Simply

Numerical Integration ...

Runge-Kutta in nD:

Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2009); Jim Crutchfield

!k1 = !f(!xn)!t

!k2 = !f(!xn + 12!k1)!t

!k3 = !f(!xn + 12!k2)!t

!k4 = !f(!xn + !k3)!t

!xn+1 = !xn + 16

!!k1 + 2!k2 + 2!k3 + !k4

"

Intermediate estimates:

Final estimate:

!x = !f(!x), x ! Rn !f : Rn ! Rn

10