of Ordinary Differential Equations

Reading: NDAC Secs. 2.8 and 6.1

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

Monday, April 19, 2010 1 Numerical Integration ...

Dynamical System:{X , T}

State Space: X State: x ∈X x X

Dynamic: T : X→X

x! x X X

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

Monday, April 19, 2010 2 Numerical Integration ...

Dynamical System ... For example, continuous time ... d !x˙ F! !x Ordinary : = ( ) (˙ = dt ) n State: !x (t) ∈ R !x =(x1,x2,...,xn)

Initial condition: !x (0)

! n n Dynamic: F : R → R F! =(f1,f2,...,fn)

Dimension: n

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

Monday, April 19, 2010 3 Numerical Integration ... X = R2 ￿x = (x1, x2) Geometric view of an ODE: F￿ = (f1(￿x), f2(￿x)) d￿x = F￿ (￿x) !x ! !x tF! !x dt = +∆ ( )

d￿x ∆￿x ￿x￿ ￿x = − ∆x2 = f2(!x ) dt ≈ ∆t ∆t !x ∆x1 = f1(!x )

Each state !x has a vector attached F￿ (￿x)

that says to what next state to go: ￿x ￿ = ￿x + ∆ t F￿ ( ￿x ) . ·

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

Monday, April 19, 2010 4 Numerical Integration ...

Vector field for an ODE (aka ) X = R2 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 2010); Jim Crutchfield

Monday, April 19, 2010 5 Numerical Integration ...

Time-T Flow: T T ˙ ￿x(T ) = φT (￿x(0)) = dt ￿x = dt F￿ (￿x(t)) ￿0 ￿0 The solution of the ODE, starting from some IC Simply follow the arrows

!x (0)

!x (T )

φT Point: ODE is only instantaneous, flow gives state for any time t. Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2010); Jim Crutchfield

Monday, April 19, 2010 6 Numerical Integration ...

Euler Method in 1D: x˙ = f(x)

dx ∆x x x = n+1 − n dt ≈ ∆t ∆t

x(t + ∆t) x = x + f(x )∆t 0 ≈ 1 0 0

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

A discrete-time map!

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

Monday, April 19, 2010 7 Numerical Integration ...

Improved in 1D:

x˙ = f(x)

A trial (Euler) step:

xn = xn + f(xn)∆t

The resulting better estimate (averaged at t n and t n +1 ): ￿

1 xn+1 = xn + 2 [f(xn) + f(xn)] ∆t

￿

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

Monday, April 19, 2010 8 Numerical Integration ...

Fourth-order Runge-Kutta Method in 1D:

Intermediate estimates:

k1 = f(xn)∆t 1 k2 = f(xn + 2 k1)∆t 1 k3 = f(xn + 2 k2)∆t k4 = f(xn + k3)∆t

Final estimate:

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

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

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

Monday, April 19, 2010 9 Numerical Integration ... Runge-Kutta in nD:

n n n ￿x˙ = f￿(￿x), x R f￿ : R R ∈ → Intermediate estimates:

￿k1 = f￿(￿xn)∆t ￿ ￿ 1￿ k2 = f(￿xn + 2 k1)∆t ￿ ￿ 1￿ k3 = f(￿xn + 2 k2)∆t

￿k4 = f￿(￿xn + ￿k3)∆t Final estimate: 1 ￿ ￿ ￿ ￿ ￿xn+1 = ￿xn + 6 k1 + 2k2 + 2k3 + k4 ￿ ￿ Lecture NI: Nonlinear Physics, Physics 150/250 (Spring 2010); Jim Crutchfield

Monday, April 19, 2010 10