Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan...

30
Modified equations for Hamiltonian systems Jitse Niesen (University of Leeds) Per Christian Moan Institute of Computational Mathematics and Scientific/Engineering Computing Chinese Academy of Sciences, Beijing 22 August 2011

Transcript of Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan...

Page 1: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Modified equations for Hamiltonian systems

Jitse Niesen (University of Leeds)

Per Christian Moan

Institute of Computational Mathematics andScientific/Engineering Computing

Chinese Academy of Sciences, Beijing

22 August 2011

Page 2: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Feng Kang

Page 3: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Numerical integratorsA numerical integrator applied to the initial value problem (IVP)

y ′ = f (y), y(0) = y0,

yields a sequence y1, y2, y3, . . . that approximates the solution tothe IVP: yn ≈ y(nh).

For instance, the (forward) Euler method is:

yn+1 = yn + hf (yn).

Apply this to y ′ = 0.2 y , y(0) = 1 with step size h = 0.5:

0 2 4 6 8t

012345

y

y(t)

y0y1

y2y3

y4

y5

y6

y7

y8

Page 4: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Modified equations

The modified equation is the initial value problem

y ′ = f (y), y(0) = y0,

such that its solution interpolates the numerical solution:yn = y(nh) (modulo technicalities).

The numerical method solves the original equation approximately,but it solves the modified equation exactly (backward erroranalysis).

0 2 4 6 8t

012345

y

y(t)

y(t)

Page 5: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Modified equations: An exampleConsider the Euler method yn+1 = yn + hf (yn) applied to thelinear test equation

y ′ = λy , y(0) = y0,

The numerical method reduces to yn+1 = yn + hλyn = (1 + hλ)yn,so yn = (1 + hλ)ny0.

The function

y(t) = (1 + hλ)t/h = exp

(log(1 + hλ)

ht

)interpolates the numerical solution: yn = y(nh).

The function y satisfies the differential equation

y ′ =log(1 + hλ)

hy .

This is the modified equation.

Page 6: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Outline

I Modified equations

I Hamiltonian equations and symplectic integrators

I The modified energy

I The work of Skeel et al.

I Richardson extrapolation

I Example: The pendulum

I Exponentially small remainder for modified energy

I Error when computing the modified energy

I Example: The Kepler problem

I Conclusion

Page 7: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Outline

I Modified equations

I Hamiltonian equations and symplectic integrators

I The modified energy

I The work of Skeel et al.

I Richardson extrapolation

I Example: The pendulum

I Exponentially small remainder for modified energy

I Error when computing the modified energy

I Example: The Kepler problem

I Conclusion

Page 8: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Hamiltonian equations

A Hamiltonian equation is of the form

q′ =∂H

∂p(q, p), p′ = −∂H

∂q(q, p)

for some function H.

We can write this as y ′ = J∇H(y) where J =[

0 I−I 0

]and y =

[ qp

].

Solutions preserve energy H, meaning that H(y(t)) = H(y(0)).

In this talk, we only consider separable Hamiltonians, meaning thatH is of the form H(q, p) = T (p) + V (q) (kinetic plus potentialenergy), yielding the equations q′ = ∇T (p), p′ = −∇V (q).

Page 9: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

The pendulum

Hamiltonian equation: q′ =∂H

∂p(q, p), p′ = −∂H

∂q(q, p)

For example, the mathematical pendulum is described by

q′ = p, p′ = − sin q,

which is the Hamiltonian equation for H = 12p

2 − cos q.

0 2 4 6 8 101.51.00.50.00.51.01.5

q(t)

p(t)

H(t)

Page 10: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

The pendulum: Numerical solution

Apply Euler method with h = 0.05.

{qn+1 = qn + hpnpn+1 = pn − h sin qn

0 81.5

0.0

1.5

0 100

Apply leap-frog method with h = 1.

qn+ 1

2= qn + 1

2hpnpn+1 = pn − h sin qn+ 1

2

qn+1 = qn+ 12

+ 12hpn+1

0 81.5

0.0

1.5

0 100

Page 11: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Symplectic integrators

Let Φt be the flow map of the Hamiltonian equation y ′ = J∇H(y);that is, Φt maps y(0) to y(t) where y is a solution of the equation.

Then, Φt is a symplectic map: it satisfies (DΦt)T J DΦt = J

where DΦt is the Jacobian matrix.

Let Ψf be the time stepping function of a numerical integratorapplied to y ′ = f (y); that is, Ψf maps yk to yk+1. For forwardEuler, Ψf (y) = y + hf (y).

The method is a symplectic integrator if Ψf is a symplectic mapwhenever the method is applied to a Hamiltonian equation. Theleap-frog method is symplectic; Euler’s method is not.

Thus, symplectic integrators preserve the symplectic structure ofthe ODE. They do not preserve energy, but energy drift isbounded. Modified equations can explain this.

Page 12: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Modified energy

If a non-symplectic method is used on a Hamiltoian equation, themodified equation will not be Hamiltonian.

However, if a symplectic integrator is used, then the modifiedequation is Hamiltonian: y ′ = J∇H(y). Modified equation reflectthe structure-preserving properties of the integrator.

We call H the modified energy.

The main topic of this talk is how to compute the modified energy.

Motivation: The modified energy can be used to detect numericalinstabilities.1 Computing the modified energy is also useful toillustrate and guide backward error analysis.

1 Skeel & Hardy, SIAM J. Sci. Comp., 23:1172–1188 (2001).

Page 13: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Outline

I Modified equations

I Hamiltonian equations and symplectic integrators

I The modified energy

I The work of Skeel et al.

I Richardson extrapolation

I Example: The pendulum

I Exponentially small remainder for modified energy

I Error when computing the modified energy

I Example: The Kepler problem

I Conclusion

Page 14: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

The extended Hamiltonian

Given Hamiltonian H(q, p), equations are q′ = ∂H∂p and p′ = −∂H

∂q .

Define homogeneous extension of H by

He(q, α, p, β) = α2H(1αq,

1αp).1

Hamilton’s equations for He are:

q′ =∂He

∂p= α

∂H

∂p, p′ =

∂He

∂q= −α∂H

∂q,

α′ =∂He

∂β= 0, β′ = −∂H

e

∂α= −2αH + qT

∂H

∂q+ pT

∂H

∂p.

If α(0) = 1, then α(t) = 1 for all t, so (q, p) evolve under He asunder H. Furthermore,

β′ = −2H + qTp′ − pTq′.

1 Skeel & Hardy, SIAM J. Sci. Comp., 23:1172–1188 (2001).

Page 15: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Numerical integrators and the extended Hamiltonian

Given Hamiltonian H(q, p), equations are q′ = ∂H∂p and p′ = −∂H

∂q .

Modified eq’n is q′ = ∂H∂p , p′ = −∂H

∂q where H is modified energy.

Extended Hamiltonian He = α2H(1αq,

1αp)

yields equations:

q′ =∂H

∂p, p′ = −∂H

∂q, α′ = 0, β′ = −2H + qTp′ − pTq′.

If a splitting method is used, then modified energy for He ishomogeneous extension of modified energy for H: He = (H)e .1

Thus modified equation for He is

q′ =∂H

∂p, p′ = −∂H

∂q, α′ = 0, β′ = −2H + qT p′ − pT q′.

Last equation implies H = 12(qT p′ − pT q′ − β′).

1 Skeel & Hardy, SIAM J. Sci. Comp., 23:1172–1188 (2001).

Page 16: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Computing the modified energy

We can use numerical solution {qn, pn, βn} to estimateH = 1

2(qT p′ − pT q′ − β′). For instance, a second-orderapproximation is

1

2

(qTn

pn+1 − pn−12h

− pTnqn+1 − qn−1

2h− βn+1 − βn−1

2h

)Higher-order approximations can be constructed:2

2 Engle, Skeel & Drees, J. Comput. Phys., 206:432–452 (2005).

Page 17: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Richardson extrapolation

We propose the use of Richardson extrapolation to approximateH = 1

2(qT p′ − pT q′ − β′).

Richardson extrapolation combines two approximations of the sameorder into one higher-order approximation.

Suppose we want to approximate z ′(0) for some function z .Construct two second-order approximations:

T1 =z(12h)− z(−1

2h)

hand T2 =

z(h)− z(−h)

2h

Then T ∗ = T2 + 13(T2 − T1) is a fourth-order approximation.

This process can be repeated to get approximants of higher andhigher orders. It is used in Romberg’s method to compute integralsand in the Stoer–Bulirsch method to solve ODEs.

Page 18: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Computing modified energy with Richardson extrapolation

We want to approximate H = 12(qT p′ − pT q′ − β′).

First, compute second-order approximations using centraldifferences:

T nj ,1 =

1

2

(qTn

pn+j − pn−j2jh

− qTnpn+j − qn−j

2jh−βn+j − βn−j

2jh

).

Then, apply Richardson extrapolation recursively:

T nj ,k+1 = T n

j ,k +T nj ,k − T n

j−1,k(1− k/j)2 − 1

(for k < j).

After j iterations we get a (2j)-th order approximation to themodified energy: T n

j ,j = H(qn, pn) +O(h2j).

The error in Tj ,j can be estimated as Tj+1,j+1 − Tj ,j .

We use Arprec multiple-precision library with 200 digits.

Page 19: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

The pendulum: H = 12p

2 − cos(q)Solve pendulum with leap-frog rule over t = [0, 100] and computeenergy drift ∆H = maxn H(qn, pn)−minn H(qn, pn) using Tj ,j forj = 2, 5, 10, 15, 20, 30, 40 and various values of step size h.

0 20 40 60 80 1001/h

10-50

10-40

10-30

10-20

10-10

100

drift

usi

ng Tj,j

2

5

10

15

20

Red line, corresponding to j = 200, shows that ∆H ≈ C1e−C2/h.

Page 20: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

The pendulum: H = 12p

2 − cos(q)

Set q(0) = 0 and vary initial condition for p(0).

0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4p(0)

10-100

10-80

10-60

10-40

10-20

100dr

ift in

mod

ified

ene

rgy

h=1/5

h=1/10

h=1/15

h=1/20

The drift in modified energy decreases as we approach theequilibrium point (q, p) = (0, 0).

Page 21: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Outline

I Modified equations

I Hamiltonian equations and symplectic integrators

I The modified energy

I The work of Skeel et al.

I Richardson extrapolation

I Example: The pendulum

I Exponentially small remainder for modified energy

I Error when computing the modified energy

I Example: The Kepler problem

I Conclusion

Page 22: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Modified equations done rigorously

Actually, there is no f such that solution of y ′ = f (y) interpolatesnumerical solution, yn = y(nh).

The standard approach is to use a divergent but asymptotic series:

f ∼ f + hp+1fp+1 + hp+2fp+2 + hp+3fp+3 + · · ·

If f[k] is truncation of order k and y[k] solves y ′[k] = f[k](y[k]) then

yn = y[k](nh) +O(hk+1).

If f is analytic and truncation index k is chosen suitably (varyingwith h), then the remainder is exponentially small:

|y1 − y[k](h)| ≤ C1he−C2/h.

In Hamiltonian setting, y[k] preserves exactly the modified

energy H[k], so numerical drift in modified energy is exponentially

small over exponentially long intervals.3

3 Tang Yifa (1994), Benettin & Giorgilli (1994), Hairer & Lubich (1997), . . .

Page 23: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

An alternative approach

It is possible to find a modified equation if we allow it to benon-autonomous.4

The modified equation is y ′ = f1(y) + f2(y , t) where thetime-dependent part f2 is h-periodic and exponentially small:

‖f2‖ ≤ C1h−1‖f ‖ exp

(− C2

h‖f ‖

),

where ‖ · ‖ denotes max-norm in complex neighbourhood of y(t).

Solution of modified equation interpolates numerical solutionexactly: yn = y(nh).

In Hamiltonian setting, modified energy H = H1(y) + H2(y , t) istime-dependent, so not conserved.

However, energy drift ddt H(y(t)) = ∂H2

∂t is exponentially small.

4 Moan, J. Phys. A, 39:5545–5561 (2006).

Page 24: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Theorem on time-dependent modified equationsSuppose that f is analytic in

D =⋃t>0

{z ∈ Cd : |=(y(t)− z)|∞ < R}.

Let ‖f ‖D = supz∈D |f (z)|∞.

If one-step method Ψf is analytic, then there exists a modifiedvector field f (y , t) = f1(y) + f2(y , t) analytic in

D′ =

{(z , τ) ∈ Cd × C : |=(z − y(t))‖∞ < R − δ, |=(τ − t)| < δη

e‖f ‖D

}for all δ ∈ (0,R) and η ∈ (0, 1).The time-dependent part f2 is h-periodic: f2(y , t + h) = f2(y , t).The modified equation satisfies the estimates:

‖f ‖D′ ≤2

1− η‖f ‖D

‖f2‖D′ = O(‖f ‖Dh

exp

(− 2πδη

eh‖f ‖D

)).

Page 25: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Error in computing the modified energy

Drift in modified energy is exponentially small.Can we recover it numerically?

Yes! If j∗ is chosen suitably, then error in j∗-th approximation inRichardson tableau is exponentially small:

|H(qn, pn, ty )− T nj∗,j∗ | ≤ C ′1h

−1‖f ‖ exp

(− C ′2h‖f ‖

).

This bound is of same form as bound on time-dependent part

‖f2‖ ≤ C1h−1‖f ‖ exp

(− C2

h‖f ‖

).

Thus, we should be able to track (accumulated) drift in modifiedenergy numerically.

Page 26: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Kepler problem: Estimated error in Tj ,j against j

0 20 40 60 80 100j

10-50

10-40

10-30

10-20

10-10

100

|Tj+

1,j

+1−Tj,j|

We use ad hoc criterion to find truncation point: smoothen curveby taking maximum over 10 values and find minimum ofsmoothened curve (see stars in plot).

Page 27: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Kepler problem: Energy drift against time

0 20 40 60 80 100time

10-50

10-40

10-30

10-20

10-10

100

drift

in m

odifi

ed e

nerg

y

h=1/10

h=1/20

h=1/40

h=1/80

Modified energy shows drift when approaching point closest tosingularity but recovers afterwards.

Page 28: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Kepler problem: Energy drift against h

0 50 100 150 2001/h

10-80

10-60

10-40

10-20

100

drift

in m

odifi

ed e

nerg

y

Again, ∆H ≈ C1e−C2/h, confirming theory.

Page 29: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Kepler problem: Other methods

0 20 40 60 80 1001/h

10-40

10-30

10-20

10-10

100

drift

in m

odifi

ed e

nerg

y

Leap-frogYoshidaBlanes/Moan

Also include Yoshida’s fourth-order method5 and highly optimized6-stage fourth order method of Blanes and Moan.6

5 Yoshida, Phys. Lett. A, 150:262–268 (1990).6 Blanes & Moan, J. Comput. Appl. Math, 142:313–330 (2002).

Page 30: Jitse Niesen (University of Leeds) Per Christian Moan ...jitse/cas11.pdf · Per Christian Moan Institute of Computational Mathematics and ... The Kepler problem ... Modi ed energy

Conclusion

I Richardson extrapolation can be used to track drift inmodified energy.

I Error estimates show that error is of similar magnitude as driftin modified energy, so we can capture the drift numerically.

I Experiments confirm exponentially small drift, also forHenon–Heiles system which Skeel could not do.

I If preserving modified energy over long times is priority, thenthere seems no reason to use higher-order methods.

I Can we use modified energy to study chaotic islands inpendulum (numerically induced chaos)?

I Need better stopping criterion for Richardson extrapolation; orperhaps use convergence acceleration?