Sei sulla pagina 1di 14

Numerical Analysis Seminar

Fr
uhjahrssemester 08

Lecturers: Prof. M. Torrilhon, Prof. D. Kressner

The St
ormer-Verlet method
F. Crivelli (flcrivel@student.ethz.ch)
May 8, 2008

Introduction
During this talk Ill introduce the St
ormer-Verlet method, also known by the name
leap-frog method or Newton method or more extensively Newton-St
ormer-Verlet-leapfrog
method. This method is used in order to find numerical solutions of ordinary differential
equations: its various names are due to the different branchs of science in which the
method is used. Carl Stormed used this method for his computations of the motion of
ionized particles in the earths magnetic field (aurora borealis) in 1907; in the context
of partial differential equations of wave propagation, this method is called leap-frog
method; Loup Verlet in 1967 used this method in molecular dynamics and then he
discovered that Newton used this method in his Principia Mathematica in 1687.

Ordinary differential equations

In this paragraph Ill just remind some basis definitions of the language of ordinary
differential equations.
Definition 1. Let

y : R R
x 7 y(x)

be an unknown function of x and denote by y (i) its i-th derivative. An Ordinary


Differential Equation (ODE) of order n is an equation of the form

F x, y, y 0 , . . . , y (n1) = y (n) ,
where F : Rn+1 R is a function.
This leads to the definition of a solution of an ODE.

Definition 2. A solution of an ODE of dimension n, F x, y, y 0 , . . . , y (n1) = y (n) ,
is a function u : I R
on I, F is defined
 R such that u is n-times differentiable

for all x, u, u0 , . . . , u(n1) , x I, and F x, u, u0 , . . . , u(n1) = u(n) , x I.

Solutions of ODE of order n usually contain n parameters, resulting from the


constants of integration. This parameters can be uniquely determined if we give an
(i1)
initial condition at the ODE, i.e., for some x0 R and y0
R, i = 1, . . . , n, we
want the solution to satisfy the conditions
(i)

y (i) (x0 ) = y0 , i = 0, . . . , n 1.
We have another important
Definition 3. Let yi : R R, i = 1, . . . , n, be unknown functions of the variable x.
A first order system of differential equations of dimension n is a system
of equations of the form
y10 = F1 (x, y1 , . . . , yn )
y20 = F2 (x, y1 , . . . , yn )
.. .. ..
. . .
yn0 = Fn (x, y1 , . . . , yn )
where Fi : Rn+1 R, i = 1, . . . , n, are functions. Setting
y := (y1 , . . . , yn )T , F := (F1 , . . . , Fn )T ,
the system becomes
y 0 = F(x, y),
with y and F interpreted as vectors. This notation was introduced by Giuseppe Peano
in 1890.

Take an ODE of order n, F x, y, y 0 , . . . , y (n1) = y (n) . If we write yi (x) :=
y i1 (x), i = 1, . . . , n, we obtain a first order system of differential equations of dimension n
y10 = y2
y20 = y3
..
.. ..
.
. .
0
yn1
= yn
0
yn = F (x, y1 , . . . , yn )
Hence, we can switch from an ODE of dimension n to a first order system of differential
equations.
We look at the existence and uniqueness of solutions of a first order system of
differential equations of dimension n. We state this theorem without proof.

Theorem 1. Let y 0 = F(x, y) be a first order system of differential equations of


dimension n with y = (y1 , . . . , yn )T and F = (F1 , . . . , Fn )T and initial conditions
yi (x0 ) = yi0 , x0 , yi0 R, i = 1, . . . , n. Assume that F is continuous and that Fi is
Lipschitz in the variables yj for all i, j = 1, . . . , n, i.e.,
| Fi (x, y1 , . . . , yn ) Fi (x, y1 , . . . , yn ) | M max | yj yj |, i = 1, . . . , n,
1jn

where M > 0 is a positive constant. Then the first order system of differential equations y 0 = F(x, y) has a unique solution y1 (x), . . . , yn (x) on the interval
I := {x R s.t. | x x0 | }
for some > 0.
2

Runge-Kutta methods

We are interested in solving numerically ODE and in how different numerical methods
behave on ODEs, especially the Stormer-Verlet method. In order to do that, we
introduce a family of methods, called Runge-Kutta methods in honor to the German
mathematicians Carl Runge and Martin Kutta who developed these methods. One
thing should always be in the mind of the reader, looking to a numerical method for
solving an ODE: the expression of the derivative of a function g
g(a + h) g(a)
,
h0
h

g 0 (a) = lim

because this gives an approximation of the function at the point a + h, for small h,
g(a + h) g(a) + hg 0 (a).
This leads to the Taylor series of g, that gives a good approximation of a function.
We will now define the Runge-Kutta methods family and concentrate on two of the
most famous methods of this type: the midpoint method and the Euler method. We
give just the definition for an ODE of first order, since we know that if the ODE is
of order greater than 1, we can always translate the ODE on to a first order system
of differential equations.
Definition 4. Let F (x, y) = y 0 be an ODE with initial condition y(x0 ) = y0 . Let
h > 0 be a positive real, called step size, and s a positive integer, called number of
stages. Define xn := x0 + nh and let yn be the approximation of y(xn ), n 0. Then
a s-stage explicit Runge-Kutta method is of the form
yn+1 = yn + h

s
X

bj kj

j=1

where
k1 = F (xn , yn )
k2 = F (xn + c2 h, yn + ha21 k1 )
k3 = F (xn + c3 h, yn + h(a31 k1 + a32 k2 ))
.. .. ..
. . .
ks = F (x0 + cs , yn + h(as1 k1 + + as,s1 ks1 ))
and a21 , a31 , a32 , . . . , as1 , . . . , as,s1 , b1 , . . . , bs , c1 , . . . , cs R.
Remark:
1. A method is often denoted by h , with h > 0 the step size, in order to say
the yn+1 = h (yn ). h is called an one-step method because we approximate
y(xn+1 ) just by yn and not by other previous approximation (e.g. by yn and
yn1 ). The function h : R R is called the numerical flow.

2. The term explicit refers to the fact that we compute directly the approximation
yn+1 from yn , i.e., yn+1 = (yn ) and not that we can find yn+1 solving an
equation, i.e., yn+1 = h (yn+1 , yn ). In the latter case the method is called
implicit.
It is easy to extend the definition and the remarks in the case of a first order system
of differential equations of finite dimension.
We will not discuss the convergence of a method, i.e., if the approximate solution
approaches the exact solution when h goes to 0, in details because it will require
some advanced definitions...
Definition 5. The local error of a method is the error made by a step of the method,
assuming that no error was made in earlier steps:
h := ||y(xn + h) yn+1 || = ||y(x0 + h) y1 || .
A method is said to be consistent if
h
=0
h0 h
lim

and to have order p if h = O(hp+1 ) as h 0. Clearly if a method is of order p 1,


it is also consistent.
A Runge-Kutta method is consistent if we have
ci =

i1
X

aij , 2 i s.

j=1

2.1

The explicit Euler method

The explicit Euler method is a 1 stage Runge-Kutta method of the form


yn+1 = yn + hF (xn , yn ).
This method is simplest Runge-Kuttas method. Indeed, for small h > 0, we have
y 0 (x)

y(x + h) y(x)
,
h

and this gives


y(x + h) y(x) + hF (x, y(x)) .
Hence, this method is just the simplest approximation given by the definition of
derivative.
We have that
y(x0 + h) = y(x0 ) + hy 0 (x0 ) + O(h2 )
4

using the Taylor series of y. We know that


y 0 (x0 ) = F (x0 , y) = F (x0 , y0 ) and y(x0 ) = y0 ,
therefore
y(x0 + h) y1 = y(x0 ) + hy 0 (x0 ) y0 hF (x0 , y0 ) + O(h2 )
= y0 + hF (x0 , y0 ) y0 hF (x0 , y0 ) + O(h2 )
= O(h2 ),
so the Euler methods has order 1.

2.2

The explicit midpoint method

The midpoint method is a 2 stages Runge-Kutta method given by the formula




h
h
yn+1 = yn + hF xn + , yn + F (xn , yn ) .
2
2
Geometrically, the midpoint method can be viewed in the following way: assuming
that yn is the exact value of y(xn ), the midpoint method gives yn+1 such that the
segment between yn and yn+1 is approximatively parallel to the tangent line at the
midpoint y(xn + h/2).

We look at the Taylor expansions of y(x0 + h) and F x0 + h2 , y0 + h2 F (x0 , y0 ) :
y(x0 + h) = y(x0 ) + hy 0 (x0 ) +

h2 00
y (x0 ) + O(h3 )
2

and


h
h
h
h
F x0 + , y0 + F (X0 , y0 ) = F (x0 , y0 )+ Fx (x0 , y0 )+ F (x0 , y0 )Fy (x0 , y0 )+O(h2 ),
2
2
2
2
where Fx , resp. Fy , denotes the partial derivative of F with respect to the variable
x, resp. to the variable y. This gives

y1 = y0 + hF x0 + h2 , y0 + h2 F (x0 , y0 )

= y0 + h F (x0 , y0 ) + h2 Fx (x0 , y0 ) + h2 F (x0 , y0 )Fy (x0 , y0 ) + O(h2 )
2
2
= y0 + hF (x0 , y0 ) + h2 Fx (x0 , y0 ) + h2 F (x0 , y0 )Fy (x0 , y0 ) + hO(h2 )
2
2
= y0 + hF (x0 , y0 ) + h2 Fx (x0 , y0 ) + h2 F (x0 , y0 )Fy (x0 , y0 ) + O(h3 ).
On the other side, we know that y(x0 ) = y0 and y 0 (x0 ) = F (x0 , y0 ). Moreover, we
find that
y 00 (x0 ) = Fx (x0 , y0 ) + F (x0 , y0 )Fy (x0 , y0 ).
Finally, we get
y(x0 + h) y1 = O(h3 ),
hence, the midpoint method has order 2.
5

Figure 1: The exact solution ex of the ODE y 0 = y, y(0) = 1 is the red line, in green
we have the midpoint approximation and in blue the Euler approximation. The step
size in the left picture is h = 1, in the right picture h = 0.25. The right picture shows
that the midpoint method converges faster than the Euler method.

2.3

Example

We want to solve numerically, using the two methods presented above, the ODE
y 0 = y, y(0) = 1.
The exact solution is ex . Fix h > 0. For the Euler method we get
yn = (1 + h)n , n 0
while for the midpoint method we get
n

h2
, n 0.
yn = 1 + h +
2

St
ormer-Verlet method

In this section, the Stormer-Verlet method is presented, with some of its interesting
properties, in the special case of a second order ODE of the form
q = F (q),
where the right-hand side does not depend on q.
This equation is common in physics.
There are variations of the Stormer-Verlet method for a genereal second order ODE.
6

Figure 2: Stormer-Verlet method. Left: two-step formulation. Right: one-step formulation.

3.1

Definition

Let h > 0 be the step size. The simplest case is just the discretisation of the ODE,
i.e.,
qn+1 2qn + qn1 = h2 F (qn ).
It is a two-step method since qn+1 is computed using qn and qn1 . This formulation is
not very interesting. We know that we can transform a second order ODE into a first
order system of differential equations of dimension 2, in order to do so, we introduce
the unknown function v = q and the system becomes
v = q,
v = F (q).
In physics often this type of system is closely related to the motion of a physical body.
In this sense, we can see v as the velocity, q as the displacement (as functions of the
time) and F describes some kind of force acting on the physical body.
We set
qn+1 qn1
.
vn =
2h
Inserting these expressions in the two-step formulation gives a one-step method h :
(qn , vn ) 7 (qn+1 , vn+1 ) of the form

qn+1 = qn + h vn + h2 F (qn ) ,
vn+1 = vn + h2 F (qn ) + h2 F (qn+1 ).
This formulation of the Stormer-Verlet method is more economic to implement for
numerical calculation and is also numerically more stable than the two-step formulation.
Recall that the flow of a first order system of differential equations y = F(x, y)
of dimension n is the function x : Rn Rn which associates, for a given x, to the
7

initial condition y0 = y(x0 ) the corresponding solution value at x


x (y0 ) = y(x),
where y depends on the choice of the initial value y0 . Sometimes x is called the
exact flow, in order to avoid confusion between the flow of a first order system of
differential equations and the numerical flow of a method.
Let us look at the order of the Stormer-Verlet method. Recall that h = ||y(x0 + h) y1 ||,
where y(x) is the solution of the system
  

q
v
y =
=
= F(y).
v
F (q)
with initial conditions v0 = v(x0 ), q0 = q(x0 ). We have
 
 



q0 + h v0 + h2 F (q0 )
q(x0 + h)
q1
=
and y(x0 + h) =
y1 =
v1
v(x0 + h)
v0 + h2 F (q0 ) + h2 F (q1 )
We have also the following Taylor expansions
2

q(x0 + h) = q0 + hv0 + h2 F (q0 ) + O(h3 ),


2
v(x0 + h) = v0 + hF (q0 ) + h2 v(x0 ) +
O(h3 ),

F (q1 )
= F (q0 ) + h v0 + h2 F (q0 ) F (q0 ) + O(h2 ).
Note that v(x0 ) = F (q0 )v0 since v(x)

= F (q(x)) gives v(x) = F (q(x)) q(x)

F (q(x)) v(x). We have


q(x0 + h) q1 = O(h3 ) and v(x0 + h) v1 = O(h3 )
and this implies that the Stormer-Verlet method has order 2.

3.2

Properties

We introduce some notions.


Definition 6. Let h : (qn , vn ) 7 (qn+1 , vn+1 ) be a one-step method for the first
order system of differential equations v = q,
v = F (q).
h is called symmetric if
h = 1
h ,

where 1
h denotes the method h : (qn+1 , vn+1 ) 7 (qn , vn ), i.e, we invert the
subscripts n and n + 1, as a reflection based on xn+ 1 .
2

the numerical flow h is called reversible if


h (q, v) = (
q , v) implies h (
q ,
v ) = (q, v),
for all q, v and for all h.
8

Figure 3: On the right some non-symplectic methods. On the left the simplecticity
of the Stormer-Verlet method.

the method h is called symplectic if it satisfies






0 1
0 1
0
T
0
h (q, v)
h (q, v) =
,
1 0
1 0
for all q, v, h and where 0h denotes the Jacobian of h .
For a method h , to be symmetric means that when we have computed an approximation yn , starting with initial condition y0 , if we apply the method h with
initial condition y0 = yn , after n steps we have that yn = y0 . Intuitively, this means
that if we reverse the time, we return where we started.
The reversibility is a very important, because in the case of the above system the flow
satisfies the same condition and in the case of physics equations this means that inverting the initial velocity does not change the trajectory, it just inverts the direction
of the motion.
The property of being symplectic is also very important, because it implies the preservation of the volume: if the flow of a first order system of differential equations is
symplectic, we have that, for a given x, vol (x (U)) = vol (U), for any open bounded
set U such that the flow is defined in U. Indeed, the fact to be symplectic implies
that |det 0h (q, v)| = 1, for all q, v and h, therefore
Z
Z
Z
0
vol (x (U)) =
dy =
|det h (q, v)| dy0 =
dy0 = vol(U).
x (U )

We can see this in the figure 3: the cats denotes a set of initial values; if a method is
symplectic the cats have always the same area.
Remark that the midpoint and the Euler methods havent any of these properties,
although they can have one or more of these properties in the case of a particular
system of differential equations.
We prove now that the Stormer-Verlet method satisfies the above conditions.
Theorem 2. The Stormer-Verlet method is symmetric.
9

Proof: We have h : (qn , vn ) 7 (qn+1 , vn+1 )



qn+1 = qn h vn h2 F (qn ) ,
vn+1 = vn h2 F (qn ) h2 F (qn+1 ).
Inverting n and n + 1 we get 1
h : (qn+1 , vn+1 ) 7 (qn , vn ), explicitly

qn = qn+1 h vn+1 h2 F (qn+1 ) ,
vn = vn+1 h2 F (qn+1 ) h2 F (qn ).
Finally

qn+1 = qn + h vn+1 h2 F (qn+1 )

= qn + h vn + h2 F (qn ) ,
vn+1 = vn + h2 F (qn ) + h2 F (qn+1 ),
hence h = 1
h and h is symmetric.

Theorem 3. The Stormer-Verlet method is reversible.
Proof: We have

h (q, v) = (
q , v) =





h
h
h
h
q + h v + F (q) , v + F (q) + F q + h v + F (q)
2
2
2
2


and so





h
h
h
h
h (
q ,
v ) = q + h
v + F (
q)
,
v + F (
q ) + F q + h
v + F (
q) .
2
2
2
2
|
{z
}
|
{z
}

We get


= q + h v + h2 F (q) + h v h2 F (q) h2 F (
q ) + h2 F (
q)
= q
and

= v h2 F (q) h2 F (
q ) + h2 F (
q )+
+

h
F
2


q + h v h2 F (q) h2 F (
q ) + h2 F (
q)



= v h2 F (q) + h2 F q + h v + h2 F (q) + h v h2 F (q)
= v.
This gives h (
q ,
v ) = (q, v), hence h is reversible.
10


Theorem 4. The Stormer-Verlet method is symplectic.
Proof: Write h in the following way:
h (q, v) = (1 (q, v), 2 (q, v)) .
The Jacobian 0h (q, v) is the matrix


q 1 (q, v) v 1 (q, v)
.
q 2 (q, v) v 2 (q, v)
We get
0h (q, v)T

0 1
1 0

0h (q, v)


=

0
q 1 v 2 v 1 q 2
(q 1 v 2 v 1 q 2 )
0


(q, v).

We have
h2 0
F (q),
2
h 0
F (q) + h2 F 0
2

q 1 (q, v) = 1 +

q 2 (q, v) =
v 1 (q, v) = h
v 2 (q, v) = 1 +

h2 0
F
2

 
1+
q + h v + h2 F (q)

h2 0
F (q)
2


q + h v + h2 F (q) .

This gives


2
2
1 + h2 F 0 (q) 1 + h2 F 0 q + h v + h2 F (q)





2
h h2 F 0 (q) + h2 F 0 q + h v + h2 F (q)
1 + h2 F 0 (q)

(q 1 v 2 v 1 q 2 )(q, v) =

2
4
h2 0
0
F (q) + h2 F 0 (q + .. .) + h4 F 0 (q)F
2
 (q
2
2
2
h
F 0 (q) h2 F 0 (q + . . .) 1 + h2 F 0 (q)
2

= 1+

+ . . .)

= 1
and therefore h is symplectic.


3.3

Examples

Let us look at two example: the Kepler problem and the aurora borealis.
The first example is very famous, known as Kepler problem because Johannes Kepler
(1571-1630) proposed a similar formula for the celestial orbits, i.e., the equations that
define the displacements of two celestial bodies that interact by a force. Explicitly
q1 =

q1
(q12 +

3/2
q22 )

, q2 =
11

q2
3/2

(q12 + q22 )

Figure 4: Kepler problem; dashed: exact solution.

with initial condition


r
q1 (0) = 1 e, q2 (0) = 0, q1 (0) = 0, q2 (0) =

1+e
1e

and e = 0.6. In a two-body problem, the exact solution (q1 , q2 ) describes the orbit
of a body with respect to the other body and has period 2. Figure 4 shows the
behavior of the Stormer-Verlet method with different step-size and different number
of steps compared to the explicit midpoint method presented above. We know that
the midpoint method has the same order of the Stormer-Verlet method, but the figure
shows us that the Stormer-Verlet method approximate pretty well the exact solution
in the two cases, instead the midpoint method deteriorates rapidly when the step-size
increases and in both cases is less accurate than the Stormer-Verlet method. We
remark the fact that the Kepler problem was the foundation of Newtons theory of
universal gravitation.
The second example is the original problem that Carl Stormer tried to solve numerically in 1907. Stormer tried to confirm numerically a previous conjecture, that says
that the phenomenon known as aurora borealis (figure 5) is produced by electrical
particles emanating from the sun and moving in the earths magnetic field. We are
not interested in all the detailed calculations, we hope to convince the reader that using the Stormer-Verlet method we obtain a solution that approaches the real behavior
of these particles as shown in the figure 6. This picture shows 125 solution curves in
the 3-dimensional space with neighboring initial values: this gives an impression of
how an aurora borealis comes into being.

12

Figure 5: 125 solution curves using the Stormer method.

Figure 6: The aurora borealis.

13

Contents
1 Ordinary differential equations

2 Runge-Kutta methods

2.1

The explicit Euler method . . . . . . . . . . . . . . . . . . . . . . . .

2.2

The explicit midpoint method . . . . . . . . . . . . . . . . . . . . . .

2.3

Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3 St
ormer-Verlet method

3.1

Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.2

Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3.3

Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11

References
Solving Ordinary Differential Equations Vol. I, E. Hairer, S.P. Nrsett, G. Wanner, Springer, 1993.
Geometric numerical integration illustrated by the St
ormer/Verlet method (Acta
Numerica (2003) pp. 1-51), E. Hairer, C. Lubich, G. Wanner, Cambridge University Press, 2003.

14

Potrebbero piacerti anche