Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Fr
uhjahrssemester 08
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.
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)
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.
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
i1
X
aij , 2 i s.
j=1
2.1
y(x + h) y(x)
,
h
2.2
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
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
3.2
Properties
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
Figure 3: On the right some non-symplectic methods. On the left the simplecticity
of the Stormer-Verlet method.
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
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 )
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
13
Contents
1 Ordinary differential equations
2 Runge-Kutta methods
2.1
2.2
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