You are on page 1of 59

Lecture notes

An introduction to Lagrangian and Hamiltonian mechanics


Simon J.A. Malham

Simon J.A. Malham (15th January 2015)


Maxwell Institute for Mathematical Sciences
and School of Mathematical and Computer Sciences
Heriot-Watt University, Edinburgh EH14 4AS, UK
Tel.: +44-131-4513200
Fax: +44-131-4513249
E-mail: S.J.Malham@hw.ac.uk

Simon J.A. Malham

1 Introduction
Newtonian mechanics took the Apollo astronauts to the moon. It also took the
voyager spacecraft to the far reaches of the solar system. However Newtonian
mechanics is a consequence of a more general scheme. One that brought us
quantum mechanics, and thus the digital age. Indeed it has pointed us beyond
that as well. The scheme is Lagrangian and Hamiltonian mechanics. Its original
prescription rested on two principles. First that we should try to express the
state of the mechanical system using the minimum representation possible
and which reflects the fact that the physics of the problem is coordinateinvariant. Second, a mechanical system tries to optimize its action from one
split second to the next; often this corresponds to optimizing its total energy as
it evolves from one state to the next. These notes are intended as an elementary
introduction into these ideas and the basic prescription of Lagrangian and
Hamiltonian mechanics. A pre-requisite is the thorough understanding of the
calculus of variations, which is where we begin.

2 Calculus of variations
Many physical problems involve the minimization (or maximization) of a quantity that is expressed as an integral.
Example 1 (Euclidean geodesic) Consider the path that gives the shortest
distance between two points in the plane, say (x1 , y1 ) and (x2 , y2 ). Suppose
that the general curve joining these two points is given by y = y(x). Then our
goal is to find the function y(x) that minimizes the arclength:
Z

(x2 ,y2 )

J(y) =
=

ds
(x1 ,y1 )
Z x2 p

1 + (yx )2 dx.

x1

Here we have used that for a curve y = y(x), if we make a small increment
in x, say x, and the corresponding change in y is y, then by Pythagoras
p theorem the corresponding change in length along the curve is s =
+ (x)2 + (y)2 . Hence we see that
s
x =
s =
x


1+

y
x

2
x.

Note further that here, and hereafter, we use yx = yx (x) to denote the derivative of y, i.e. yx (x) = y 0 (x) for each x for which the derivative is defined.

Lagrangian and Hamiltonian mechanics

(x1, y1)

y=y(x)

(x2, y2)

Fig. 1 In the Euclidean geodesic problem, the goal is to find the path with minimum total
length between points (x1 , y1 ) and (x2 , y2 ).
(x1, y1)

v
y=y(x)

mgk

(0,0)

Fig. 2 In the Brachistochrome problem, a bead can slide freely under gravity along the wire.
The goal is to find the shape of the wire that minimizes the time of descent of the bead.

Example 2 (Brachistochrome problem; John and James Bernoulli 1697)


Suppose a particle/bead is allowed to slide freely along a wire under gravity
(force F = gk where k is the unit upward vertical vector) from a point
(x1 , y1 ) to the origin (0, 0). Find the curve y = y(x) that minimizes the time
of descent:
Z

(0,0)

J(y) =
(x1 ,y1 )

=
x1

p
p

1
ds
v

1 + (yx )2

2g(y1 y)

dx.

Here we have used that the total energy, which is the sum of the kinetic and
potential energies,
E = 21 mv 2 + mgy,
is constant. Assume the initial condition is v = 0 when y = y1 , i.e. the bead
starts with zero velocity at the top end of the wire. Since its total energy is
constant, its energy at any time t later, when its height is y and its velocity is
v, is equal to its initial energy. Hence we have
2
1
2 mv

+ mgy = 0 + mgy1

p
v = + 2g(y1 y).

Simon J.A. Malham

3 EulerLagrange equation
We can see that the two examples above are special cases of a more general
problem scenario.
Problem 1 (Classical variational problem) Suppose the given function F is
twice continuously differentiable with respect to all of its arguments. Among
all functions/paths y = y(x), which are twice continuously differentiable on
the interval [a, b] with y(a) and y(b) specified, find the one which extremizes
the functional defined by
Z b
J(y) :=
F (x, y, yx ) dx.
a

Theorem 1 (EulerLagrange equation) The function u = u(x) that extremizes the functional J necessarily satisfies the EulerLagrange equation on [a, b]:


d F
F

= 0.
u
dx ux
Proof Consider the family of functions on [a, b] given by
y(x; ) := u(x) + (x),
where the functions = (x) are twice continuously differentiable and satisfy
(a) = (b) = 0. Here  is a small real parameter, and of course, the function
u = u(x) is our candidate extremizing function. We set (see for example
Evans [7, Section 3.3])
() := J(u + ).
If the functional J has a local maximum or minimum at u, then u is a stationary function for J, and for all we must have
0 (0) = 0.
To evaluate this condition for the functional given in integral form above, we
need to first determine 0 (). By direct calculation,
0 () =
=
=
=
=

d
J(u + )
d
Z
d b
F (x, u + , ux + x ) dx
d a
Z b

F (x, y(x; ), yx (x; )) dx


a 

Z b
F y
F yx
+
dx
y 
yx 
a

Z b
F
F 0
(x) +
(x) dx.
y
yx
a

Lagrangian and Hamiltonian mechanics

The integration by parts formula tells us that


Z
a


x=b Z b


F 0
F
d F
(x) dx =
(x)
(x) dx.

yx
yx
a dx yx
x=a

Recall that (a) = (b) = 0, so the boundary term (first term on the right)
vanishes in this last formula, and we see that
0 () =

Z b
a



d F
F

(x) dx.
y
dx yx

If we now set  = 0, the condition for u to be a critical point of J is


Z b
a



F
d F

(x) dx = 0.
u
dx ux

Now we note that the functions = (x) are arbitrary, using Lemma 1 below,
we can deduce that pointwise, i.e. for all x [a, b], necessarily u must satisfy
the EulerLagrange equation shown.
t
u
Lemma 1 (Useful lemma) If (x) is continuous in [a, b] and
Z

(x) (x) dx = 0
a

for all continuously differentiable functions (x) which satisfy (a) = (b) = 0,
then (x) 0 in [a, b].
Proof Assume (z) > 0, say, at some point a < z < b. Then since is
continuous, we must have that (x) > 0 in some open neighbourhood of z,
say in a < z < z < z < b. The choice
(
(x) =

(x z)2 (z x)2 ,
0,

for x [z, z],


otherwise,

which is a continuously differentiable function, implies


Z

Z
(x) (x) dx =

a contradiction.

(x) (x z)2 (z x)2 dx > 0,

t
u

Simon J.A. Malham

3.1 Remarks
Some important theoretical and practical points to keep in mind are as follows.
1. The EulerLagrange equation is a necessary condition: if such a u = u(x)
exists that extremizes J, then u satisfies the EulerLagrange equation.
Such a u is known as a stationary function of the functional J.
2. The EulerLagrange equation above is an ordinary differential equation for
u; this will be clearer once we consider some examples presently.
3. Note that the extremal solution u is independent of the coordinate system
you choose to represent it (see Arnold [3, Page 59]). For example, in the
Euclidean geodesic problem, we could have used polar coordinates (r, ),
instead of Cartesian coordinates (x, y), to express the total arclength J.
Formulating the EulerLagrange equations in these coordinates and then
solving them will tell us that the extremizing solution is a straight line
(only it will be expressed in polar coordinates).
4. Let Y denote a function space; in the context above Y was the space of
twice continuously differentiable functions on [a, b] which are fixed at x = a
and x = b. A functional is a real-valued map and here J : Y R.
5. We define the first variation J(u, ) of the functional J, at u in the direction , to be J(u, ) := 0 (0).
6. Is u a maximum, minimum or saddle point for J? The physical context
should hint towards what to expect. Higher order variations will give you
the appropriate mathematical determination.
7. The functional J has a local minimum at u iff there is an open neighbourhood U Y of u such that J(y) J(u) for all y U . The functional J
has a local maximum at u when this inequality is reversed.
8. We generalize all these notions to multidimensions and systems presently.

Solution 1 (Euclidean geodesic) Recall, this variational problem concerns


finding the shortest distance between the two points (x1 , y1 ) and (x2 , y2 ) in
the plane. This is equivalent to minimizing the total arclength functional

x2

J(y) =

p
1 + (yx )2 dx.

x1

p
Hence in this case, the integrand is F (x, y, yx ) = 1 + (yx )2 . From the general
theory outlined above, we know that the extremizing solution satisfies the
EulerLagrange equation



F
d F

= 0.
y
dx yx

Lagrangian and Hamiltonian mechanics

We substitute the actual form for F we have in this case which gives


1 
d


=0
1 + (yx )2 2
dx yx
!
d
yx
=0

dx 1 + (y )2  21
x

(yx )2 yxx

1
3 = 0
1 + (yx )2 2
1 + (yx )2 2

1 + (yx )2 yxx
(yx )2 yxx
 32
3 = 0
1 + (yx )2
1 + (yx )2 2
yxx
3 = 0
1 + (yx )2 2
yxx

yxx = 0.

Hence y(x) = c1 + c2 x for some constants c1 and c2 . Using the initial and
starting point data we see that the solution is the straight line function (as we
should expect)


y2 y1
(x x1 ) + y1 .
y=
x2 x1
Note that this calculation might have been a bit shorter if we had recognised
that this example corresponds to the third special case in the next section.
4 Alternative form and special cases
Lemma 2 (Alternative form) The EulerLagrange equation given by


F
d F

=0
y
dx yx
is equivalent to the equation


F
d
F

F yx
= 0.
x
dx
yx
Proof See the Exercises Section 19 at the end of these notes.

t
u

Corollary 1 (Special cases) When the functional F does not explicitly depend
on one or more variables, then the EulerLagrange equations simplify considerably. We have the following three notable cases:
1. If F = F (y, yx ) only, i.e. it does not explicitly depend on x, then the
alternative form for the EulerLagrange equation implies


d
F
F
F yx
=0

F yx
= c,
dx
yx
yx
for some arbitrary constant c.

Simon J.A. Malham

2. If F = F (x, yx ) only, i.e. it does not explicitly depend on y, then the


EulerLagrange equation implies


d F
F
=0

= c,
dx yx
yx
for some arbitrary constant c.
3. If F = F (yx ) only, then the EulerLagrange equation implies


F
d F
0=

y
dx yx
 2

F
F
2F
2F
=

+ yx
+ yxx
y
xyx
yyx
yx yx
2F
= yxx
.
yx yx
Hence yxx = 0, i.e. y = y(x) is a linear function of x and has the form
y = c1 + c2 x,
for some constants c1 and c2 .
Solution 2 (Brachistochrome problem) Recall, this variational problem concerns a particle/bead which can freely slide along a wire under the force of
gravity. The wire is represented by a curve y = y(x) from (x1 , y1 ) to the origin
(0, 0). The goal is to find the shape of the wire, i.e. y = y(x), which minimizes
the time of descent of the bead, which is given by the functional
Z 0s
Z 0s
1 + (yx )2
1
1 + (yx )2
J(y) =
dx =
dx.
2g(y1 y)
(y1 y)
2g x1
x1
Hence in this case, the integrand is
s
F (x, y, yx ) =

1 + (yx )2
.
(y1 y)

From the general theory, we know that the extremizing solution satisfiesthe
EulerLagrange equation. Note that the multiplicative constant factor 1/ 2g
should not affect the extremizing solution path; indeed it divides out of the
EulerLagrange equations. Noting that the integrand F does not explicitly
depend on x, then the alternative form for the EulerLagrange equation may
be easier:


F
d
F

F yx
= 0.
x
dx
yx
This implies that for some constant c, the EulerLagrange equation is
F yx

F
= c.
yx

Lagrangian and Hamiltonian mechanics

Now substituting the form for F into this gives


1 + (yx )2

 12

(y1 y) 2
1
1 + (yx )2 2

(y1 y)

1 + (yx )2

(y1 y)
1 + (yx )2

(y1 y) 2 1 + (yx )2

(y1 y)

(y1 y)

1
2

1 + (yx )2

(yx )2

 12

2 yx
1
2

 21

1
2

 21 !

(y1 y) 2
1
2

yx

1
2

1 + (yx )2

yx
yx

1 + (yx )2

=c

 21 = c
 21 = c

(yx )2

1 = c
1
(y1 y) 2 1 + (yx )2 2
1
 = c2 .
(y1 y) 1 + (yx )2

We can now rearrange this equation so that


(yx )2 =

1
c2 (y1

y)

If we set a = y1 and b =

1
c2

(yx )2 =

1 c2 y1 c2 y
.
c2 y1 c2 y

y1 , then this equation becomes



yx =

b+y
ay

 12
.

To find the solution to this ordinary differential equation we make the change
of variable
y = 21 (a b) 12 (a + b) cos .
If we substitute this into the ordinary differential equation above and use the
chain rule we get

1
d
1 cos 2
1
.
2 (a + b) sin dx =
1 + cos

Now we use that 1/(d/dx) = dx/d, and that sin = 1 cos2 , to get
1
1 + cos 2
1 cos

1
1
dx
1 + cos 2
2
1
2
= 2 (a + b) (1 cos )
d
1 cos
1

1
1
dx
1 + cos 2
1
2
2
= 2 (a + b) (1 + cos ) (1 cos )
d
1 cos
dx
= 12 (a + b)(1 + cos ).
d

dx
= 12 (a + b) sin
d

10

Simon J.A. Malham

We can directly integrate this last equation to find x as a function of . In


other words we can find the solution to the ordinary differential equation for
y = y(x) above in parametric form, which with some minor rearrangement,
can expressed as (here d is an arbitrary constant of integration)
x + d = 12 (a + b)( + sin ),
y + b = 12 (a + b)(1 cos ).
This is the parametric representation of a cycloid.

5 Multivariable systems
We consider possible generalizations of functionals to be extremized. For more
details see for example Keener [9, Chapter 5].
Problem 2 (Higher derivatives) Suppose we are asked to find the curve y =
y(x) R that extremizes the functional
Z b
:=
J(y)
F (x, y, yx , yxx ) dx,
a

subject to y(a), y(b), yx (a) and yx (b) being fixed. Here the functional quantity
to be extremized depends on the curvature yxx of the path. Necessarily the extremizing curve y satisfies the EulerLagrange equation (which is an ordinary
differential equation)




d F
F
d2
F

+ 2
= 0.
y
dx yx
dx yxx
Note this follows by analogous arguments to those used for the classical variational problem above.
Question 1 Can you guess what the correct form for the EulerLagrange equation should be if F = F (x, y, yx , yxx , yxxx ) and so forth?
Problem 3 (Multiple dependent variables) Suppose we are asked to find the
multidimensional curve y = y(x) RN that extremizes the functional
Z b
J(y) :=
F (x, y, y x ) dx,
a

subject to y(a) and y(b) being fixed. Note x [a, b] but here y = y(x) is a
curve in N -dimensional space and is thus a vector so that (here we use the
notation 0 d/dx)

0
y1
y1
..
..
and
yx = . .
y= .
yN

0
yN

Lagrangian and Hamiltonian mechanics

11

Necessarily the extremizing curve y satisfies a set of EulerLagrange equations,


which are equivalent to a system of ordinary differential equations, given for
i = 1, . . . , N by:


F
d F
= 0.

yi
dx yi0
Problem 4 (Multiple independent variables) Suppose we are asked to find
the field y = y(x) that, for x Rn , extremizes the functional
Z
F (x, y, y) dx,

J(y) :=

subject to y being fixed at the boundary of the domain . Note here


y x y is simply the gradient of y, i.e. it is the vector of partial derivatives
of y with respect to each of the components xi (i = 1, . . . , n) of x:

y/x1

..
y =
.
.
y/xn
Necessarily y satisfies an EulerLagrange equation which is a partial differential equation given by

F
yx F = 0.
y
Here x is the usual divergence gradient operator with respect to
x, and

F/yx1

..
yx F =
,
.
F/yxn
where to keep the formula readable, with y the usual gradient of y, we have
set yx y so that yxi = (y)i = y/xi for i = 1, . . . , n.
Example 3 (Laplaces equation) The variational problem here is to find the
field = (x1 , x2 , x3 ), for x = (x1 , x2 , x3 )T R3 , that extremizes the
mean-square gradient average
Z
J() :=

||2 dx.

In this case the integrand of the functional J is


F (x, , ) = ||2 (x1 )2 + (x2 )2 + (x3 )2 .

12

Simon J.A. Malham

Note that the integrand F depends on the partial derivatives of only. Using
the form for the EulerLagrange equation above we get

x x F = 0

/x1
F/x1
/x2 F/x2 = 0

/x3
F/x3




2x1 +
2x2 +
2x3 = 0

x1
x2
x3

x1 x1 + x2 x2 + x3 x3 = 0
2 = 0.

This is Laplaces equation for in the domain ; the solutions are called
harmonic functions. Note that implicit in writing down the EulerLagrange
partial differential equation above, we assumed that was fixed at the boundary , i.e. Dirichlet boundary conditions were specified.
Example 4 (Stretched vibrating string) Suppose a string is tied between the
two fixed points x = 0 and x = `. Let y = y(x, t) be the small displacement of
the string at position x [0, `] and time t > 0 from the equilibrium position
y = 0. If is the uniform mass per unit length of the string which is stretched
to a tension K, the kinetic and potential energy of the string are given by
T := 12

yt2 dx,

Z
V := K

and

1 + (yx )2

1/2


dx `

respectively, where subscripts indicate partial derivatives and the effect of


gravity is neglected. If the oscillations of the string are quite small, we can
1/2
replace the expression for V , using the binomial expansion 1 + (yx )2

1 + (yx )2 , by
Z
K ` 2
V =
y dx.
2 0 x
We seek a solution y = y(x, t) that extremizes the functional (this is the action
functional as we see later)
Z

t2

(T V ) dt,

J(y) :=
t1

where t1 and t2 are two arbitrary times. In this case, with


 


x
y/x
x=
and
y =
t
y/t
the integrand is
F (x, y, y) 12 (yt )2 12 K(yx )2 ,

Lagrangian and Hamiltonian mechanics

13

i.e. F = F (y) only. The EulerLagrange equation is thus



x yx F = 0

 

/x
F/yx

=0
/t
F/yt



Kyx
yt = 0
x
t
c2 yxx ytt = 0,

where c2 = K/. This is the partial differential equation ytt = c2 yxx known
as the wave equation. It admits travelling wave solutions of speed c.

6 Lagrange multipliers
For the moment, let us temporarily put aside variational calculus and consider
a problem in standard multivariable calculus.
Problem 5 (Constrained optimization problem) Find the stationary points
of the scalar function f (x) where x = (x1 , . . . , xN )T subject to the constraints
gk (x) = 0, where k = 1, . . . , m, with m < N .
Note that the graph y = f (x) of the function f represents a hyper-surface
in (N + 1)-dimensional space. The constraints are given implicitly; each one
also represents a hyper-surface in (N + 1)-dimensional space. In principle we
could solve the system of m constraint equations, say for x1 , . . . , xm in terms
of the remaining variables xm+1 , . . . , xN . We could then substitute these into
f , which would now be a function of (xm+1 , . . . , xN ) only. (We could solve
the constraints for any subset of m variables xi and substitute those in if we
wished or this was easier, or avoided singularities, and so forth.) We would then
proceed in the usual way to find the stationary points of f by considering the
partial derivative of f with respect to all the remaining variables xm+1 , . . . , xN ,
setting those partial derivatives equal to zero, and then solving that system
of equations. However solving the constraint equations may be very difficult,
and the method of Lagrange multipliers provides an elegant alternative (see
McCallum et. al. [14, Section 14.3]).
The idea of the method of Lagrange multipliers is to convert the constrained optimization problem to an unconstrained one as follows. Form the
Lagrangian function
L(x, ) := f (x) +

m
X

k gk (x),

k=1

where the parameter variables = (1 , . . . , m )T are known as the Lagrange


multipliers. Note L is a function of both x and , i.e. of N + m variables. The

14

Simon J.A. Malham

f
v

g
(x* , y*)

f=5
g=0

f=4
v
f=3

g
f=2

f=1
Fig. 3 At the constrained extremum f and g are parallel. (This is a rough reproduction
of the figure on page 199 of McCallum et. al. [14])

partial derivatives of L with respect to all of its dependent variables are:


m

X
L
f
gk
=
+
k
,
xj
xj
xj
k=1

L
= gk ,
k
where j = 1, . . . , N and k = 1, . . . , m. At the stationary points of L(x, ),
necessarily all these partial derivatives must be zero, and we must solve the
following unconstrained problem:
m

X
gk
f
k
+
= 0,
xj
xj
k=1

gk = 0,
where j = 1, . . . , N and k = 1, . . . , m. Note we have N +m equations in N +m
unknowns. Assuming that we can solve this system to find a stationary point
(x , ) of L (there could be none, one, or more) then x is also a stationary
point of the original constrained problem. Recall: what is important about the
formulation of the Lagrangian function L we introduced above, is that the
given constraints mean that (on the constraint manifold) we have L = f + 0
and therefore the stationary points of f and L coincide.
Remark 1 (Geometric intuition) Suppose we wish to extremize (find a local
maximum or minimum) the objective function f (x, y) subject to the constraint
g(x, y) = 0. We can think of this as follows. The graph z = f (x, y) represents
a surface in three dimensional (x, y, z) space, while the constraint represents
a curve in the x-y plane to which our movements are restricted.

Lagrangian and Hamiltonian mechanics

15

Constrained extrema occur at points where the contours of f are tangent


to the contours of g (and can also occur at the endpoints of the constraint).
This can be seen as follows. At any point (x, y) in the plane f points in
the direction of maximum increase of f and thus perpendicular to the level
contours of f . Suppose that the vector v is tangent to the constraining curve
g(x, y) = 0. If the directional derivative fv = f v is positive at some point,
then moving in the direction of v means that f increases (if the directional
derivative is negative then f decreases in that direction). Thus at the point
(x , y ) where f has a constrained extremum we must have f v = 0 and
so both f and g are perpendicular to v and therefore parallel. Hence for
some scalar parameter (the Lagrange multiplier) we have at the constrained
extremum:
f = g
and
g = 0.
Notice that here we have three equations in three unknowns x, y, .

7 Constrained variational problems


A common optimization problem is to extremize a functional J with respect
to paths y which are constrained in some way. We consider the following
formulation.
Problem 6 (Constrained variational problem) Find the extrema of the functional
Z b
J(y) :=
F (x, y, y x ) dx,
a

where y = (y1 , . . . , yN ) R
1, . . . , m < N :
T

subject to the set of m constraints, for k =


Gk (x, y) = 0.

To solve this constrained variational problem we generalize the method of


Lagrange multipliers as follows. Note that the m constraint equations above
imply
Z b
k (x) Gk (x, y) dx = 0,
a

for each k = 1, . . . , m. Note that the k s are the Lagrange multipliers, which
with the constraints expressed in this integral form, can in general be functions
of x. We now form the equivalent of the Lagrangian function which here is the
functional
Z b
m Z b
X
) :=
J(y,
F (x, y, y x ) dx +
k (x) Gk (x, y) dx
a

) =
J(y,

k=1

Z b
F (x, y, y x ) +
a

m
X
k=1


k (x) Gk (x, y) dx.

16

Simon J.A. Malham

The integrand of this functional is


F (x, y, y x , ) := F (x, y, y x ) +

m
X

k (x) Gk (x, y),

k=1

where = (1 , . . . , m )T . We know from the classical variational problem that


if (y, ) extremize J then necessarily they must satisfy the EulerLagrange
equations:


F
d F
= 0,

yi
dx yi0


F
d F

= 0,
k
dx 0k
which simplify to


d F
F

= 0,
yi
dx yi0
Gk (x, y) = 0,
for i = 1, . . . , N and k = 1, . . . , m. This is a system of differential-algebraic
equations: the first set of relations are ordinary differential equations, while
the constraints are algebraic relations.
Remark 2 (Integral constraints) If the constraints are (already) in integral
form so that we have
Z b
Gk (x, y) dx = 0,
a

for k = 1, . . . , m, then set


) := J(y) +
J(y,

m
X
k=1

Z
k

Gk (x, y) dx
a

Z b
=

F (x, y, y x ) +
a

m
X


k Gk (x, y) dx.

k=1

Note we now have a variational problem with respect to the curve y = y(x)
but the constraints are classical in the sense that the Lagrangian multipliers
here are simply variables. Proceeding as above, with this hybrid variational
constraint problem, we generate the EulerLagrange equations as above, together with the integral constraint equations.
Example 5 (Didos/isoperimetrical problem) The goal of this classical constrained variational problem is to find the shape of the closed curve, of a
given fixed length `, that encloses the maximum possible area. Suppose that

Lagrangian and Hamiltonian mechanics

17

c:

(x,y)=(x(t),y(t))

Fig. 4 For the isoperimetrical problem, the closed curve C has a fixed length `, and the goal
is to choose the shape that maximizes the area it encloses.


the curve is given in parametric coordinates x( ), y( ) where the parameter
[0, 2]. By Stokes theorem, the area enclosed by a closed contour C is
I
1
x dy y dx.
2
C

Hence our goal is to extremize the functional


Z 2
1
:=
(xy y x)
d,
J(x, y)
2
0

subject to the constraint


Z

p
x 2 + y 2 d = `.

Note that the constraint can be expressed in standard integral form as follows.
Since ` is fixed we have
Z
2

1
2 ` d

= `.

Hence the constraint can be expressed in the form


Z 2 p
1
x 2 + y 2 2
` d = 0.
0

To solve this variational constraint problem we use the method of Lagrange


multipliers and form the functional
Z 2 p

1
y, ) := J(x, y) +
J(x,
x 2 + y 2 2
` d .
0

Substituting in the form for J = J(x, y) above we find we can write


Z 2
y, ) =
J(x,
F (x, y, x,
y,
) d,
0

where the integrand F is given by


1
1
+ (x 2 + y 2 ) 2 2
`.
F (x, y, x,
y,
) = 21 (xy y x)

18

Simon J.A. Malham

Note there are two dependent variables x and y (here the parameter is the
independent variable). By the theory above we know that the extremizing
solution (x, y) necessarily satisfies an EulerLagrange system of equations,
which are the pair of ordinary differential equations


F
d F

= 0,
x
d x


F
d F

= 0,
y
d y
together with the integral constraint condition. Substituting the form for F
above, the pair of ordinary differential equations are


d
x
1
1
= 0,
1
2 y d 2 y +
(x 2 + y 2 ) 2


d 1
y
12 x
x
+
= 0.
1
d 2
(x 2 + y 2 ) 2
Integrating both these equations with respect to we get
y

x
(x 2

1
y 2 ) 2

= c2

and

y
(x 2

+ y 2 ) 2

= c1 ,

for arbitrary constants c1 and c2 . Combining these last two equations reveals
(x c1 )2 + (y c2 )2 =

2 y 2
2 x 2
+ 2
= 2 .
2
+ y
x + y 2

x 2

Hence the solution curve is given by


(x c1 )2 + (y c2 )2 = 2 ,
which is the equation for a circle with radius and centre (c1 , c2 ). The constraint condition implies = `/2 and c1 and c2 can be determined from the
initial or end points of the closed contour/path.
Remark 3 The isoperimetrical problem has quite a history. It was formulated in Virgils poem the Aeneid, one account of the beginnings of Rome;
see Wikipedia [18] or Montgomery [16]. Quoting from Wikipedia (Dido was
also known as Elissa):
Eventually Elissa and her followers arrived on the coast of North Africa
where Elissa asked the local inhabitants for a small bit of land for a
temporary refuge until she could continue her journeying, only as much
land as could be encompassed by an oxhide. They agreed. Elissa cut
the oxhide into fine strips so that she had enough to encircle an entire
nearby hill, which was therefore afterwards named Byrsa hide. (This
event is commemorated in modern mathematics: The isoperimetric
problem of enclosing the maximum area within a fixed boundary is
often called the Dido Problem in modern calculus of variations.)

Lagrangian and Hamiltonian mechanics

19

Dido found the solutionin her case a half-circleand the semi-circular city
of Carthage was founded.
Example 6 (Helmholtzs equation) This is a constrained variational version
of the problem that generated the Laplace equation. The goal is to find the
field = (x) that extremizes the functional
Z
J() :=
||2 dx,

subject to the constraint


Z

2 dx = 1.

This constraint corresponds to saying that the total energy is bounded and
in fact renormalized to unity. We assume zero boundary conditions, (x) = 0
for x Rn . Using the method of Lagrange multipliers (for integral
constraints) we form the functional
Z

Z
2
2

J(, ) :=
|| dx +
dx 1 .

We can re-write this in the form




Z
1
2
2

dx,
J(, ) =
|| +
||

where || is the volume of the domain . Hence the integrand in this case is


1
F (x, , , ) := ||2 + 2
.
||
The extremzing solution satisfies the EulerLagrange partial differential equation

F
x F = 0,

together with the constraint equation. Note, directly computing, we have


x F = 2

and

F
= 2.

Substituting these two results into the EulerLagrange partial differential


equation we find
2 (2) = 0

2 = .

This is Helmholtzs equation on . The Lagrange multiplier also represents


an eigenvalue parameter.

20

Simon J.A. Malham

8 Optimal linear-quadratic control


We can use calculus of variations techniques to derive the solution to an important problem in control theory. Suppose that a system state at any time
t > 0 is recorded in the vector q = q(t). Suppose further that the state evolves
according to a linear system of differential equations and we can control the
system via a set of inputs or controls u = u(t), i.e. the system evolution is
dq
= Aq + Bu.
dt
Here A is a matrix, which for convenience we will assume is constant, and
B = B(t) is another matrix mediating the controls.
Problem 7 (Optimal control problem) Starting in the state q(0) = q 0 , bring
this initial state to a final state q(T ) at time t = T > 0, as expediently as
possible.
There are many criteria as to what constitutes expediency. Here we will
measure the cost on the system of our actions over [0, T ] by the quadratic
utility
Z T
J(u) :=
q T (t)C(t)q(t) + uT (t)D(t)u(t) dt + q T (T )Eq(T ).
0

Here C = C(t), D = D(t) and E are non-negative definite symmetric matrices.


The final term represents a final state achievement cost. Note that we can in
principle solve the system of linear differential equations above for the state
q = q(t) in terms of the control u = u(t) so that J = J(u) is a functional of
u only (we see this presently).
Thus our goal is to find the control u = u (t) that minimizes the cost
J = J(u) whilst respecting the constraint which is the linear evolution of
the system state. We proceed as before. Suppose u = u (t) exists. Consider
perturbations to u on [0, T ] of the form
u = u + 
u.
Changing the control/input changes the state q = q(t) of the system so that
q = q + 
q.
where we suppose here q = q (t) to be the system evolution corresponding
to the optimal control u = u (t). Note that linear system perturbations 
q
are linear in . Substituting these last two perturbation expressions into the
differential system for the state evolution we find
d
q
,
= A
q + Bu
dt
where we have used that (d/dt)q = Aq + Bu . The initial condition is
(0) = 0. We can solve this system of differential equations for q
in terms of u

Lagrangian and Hamiltonian mechanics

21

by the variation of constants formula (using an integrating factor) as follows.


Since the matrix A is constant we observe

d
exp(At)
q (t) = exp(At)B(t)
u(t)
dt
Z t
exp(At)
q (t) =
exp(As)B(s)
u(s) ds
0
Z t

(t) =
q
exp A(t s) B(s)
u(s) ds.

By the calculus of variations, if we set


() := J(u + 
u),
,
then if the functional J has a minimum we have, for all u
0 (0) = 0.
(t) in terms of u
into J(u +
Note that we can substitute our expression for q

u). Since u = u + 
u and q = q + 
q are linear in  and the functional
J = J(u) is quadratic in u and q, then J(u + 
u) must be quadratic in  so
that
() = 0 + 1 + 2 2 ,
for some functionals 0 = 0 (
u), 1 = 1 (
u) and 2 = 2 (
u) independent of
. Since 0 () = 1 + 22 , we see 0 (0) = 1 . This term in () = J(u + 
u)
by direct computation is thus
T

T (t)C(t)q (t) + u
T (t)D(t)u (t) dt + 2
q
q T (T )Eq (T ),

(0) = 2
0

where we used that C, D and E are symmetric. We now substitute our ex in terms of u
above into this formula for 0 (0), this gives
pression for q
1 0
2 (0)
T

(t)C(t)q (t) dt +
q

=
0

=
0

Z
+

Z t
T

T (s)D(s)u (s) ds dt
u(s) C(t)q (t) + u
exp A(t s) B(s)
0
T

T

exp A(T s) B(s)
u(s) ds E q (T )

0
T Z T

Z
=

T (s)D(s)u (s) ds + q
T (T )E q (T )
u

0
T

Z
+
0

s
T

T

T (s)D(s)u (s) dt ds
exp A(t s) B(s)
u(s) C(t)q (t) + u

T

exp A(T s) B(s)
u(s) ds E q (T ),

22

Simon J.A. Malham

where we have swapped the order of integration in the first term. Now we use
the transpose of the product of two matrices is the product of their transposes
in reverse order to get
1 0
2 (0)

T


T (s)D(s)u (s)
exp AT (t s) C(t)q (t) dt + u
s
0


T
T
T

+ u(s) B (s) exp A (T s) E q (T ) ds


T (s)B T (s)
u

T (s)B T (s)p(s) + u
T (s)D(s)u (s) ds,
u

where for all s [0, T ] we set


Z
p(s) :=



exp AT (t s) C(t)q (t) dt + exp AT (T s) Eq (T ).

We see the condition for a minimum, 0 (0) = 0, is equivalent to


Z


T (s) B T (s)p(s) + D(s)u (s) ds = 0,
u

. Hence a necessary condition for the minimum is that for all t [0, T ]
for all u
we have
u (t) = D1 (t)B T (t)p(t).
Note that p depends solely on the optimal state q . To elucidate this relationship further, note by definition p(T ) = Eq (T ) and differentiating p with
respect to t we find
dp
= Cq AT p.
dt
Using the expression for the optimal control u in terms of p(t) we derived,
we see that q and p satisfy the system of differential equations
d
dt

  
 
q
A BD1 (t)B T
q
=
.
p
C(t)
AT
p

Define S = S(t) to be the map S : q 7 p, i.e. so that p(t) = S(t)q (t). Then
u (t) = D1 (t)B T (t)S(t)q (t),
and S(t) we see characterizes the optimal current state feedback control, it
tells how to choose the current optimal control u (t) in terms of the current
state q (t). Finally we observe that since p(t) = S(t)q (t), we have
dp
dS
dq
=
q + S .
dt
dt
dt

Lagrangian and Hamiltonian mechanics

23

Thus we see that


dS
dp
dq
q =
S
dt
dt
dt
= (Cq AT Sq ) S(Aq BD1 AT Sq ).
Hence S = S(t) satisfies the Riccati equation

dS
= C AT S SA S BD1 AT S.
dt
Remark 4 We can easily generalize the argument above to the case when the
coefficient matrix A = A(t) is not constant. This is achieved by carefully
replacing the flow map exp A(t s) for the linear constant coefficient system
(d/dt)
q = A
q , by the flow map for the corresponding linear nonautonomous
system with A = A(t), and carrying that through the rest of the computation.

9 Dynamics: Holonomic constraints and degrees of freedom


Consider a system of N particles in three dimensional space, each with position
vector r i (t) for i = 1, . . . , N . Note that each r i (t) R3 is a 3-vector. We thus
need 3N coordinates to specify the system, this is the configuration space.
Newtons 2nd law tells us that the equation of motion for the ith particle is
p i = F ext
+ F con
i
i ,
for i = 1, . . . , N . Here pi = mi v i is the linear momentum of the ith particle
and v i = r i is its velocity. We decompose the total force on the ith particle
into an external force F ext
and a constraint force F con
i
i . By external forces we
imagine forces due to gravitational attraction or an electro-magnetic field, and
so forth.
By a constraint on a particles we imagine that the particles motion is
limited in some rigid way. For example the particle/bead may be constrained
to move along a wire or its motion is constrained to a given surface. If the
system of N particles constitute a rigid body, then the distances between all
the particles are rigidly fixed and we have the constraint
|r i (t) r j (t)| = cij ,
for some constants cij , for all i, j = 1, . . . , N . All of these are examples of
holonomic constraints.
Definition 1 (Holonomic constraints) For a system of particles with positions
given by r i (t) for i = 1, . . . , N , constraints that can be expressed in the form
g(r 1 , . . . , r N , t) = 0,
are said to be holonomic. Note they only involve the configuration coordinates.

24

Simon J.A. Malham

We will only consider systems for which the constraints are holonomic.
Systems with constraints that are non-holonomic are: gas molecules in a container (the constraint is only expressible as an inequality); or a sphere rolling
on a rough surface without slipping (the constraint condition is one of matched
velocities).
Let us suppose that for the N particles there are m holonomic constraints
given by
gk (r 1 , . . . , r N , t) = 0,
for k = 1, . . . , m. The positions r i (t) of all N particles are determined by
3N coordinates. However due to the constraints, the positions r i (t) are not all
independent. In principle, we can use the m holonomic constraints to eliminate
m of the 3N coordinates and we would be left with 3N m independent
coordinates, i.e. the dimension of the configuration space is actually 3N m.
Definition 2 (Degrees of freedom) The dimension of the configuration space
is called the number of degrees of freedom, see Arnold [3, Page 76].
Thus we can transform from the old coordinates r 1 , . . . , r N to new generalized coordinates q1 , . . . , qn where n = 3N m:
r 1 = r 1 (q1 , . . . , qn , t),
..
.
r N = r N (q1 , . . . , qn , t).
10 DAlemberts principle
We will restrict ourselves to systems for which the net work of the constraint
forces is zero, i.e. we suppose
N
X

F con
dr i = 0,
i

i=1

for every small change dr i of the configuration of the system (for t fixed). If
we combine this with Newtons 2nd law from the last section we get obtain
DAlemberts principle:
N
X
(p i F ext
i ) dr i = 0.
i=1

In particular, no forces of constraint are present.


Remark 5 The assumption that the constraint force does no net work is quite
general. It is true in particular for holonomic constraints. For example, for
the case of a rigid body, the internal forces of constraint do no work as the
distances |r i r j | between particles is fixed, then d(r i r j ) is perpendicular

Lagrangian and Hamiltonian mechanics

25

to r i r j and hence perpendicular to the force between them which is parallel


to r i r j . Similarly for the case of the bead on a wire or particle constrained
to move on a surfacethe normal reaction forces are perpendicular to dr i .
In his Mecanique Analytique [1788], Lagrange sought a coordinate invariant expression for mass times acceleration, see Marsden and Ratiu [15,
Page 231]. This lead to Lagranges equations of motion. Consider the transformation to generalized coordinates
r i = r i (q1 , . . . , qn , t),
for i = 1, . . . , N . If we consider a small increment in the displacements dr i
then the corresponding increment in the work done by the external forces is
N
X
i=1

F ext
dr i =
i

N,n
X

F ext

i,j=1

X
r i
dqj =
Qj dqj .
qj
j=1

Here we have set for j = 1, . . . , n,


Qj =

N
X

F ext

i=1

r i
,
qj

and think of these as generalized forces. We now assume the work done by
these forces depends on the initial and final configurations only and not on
the path between them. In other words we assume there exists a potential
function V = V (q1 , . . . , qn ) such that
Qj =

V
qj

for j = 1, . . . , n. Such forces are said to be conservative. We define the total


kinetic energy to be
N
X
2
1
T :=
2 mi |v i | ,
i=1

and the Lagrange function or Lagrangian to be


L := T V.
Theorem 2 (Lagranges equations) DAlemberts principle is equivalent to
the system of ordinary differential equations


d L
L

= 0,
dt qj
qj
for j = 1, . . . , n. These are known as Lagranges equations of motion.

26

Simon J.A. Malham

Proof The change in kinetic energy mediated through the momentumthe


first term in DAlemberts principledue to the increment in the displacements dr i is given by
N
X

p i dr i =

i=1

N
X

mi v i dr i =

i=1

N,n
X
i,j=1

From the product rule we know that




r i
r i
d
vi
v i
+ vi
dt
qj
qj
r i
v i
+ vi
qj

mi v i

r i
dqj .
qj



d r i
dt qj
v i
.
qj

Also, by differentiating the transformation to generalized coordinates we see


vi

n
X
r i
j=1

qj

qj

and

v i
r i

.
qj
qj

Using these last two identities we see that


!
n
N
N
X
X
X
r i
mi v i
p i dr i =
dqj
qj
j=1 i=1
i=1


!
n
N 
X
X
d
r i
v i
=
mi v i
mi v i
dqj
dt
qj
qj
j=1 i=1


!
n
N 
X
X
d
v i
v i
mi v i
=
mi v i
dqj
dt
qj
qj
j=1 i=1
=

n
X
j=1


N

X
!
N
X1

d
1
mi |v i |2

mi |v i |2
dqj .
dt qj i=1 2
qj i=1 2

Hence we see that DAlemberts principle is equivalent to


!


n
X
d T
T

Qj dqj = 0.
dt qj
qj
j=1
Since the qj for j = 1, . . . , n, where n = 3N m, are all independent, we have


d T
T

Qj = 0,
dt qj
qj
for j = 1, . . . , n. Using the definition for the generalized forces Qj in terms of
the potential function V gives the result.
t
u

Lagrangian and Hamiltonian mechanics

27

Remark 6 (Configuration space) As already noted, the n-dimensional subsurface of 3N -dimensional space on which the solutions to Lagranges equations lie is called the configuration space. It is parameterized by the n generalized coordinates q1 , . . . , qn .
Remark 7 (Non-conservative forces) If the system has forces that are not
conservative it may still be possible to find a generalized potential function V
such that


V
d V
Qj =
+
,
qj
dt qj
for j = 1, . . . , n. From such potentials we can still deduce Lagranges equations
of motion. Examples of such generalized potentials are velocity dependent
potentials due to electro-magnetic fields, for example the Lorentz force on a
charged particle.

11 Hamiltons principle
We consider mechanical systems with holonomic constraints and all other
forces conservative. Recall, we define the Lagrange function or Lagrangian
to be
L = T V,
where
T =

N
X

2
1
2 mi |v i |

i=1

is the total kinetic energy for the system, and V is its potential energy.
Definition 3 (Action) If the Lagrangian L is the difference of the kinetic and
potential energies for a system, i.e. L = T V , we define the action A = A(q)
from time t1 to t2 , where q = (q1 , . . . , qn )T , to be the functional
Z t2
t) dt.
A(q) :=
L(q, q,
t1

Hamilton [1834] realized that Lagranges equations of motion were equivalent to a variational principle (see Marsden and Ratiu [15, Page 231]).
Theorem 3 (Hamiltons principle of least action) The correct path of motion
of a mechanical system with holonomic constraints and conservative external
forces, from time t1 to t2 , is a stationary solution of the action. Indeed, the
correct path of motion q = q(t), with q = (q1 , . . . , qn )T , necessarily and sufficiently satisfies Lagranges equations of motion for j = 1, . . . , n:


L
d L

= 0.
dt qj
qj

28

Simon J.A. Malham

Quoting from Arnold [3, Page 60], it is Hamiltons form of the principle
of least action because in many cases the action of q = q(t) is not only an
extremal but also a minimum value of the action functional.
Example 7 (Simple harmonic motion) Consider a particle of mass m moving
in a one dimensional Hookeian force field kx, where k is a constant. The
potential function V = V (x) corresponding to this force field satisfies
V
= kx
x
Z x
V (x) V (0) =
k d

V (x) = 21 x2 .

The Lagrangian L = T V is thus given by


L(x, x)
= 12 mx 2 21 kx2 .
From Hamiltons principle the equations of motion are given by Lagranges
equations. Here, taking the generalized coordinate to be q = x, the single
Lagrange equation is


d L
L

= 0.
dt x
x
Substituting the form for the Lagrangian above, this equation becomes
m
x + kx = 0.
Example 8 (Kepler problem) Consider a particle of mass m moving in an
inverse square law force field, m/r2 , such as a small planet or asteroid
in the gravitational field of a star or larger planet. Hence the corresponding
potential function satisfies
V
m
= 2
r
Z r
m
d

V () V (r) =
2
r
m

V (r) =
.
r
The Lagrangian L = T V is thus given by
= 1 m(r 2 + r2 2 ) + m .
L(r, r,
, )
2
r
From Hamiltons principle the equations of motion are given by Lagranges
equations, which here, taking the generalized coordinates to be q1 = r and
q2 = , are the pair of ordinary differential equations


d L
L

= 0,
dt r
r


d L
L

= 0,
dt

Lagrangian and Hamiltonian mechanics

29

which on substituting the form for the Lagrangian above, become


m
m
r mr2 + 2 = 0,
r

d
mr2 = 0.
dt
Remark 8 (Non-uniqueness of the Lagrangian) Two Lagrangians L1 and
L2 that differ by the total time derivative of any function of q = (q1 , . . . , qn )T
and t generate the same equations of motion. In fact if
t) = L1 (q, q,
t) +
L2 (q, q,


d
f (q, t) ,
dt

then for j = 1, . . . , n direct calculation reveals that






d L2
L2
d L1
L1

.
dt qj
qj
dt qj
qj
12 Constraints
t) for a system, suppose we realize the system
Given a Lagrangian L(q, q,
has some constraints (so the qj are not all independent). Suppose we have m
holonomic constraints of the form
Gk (q1 , . . . , qn , t) = 0,
for k = 1, . . . , m < n. We can now use the method of Lagrange multipliers
with Hamiltons principle to deduce that the equations of motion are given by


m
X
d L
L
Gk

=
k (t)
,
dt qj
qj
qj
k=1

Gk (q1 , . . . , qn , t) = 0,
for j = 1, . . . , n and k = 1, . . . , m. We call the quantities on the right above
m
X
k=1

k (t)

Gk
,
qj

the generalized forces of constraint.


Example 9 (Simple pendulum) Consider the motion of a simple pendulum
bob of mass m that swings at the end of a light rod of length a. The other
end is attached so that the rod and bob can swing freely in a plane. If g is the
acceleration due to gravity, then the Lagrangian L = T V is given by
= 1 m(r 2 + r2 2 ) + mgr cos ,
L(r, r,
, )
2
together with the constraint
r a = 0.

30

Simon J.A. Malham

We could just substitute r = a into the Lagrangian, obtaining a system with


one degree of freedom, and proceed from there. However, we will consider the
system as one with two degrees of freedom, q1 = r and q2 = , together with a
constraint G(r) = 0, where G(r) = r a. Hamiltons principle and the method
of Lagrange multipliers imply that the system evolves according to the pair of
ordinary differential equations together with the algebraic constraint given by


d L

dt r


d L

dt

L
G
=
,
r
r
G
L
=
,

G = 0.

Substituting the form for the Lagrangian above, the two ordinary differential
equations together with the algebraic constraint become
m
r mr2 mg cos = ,

d
mr2 + mgr sin = 0,
dt
r a = 0.
Note that the constraint is of course r = a, which implies r = 0. Using this,
the system of differential algebraic equations thus reduces to
ma2 + mga sin = 0,
which comes from the second equation above. The first equation tells us that
the Lagrange multiplier is given by
(t) = ma2 mg cos .
The Lagrange multiplier has a physical interpretation, it is the normal reaction
force, which here is the tension in the rod.

Remark 9 (Non-holonomic constraints) Mechanical systems with some types


of non-holonomic constraints can also be treated, in particular constraints of
the form
n
X
A(q, t)kj qj + bk (q, t) = 0,
j=1

for k = 1, . . . , m, where q = (q1 , . . . , qn )T . Note the assumption is that these


equations are not integrable, in particular not exact, otherwise the constraints
would be holonomic.

Lagrangian and Hamiltonian mechanics

31

Fig. 5 The mechanical problem for the simple pendulum, can be thought of as a particle
of mass m moving in a vertical plane, that is constrained to always be a distance a from
a fixed point. In polar coordinates, the position of the mass is (r, ) and the constraint is
r = a.

13 Hamiltonian dynamics
We consider mechanical systems that are holonomic and and conservative (or
for which the applied forces have a generalized potential). For such a system
t), where q = (q1 , . . . , qn )T , which is the
we can construct a Lagrangian L(q, q,
difference of the total kinetic T and potential V energies. These mechanical
systems evolve according to the n Lagrange equations


d L
L

= 0,
dt qj
qj
for j = 1, . . . , n. These are each second order ordinary differential equations and so the system is determined for all time once 2n initial conditions
0 ) are specified (or n conditions at two different times). The state of
q(t0 ), q(t
the system is represented by a point q = (q1 , . . . , qn )T in configuration space.
Definition 4 (Generalized momenta) We define the generalized momenta for
a Lagrangian mechanical system for j = 1, . . . , n to be
pj =

L
.
qj

t) in general, where q = (q1 , . . . , qn )T and


Note that we have pj = pj (q, q,
T
q = (q1 , . . . , qn ) .
In terms of the generalized momenta, Lagranges equations become
pj =

L
,
qj

for j = 1, . . . , n. Further, in principle, we can solve the relations above which


define the generalized momenta, to find functional expressions for the qj in
terms of qi , pi and t, i.e. we can solve the relations defining the generalized
momenta to find qj = qj (q, p, t) where q = (q1 , . . . , qn )T and p = (p1 , . . . , pn )T .

32

Simon J.A. Malham

Definition 5 (Hamiltonian) We define the Hamiltonian function as the Legendre transform of the Lagrangian function, i.e. we define it to be
t),
H(q, p, t) := q p L(q, q,

where q = (q1 , . . . , qn )T and p = (p1 , . . . , pn )T and we suppose q = q(q,


p, t).
Note that in this definition we used the notation for the dot product
q p =

n
X

qj pj .

j=1

Remark 10 The Legendre transform is nicely explained in Arnold [3, Page 61]
and Evans [7, Page 121]. In practice, as far as solving example problems herein,
it simply involves the task of solving the equations for the generalized momenta
above, to find qj in terms of qi , pi and t.
From Lagranges equation of motion we can deduce Hamiltons equations
of motion, using the definitions for the generalized momenta and Hamiltonian,
pj =

L
qj

and

H=

n
X

qj pj L.

j=1

Theorem 4 (Hamiltons equations of motion) Lagranges equations of motion imply Hamiltons canonical equations, for i = 1, . . . , n we have,
H
,
pi
H
pi =
.
qi
qi =

These consist of 2n first order equations of motion.


Proof Using the chain rule and definition of the generalized momenta we have
n
n
X
X
H
qj
L qj
=
pj + qi
qi ,
pi
p

qj pi
i
j=1
j=1

and

X qj
L X L qj
L
H
=
pj

.
qi
q
q

q
q
i
i
j
i
i
j=1
j=1
Now using Lagranges equations, in the form pj = L/qj , the last relation
reveals
H
pi =
,
qi
for i = 1, . . . , n. Collecting these relations together, we see that Lagranges
equations of motion imply Hamiltons canonical equations as shown.
t
u

Lagrangian and Hamiltonian mechanics

33

Two further observations are also useful. First, if the Lagrangian L =


is independent of explicit t, then when we solve the equations that
L(q, q)

define the generalized momenta we find q = q(q,


p). Hence we see that


H = q(q,
p) p L q, q(q,
p) ,
i.e. the Hamiltonian H = H(q, p) is also independent of t explicitly. Second,
using the chain rule and Hamiltons equations we see that
n
n
X
X
dH
H
H
H
=
qi +
pi +
dt
q
p
t
i
i
i=1
i=1

dH
H
=
.
dt
t

Hence if H does not explicitly depend on t then

constant of the motion,


H is a conserved quantity,

integral of the motion.


Hence the absence of explicit t dependence in the Hamiltonian H could serve
as a more general definition of a conservative system, though in general H
may not be the total energy. However for simple mechanical systems for which
is a homogeneous quadratic function in q,
and
the kinetic energy T = T (q, q)
the potential V = V (q), then the Hamiltonian H will be the total energy. To
see this, suppose
n
X
cij (q) qi qj ,
T =
i,j=1

necessarily cij = cji . Then we have


i.e. a homogeneous quadratic function in q;
n
n
n
X
X
X
T
=
ckj (q) qj +
cik (q) qi = 2
cik (q) qi
qk
j=1
i=1
i=1

which implies
n
X
k=1

qk

T
= 2T.
qk

Thus the Hamiltonian H = 2T (T V ) = T + V , i.e. the total energy.


14 Hamiltonian formulation: summary
To construct Hamiltons canonical equations for a mechanical system proceed
as follows:
1. Choose your generalized coordinates q = (q1 , . . . , qn )T and construct
t) = T V.
L(q, q,

34

Simon J.A. Malham

2. Define and compute the generalized momenta


pi =

L
,
qi

for i = 1, . . . , n. Solve these relations to find qi = qi (q, p, t).


3. Construct and compute the Hamiltonian function
H=

n
X

qj pj L,

j=1

4. Write down Hamiltons equations of motion


H
,
pi
H
pi =
,
qi
qi =

for i = 1, . . . , n, and evaluate the partial derivatives of the Hamiltonian on


the right.
Example 10 (Simple harmonic oscillator) The Lagrangian for the simple harmonic oscillator, which consists of a mass m moving in a quadratic potential
field with characteristic coefficient k, is
L(x, x)
= 12 mx 2 21 kx2 .
The corresponding generalized momentum is
p=

L
= mx
x

which is the usual momentum. This implies x = p/m and so the Hamiltonian
is given by
H(x, p) = x p L(x, x)



p
=
p 12 mx 2 12 kx2
m


 p 2
p2
=
21 m
12 kx2
m
m
2
p
= 12
+ 1 kx2 .
m 2
Note this last expression is the sum of the kinetic and potential energies and
so H is the total energy. Hamiltons equations of motion are thus given by
x = H/p,
p = H/x,

x = p/m,
p = kx.

Note that combining these two equations, we get the usual equation for a
harmonic oscillator: m
x = kx.

Lagrangian and Hamiltonian mechanics

35

Fig. 6 The mechanical problem for the simple harmonic oscillator consists of a particle
moving in a quadratic potential field. As shown, we can think of a ball of mass m sliding
freely back and forth in a vertical plane, without energy loss, inside a parabolic shaped bowl.
The horizontal position x(t) is its displacement.

Example 11 (Kepler problem) Recall the Kepler problem for a mass m moving in an inverse-square central force field with characteristic coefficient . The
Lagrangian L = T V is
= 1 m(r 2 + r2 2 ) + m .
L(r, r,
, )
2
r
Hence the generalized momenta are
pr =

L
= mr
r

and

p =

= mr2 .

These imply r = pr /m and = p /mr2 and so the Hamiltonian is given by


L(r, r,

H(r, , pr , p ) = r pr + p
, )

 2

 

2
2
1
p
pr
m
2
2 p
1
=
p +
+r 2 4 +
2m
m r r2
m2
m r
r


2
1
p
m
=
p2 +
,
2m r r2
r
which in this case is also the total energy. Hamiltons equations of motion are
r = H/pr ,
= H/p ,
pr = H/r,
p = H/,

r = pr /m,
= p /mr2 ,
pr = p2 /mr3 m/r2 ,
p = 0.

Note that p = 0, i.e. we have that p is constant for the motion. This property
corresponds to the conservation of angular momentum.
Remark 11 The Lagrangian L = T V may change its functional form if
instead of (q, q),
but its magnitude will not
we use different variables (Q, Q)
change. However, the functional form and magnitude of the Hamiltonian both
depend on the generalized coordinates chosen. In particular, the Hamiltonian
H may be conserved for one set of coordinates, but not for another.

36

Simon J.A. Malham


q

Ut

Fig. 7 Mass-spring system on a massless cart.

Example 12 (Harmonic oscillator on a moving platform) Consider a massspring system, mass m and spring stiffness k, contained within a massless
cart which is translating horizontally with a fixed velocity U see Figure 7.
The constant velocity U of the cart is maintained by an external agency. The
Lagrangian L = T V for this system is
L(q, q,
t) = 21 mq2 12 k(q U t)2 .
The resulting equation of motion of the mass is
m q = k(q U t).
If we set Q = q U t, then the equation of motion is
= kQ.
mQ
Let us now consider the Hamiltonian formulation using two different sets of
coordinates.
First, using the generalized coordinate q, the corresponding generalized
momentum is p = mq and the Hamiltonian is
H(q, p, t) =

k
p2
+ (q U t)2 .
2m 2

Here the Hamiltonian H is the total energy, but it is not conserved (there is
an external energy input maintaining U constant).
= T V is
Second, using the generalized coordinate Q, the Lagrangian L

t) = 1 mQ 2 + mQU
+ 1 mU 2 1 kQ2 .
L(Q,
Q,
2
2
2
Here, the generalized momentum is P = mQ + mU and the Hamiltonian is
(P mU )2
k
m

H(Q,
P) =
+ Q2 U 2 .
2m
2
2
does not explicitly depend on t. Hence H
is conserved, but it is
Note that H
not the total energy.

Lagrangian and Hamiltonian mechanics

37

15 Symmetries, conservation laws and cyclic coordinates


We have already seen that
dH
H
=
.
dt
t
Hence if the Hamiltonian does not depend explicitly on t, then it is a constant
or integral of the motion; sometimes called Jacobis integral. It may be the
total energy. Further from the definition of the generalized momenta pi =
L/ qi , Lagranges equations, and Hamiltons equations for the generalized
momenta, we have
L
H
=
.
pi =
qi
qi
From these relations we can see that if qi is explicitly absent from the Lagrangian L, then it is explicitly absent from the Hamiltonian H, and
pi = 0.
Hence pi is a conserved quantity, i.e. constant of the motion. Such a qi is called
cyclic or ignorable. Note that for such coordinates qi , the transformation
t t + t,
qi qi + qi ,
leave the Lagrangian/Hamiltonian unchanged. This invariance signifies a fundamental symmetry of the system.
Example 13 (Kepler problem) Recall, the Lagrangian L = T V for the
Kepler problem is
= 1 m(r 2 + r2 2 ) + m ,
L(r, r,
, )
2
r
and the Hamiltonian is
H(r, , pr , p ) =



1
p2
m
p2r + 2
.
2m
r
r

Note that L, H are independent of t and therefore H is conserved (and here it is


the total energy). Further, L, H are independent of and therefore p = mr2
is conserved also. The original problem has two degrees of freedom (r, ).
However, we have just established two integrals of the motion, namely H
and p . This system is said to be integrable.
Example 14 (Axisymmetric top) Consider a simple axisymmetric top of mass
m with a fixed point on its axis of symmetry; see Figure 8. Suppose the centre
of mass is a distance a from the fixed point, and the principle moments of
inertia are A = B 6= C. We assume there are no torques about the symmetry

38

Simon J.A. Malham

mg
Fig. 8 Simple axisymmetric top: this consists of a body of mass m that spins around its
axis of symmetry moving under gravity. It has a fixed point on its axis of symmetryhere
this is the pivot at the narrow pointed end that touches the ground. The centre of mass is a
distance a from the fixed point. The configuration of the top is given in terms of the Euler
angles (, , ) shown. Typically the top also precesses around the vertical axis = 0.

or vertical axes. The configuration of the top is given in terms of the Euler
angles (, , ) as shown in Figure 8. The Lagrangian L = T V is
L = 21 A(2 + 2 sin2 ) + 21 C( + cos )2 mga cos .
The generalized momenta are

p = A,
p = A sin2 + C cos ( + cos ),
p = C( + cos ).
Using these the Hamiltonian is given by
H=

p2
(p p cos )2
p2
+
+
+ mga cos .
2A
2C
2A sin2

We see that L, H are both independent of t, and . Hence H, p and


p are conserved. Respectively, they represent the total energy, the angular
momentum about the symmetry axis and the angular momentum about the
vertical.
Remark 12 (Noethers Theorem) To accept only those symmetries which
leave the Lagrangian unchanged is needlessly restrictive. When searching for
conservation laws (integrals of the motion), we can in general consider transformations that leave the action integral invariant enough so that we get
the same equations of motion. This is the idea underlying (Emmy) Noethers
theorem; see Arnold [3, Page 88].

Lagrangian and Hamiltonian mechanics

39

16 Poisson brackets
Definition 6 (Poisson brackets) For two functions u = u(q, p) and v =
v(q, p), where q = (q1 , . . . , qn )T and p = (p1 , . . . , pn )T , we define their Poisson
bracket to be

n 
X
u v
u v
[u, v] :=

.
qi pi
pi qi
i=1
The Poisson bracket satisfies some properties that can be checked directly. For
example, for any function u = u(q, p) and constant c we have [u, c] = 0. We
also observe that if v = v(q, p) and w = w(q, p) then [uv, w] = u[v, w]+v[u, w].
Three crucial properties are summarized in the following lemma.
Lemma 3 (Lie algebra properties) The bracket satisfies the following properties for all functions u = u(q, p), v = v(q, p) and w = w(q, p) and scalars
and :
1. Skew-symmetry: [v, u] = [u, v];
2. Bilinearity: [u + v, w] = [u, w] + [v, w];
3. Jacobis identity: [u, [v, w]] + [v, [w, u]] + [w, [u, v]] = 0.
These three properties define a non-associative algebra known as a Lie algebra.
Two further simple examples of Lie algebras are: the vector space of vectors
equipped with the wedge or vector product [u, v] = u v and the vector space
of matrices equipped with the matrix commutator product [A, B] = AB BA.
Corollary 2 (Properties from the definition) Using that all the coordinates
(q1 , . . . , qn ) and (p1 , . . . , pn ) are independent, we immediately deduce by direct
substitution into the definition, the following results for any u = u(q, p) and
all i, j = 1, . . . , n:
u
= [u, pi ],
qi

u
= [u, qi ], [qi , qj ] = 0, [pi , pj ] = 0 and [qi , pj ] = ij .
pi

Here ij is the Kronecker delta which is zero when i 6= j and unity when i = j.
Corollary 3 (Poisson bracket for canonical variables) If q = (q1 , . . . , qn )T and
p = (p1 , . . . , pn )T are canonical Hamilton variables, i.e. they satisfy Hamiltons
equations for some Hamiltonian H, then for any function f = f (q, p) we have
df
f
=
+ [f, H].
dt
t
Proof Using Hamiltons equations of motion (in vector notation) we know
dp
dq
= p H
and
= q H.
dt
dt
Thus by the chain rule and then Hamiltons equations we find
dq
dp
df
=
q H +
p H = p H q H + (q H) p H
dt
dt
dt
which is zero by the commutative property of the scalar (dot) product.

t
u

40

Simon J.A. Malham

All the properties above are essential for the next two results of this section.
First, remarkably the the Poisson bracket is invariant under canonical
transformations. By this we mean the following. Suppose we make a transformation of the canonical coordinates (q, p), satisfying Hamiltons equations
with respect to a Hamiltonian H, to new canonical coordinates (Q, P ), satisfying Hamiltons equations with respect to a Hamiltonian K, where
Q = Q(q, p)

and

P = P (q, p).

For two functions u = u(q, p) and v = v(q, p) define U = U (Q, P ) and


V = V (Q, P ) by the identities
U (Q, P ) = u(q, p)

and

V (Q, P ) = v(q, p).

Then we have the following resultwhose proof we leave as an exercise in the


chain rule! (Hint: start with [u, v]q,p and immediately substitute the definitions
for U and V ; also see Arnold [3, Page 216].)
Lemma 4 (Invariance under canonical transformations) The Poisson bracket
is invariant under a canonical transformations, i.e. we have
[U, V ]Q,P = [u, v]q,p .
Second, we can use Poisson Brackets to (potentially) generate further constants of the motion. Using Corollary 3 on the Poisson bracket of canonical
variables we see Hamiltons equations of motion are equivalent to the system
of equations
dp
dq
= [q, H]
and
= [p, H].
dt
dt
Here, by [q, H] we mean the vector with components [qi , H], and observe we
have simply substituted the components of q and p for f in Corollary 3. If
u = u(q, p, t) is a constant of the motion then
du
= 0,
dt
and by Corollary 3 we see that
u
= [H, u].
t
If u = u(q, p) only and does not depend explicitly on t then it must must
Poisson commute with the Hamiltonian H, i.e. it must satisfy
[H, u] = 0.
Now suppose we have two constants of the motion u = u(q, p) and v = v(q, p),
so that [H, u] = 0 and [H, v] = 0. Then by Jacobis identity we find
[H, [u, v]] = [u, [v, H]] [v, [H, u]] = 0.

Lagrangian and Hamiltonian mechanics

41

In other words it appears as though [u, v] is another constant of the motion.


(This result also extends to the case when u and v explicitly depend on t.)
Indeed, in principle, we can generate a sequence of constants of the motion u,
v, [u, v], [u, [u, v]], . . . . Sometimes we generate new constants of the motion by
this procedure, i.e. we get new information, but often we generate a constant
of the motion we already know about.
Example 15 (Kepler problem) Consider the Kepler problem of a particle of
mass m in a three-dimensional central force field with Hamiltonian
1 2
(p + p22 + p23 ) + V (r)
H=
2m 1
p
where V = V (r) is the potential with r = q12 + q22 + q32 . Known constants of
the motion are u = q2 p3 q3 p2 and v = q3 p1 q1 p3 and their Poisson bracket
[u, v] = q1 p2 q2 p1 is another constant of the motion (not too surprisingly in
this case).
17 Geodesic flow
We have already seen the simple example of the curve that minimizes the
distance between two points in Euclidean spaceunsurprisingly a straight
line. What if the two points lie on a surface or manifold? Here we wish to
determine the characterizing properties of curves that minimize the distance
between two such points. To begin to answer this question, we need to set out
the essential components we require. Indeed, the concepts we have discussed
so far and our examples above have hinted at the need to consider the notion
of a manifold and its concomitant components. We assume in this section the
reader is familiar with the notions of Hausdorff topology, manifolds, tangent
spaces and tangent bundles. A comprehensive introduction to these can be
found in Abraham and Marsden [1, Chapter 1] or Marsden and Ratiu [15].
Thorough treatments of the material in this section can for example be found
in Abraham and Marsden [1], Marsden and Ratiu [15] and Jost [8].
We now introduce a mechanism to measure the distance between two
points on a manifold. To achieve this we need to be able to measure the length
of, and angles between, tangent vectorssee for example Jost [8, Section 1.4]
or Tao [17]. The mechanism for this in Euclidean space is the scalar product
between vectors.
Definition 7 (Riemannian metric and manifold) On a smooth manifold M
we assign, to any point q M and pair of vectors u, v Tq M, an inner
product
hu, vig(q) .
This assignment is assumed to be smooth with respect to the base point q
M, and g = g(q) is known as the Riemannian metric. The length of a tangent
vector u Tq M is then
1/2
kukg(q) := hu, uig(q) .

42

Simon J.A. Malham

A Riemannian manifold is a smooth manifold M equipped with a Riemannian


metric.
Remark 13 Every smooth manifold can be equipped with a Riemannian metric; see Jost [8, Theorem 1.4.1].
In local coordinates with q = (q1 , . . . , qn )T M, u = (u1 , . . . , un )T Tq M
and v = (v1 , . . . , vn )T Tq M, the Riemannian metric g = g(q) is a real
symmetric invertible positive definite matrix and the inner product above is
n
X

hu, vig(q) :=

gij (q)ui vj .

i,j=1

We are interested in minimizing the length of a smooth curve on M, however


as we will see, computations based on the energy of a smooth curve are simpler.
Definition 8 (Length and energy of a curve) Let q : [a, b] M be a smooth
curve. Then we define the length of this curve by
b

Z
`(q) :=


q(t)
g(q(t)) dt.

We define the energy of the curve to be


E(q) :=

1
2

Z
a

2
q(t)
g(q(t)) dt.

Remark 14 The energy E(q) is the action associated with the curve q = q(t)
on [a, b].
Remark 15 (Distance function) The distance between two points qa , q b
M, assuming q(a) = q a and q(b) = q b , can be defined as d(a, b) := inf q `(q) .
This distance function satisfies the usual axioms (positive definiteness, symmetry in its arguments and the triangle inequality); see Jost [8, pp. 1516].
By the CauchySchwarz inequality we know that
Z
a


q(t)

g(q(t))

dt 6 |b a|

1
2

Z

2
q(t)

g(q(t))

 12
dt

Using the definitions of `(q) and E(q) this implies


2
`(q) 6 2 |b a| E(q).
2
We have equality in this last statement, i.e. we have `(q) = 2 |b a| E(q),
if and only if q is constant. The length `(q) of a smooth curve q = q(t) is
invariant to reparameterization; see for example Jost [8, p. 17]. Hence we can
always parameterize a curve so as to arrange for q to be constant (this is also

Lagrangian and Hamiltonian mechanics

43

known as parameterization proportional to arclength). After such a parameterization, minimizing the energy is equivalent to minimizing the length, and
this is how we proceed henceforth.
We are now in a position to derive the geodesic equations that characterize
the curves that minimize the length/energy between two arbitrary points on
a smooth manifold M. For more background and further reading see Abraham and Marsden [1, p, 2245], Marsden and Ratiu [15, Section 7.5], Montgomery [16, pp. 610] and Tao [17]. Our goal is thus to minimize the total
energy of a path q = q(t) where q = (q1 , . . . , qn )T . The total energy of a path
q = q(t), between t = a and t = b, as we have seen, can be defined in terms
as follows
of a Lagrangian function L = L(q, q)
Z

t2

L q(t), q(t)
dt.

E(q) :=
t1

The path q = q(t) that minimizes the total energy E = E(q) necessarily
satisfies the EulerLagrange equations. Here these take the form of Lagranges
equations of motion


L
d L

= 0,
dt qj
qj
for each j = 1, . . . , n. In the following, we use g ij to denote the inverse matrix
of gij (where i, j = 1, . . . , n) so that
n
X

g ik gkj = ij ,

k=1

where ij is the Kronecker delta function that is 1 when i = j and 0 otherwise.


Lemma 5 (Geodesic equations) Lagranges equations of motion for the Lagrangian
n
X
:= 21
gik (q) qi qk ,
L(q, q)
i,k=1

are given in local coordinates by the system of ordinary differential equations


qi +

n
X

i
jk
qj qk = 0,

j,k=1
i
where the quantities jk
are known as the Christoffel symbols and for i, j, k =
1, . . . , n are given by

i
jk

:=

n
X
`=1

1 i`
2g


g`j
gk`
gjk
+

.
qk
qj
q`

44

Simon J.A. Malham

Proof We complete the proof in three steps as follows.


defined in the statement of the lemma,
Step 1. For the Lagrangian L = L(q, q)
using the product and chain rules, we find that
L
=
qj

1
2

L
=
qj

1
2

1
2

n
X
gik
qi qk
qj

i,k=1

and
n
X
k=1
n
X

n
X

1
2

gjk qk +

i=1
n
X

1
2

gjk qk +

k=1
n
X

gij qi
gkj qk

k=1

gjk qk ,

k=1

where in the last step we utilized the symmetry of g. Using this last expression
we see


n
X

d
d L
gjk qk
=
dt qj
dt
=
=

k=1
n
X

k=1
n
X

X

dgjk
qk +
gjk qk
dt

k,`=1

k=1

X

gjk
q` qk +
gjk qk .
dq`
k=1

Substituting the expressions above into Lagranges equations of motion, using


that the summation indices i and k can be relabelled and that g is symmetric,
we find
n 
n
X
X
gjk
gk` 
gjk qk +
12
qk q` = 0,
q`
qj
k=1

k,`=1

for each j = 1, . . . , n.
Step 2. We multiply the last equations from Step 1 by g ij and sum over the
index j. This gives
n
X

g ij gjk qk +

j,k=1

qi +

qi +

n
X
j,k,`=1
n
X
j,k,`=1
n
X
j,k,`=1

g ij

 g

g ij

 g

g i`

 g

jk

q`
jk

q`
`j

qk

1
2

gk` 
qk q` = 0
qj

1
2

gk` 
qk q` = 0
qj

1
2

gjk 
qj qk = 0,
q`

Lagrangian and Hamiltonian mechanics

45

where in the last step we relabelled summation indices.


Step 3. By using the symmetry of g and performing some further relabelling
of summation indices, we see




n
n
X
X
g`j
gjk
i` g`j
1 gjk
1 i` g`j
g
2
qj qk =
+

qj qk
2g
qk
q`
qk
qk
q`
j,k,`=1
j,k,`=1


n
X
gk`
gjk
1 i` g`j
=
g
+

qj qk
2
qk
qj
q`
=

j,k,`=1
n
X

iji qj qk ,

j,k=1

where the iji are those given in the statement of the lemma.

t
u

Remark 16 On a smooth Riemannian manifold there is unique torsion free


connection or covariant derivative defined on the tangent bundle known as
the LeviCivita connection. A curve q : [a, b] M is autoparallel or geodesic
with respect to if
q q 0,
i.e. the tangent field of q = q(t) is parallel along q = q(t); see Jost [8, Definition 3.1.6]. In local coordinates, the coordinates of q q are given by
i=q
i +
(q q)

n
X

i
jk
q j q k ,

j,k=1
i
for i = 1, . . . , n, where the quantities jk
are equivalent to the Christoffel
symbols above.

Now suppose that M is an embedded submanifold in a higher dimensional


Euclidean space RN . Then M is a Riemannian manifold. (Nashs Theorem
says that any Riemannian manifold can be embedded in a higher dimensional
Euclidean space RN .) For an embedded submanifold M, its Riemannian metric is that naturally induced from the embedding Euclidean space using the
map from intrinsic to extrinsic coordinates. For example, in our discussion
of DAlemberts principle, we saw that the dynamics of the system evolved
in the Euclidean space R3N , parameterized by the extrinsic coordinates r 1 ,
. . . , r N , though subject to m < 3N constraints. The dynamics thus evolves
on the submanifold M prescribed by the constraints. The dimension of M
is n = 3N m and so locally M can be parameterized by the coordinates
(q1 , . . . , qn ). Further, by making the change of coordinates
r 1 = r 1 (q1 , . . . , qn ),
..
.
r N = r N (q1 , . . . , qn ),

46

Simon J.A. Malham

we demonstrated that DAlemberts principle is equivalent to Lagranges equations of motion. Indeed the geodesic equations we derived above
2 were La = 12 q g(q) . Thus,
granges equations of motion for the Lagrangian L(q, q)
starting with Lagranges equations of motion for this Lagrangian, we can trace
the direction of implication back through to DAlemberts principle and thus
deduce that
Tq M.
q
As we argued in the lead up to DAlemberts principle, this makes sense on
a intuitive and physical level. The system is free to evolve on the manifold of
constraint and, assuming no external forces, the forces of constraint must act
normally to the manifold (normal to the tangent plane at every point q M)
in order to maintain the evolution on the manifold. In other words, as Tao [17]
eminently puts it,
... the normal quantity q then corresponds to the centripetal force
necessary to keep the particle lying in M (otherwise it would fly off
along a tangent line to M, as per Newtons first law).

18 Euler equations for incompressible flow


We formally show here how the Euler equations for incompressible flow represent a geodesic submanifold flow. The argument is an extension of that above
for finite dimensional geodesic submanifold flow to an infinite dimensional
context and is originally due to Arnold. Our arguments essentially combine
those in Daneri and Figalli [6] and Tao [17] and we cite Chorin and Marsden [5] and Malham [13] for further background material on incompressible
fluid mechanics.
The Euler equations for incompressible flow in a bounded Lipschitz domain
D Rd and on an arbitrary finite time interval [0, T ] are prescribed as follows.
The velocity field u = u(x, t) for (x, t) D [0, T ] evolves according to the
system of nonlinear partial differential equations
u
+ (u )u = p,
t
u = 0.
Here the field p = p(x, t) is the pressure field. We need to augment this system
of equations with the zero flux boundary condition for all (x, t) D [0, T ],
i.e. we have u n = 0, where n is the unit outer normal to D. We also need
to prescribe initial data u(x, 0) = u0 (x) for some given function u0 = u0 (x)
on D.
From the Lagrangian viewpoint we can describe the flow through the
swarm of particle trajectories prescribed by integral curves of the local velocity field u = u(x, t). Let q = q(x, t) Rd represent the position at time

Lagrangian and Hamiltonian mechanics

47

t > 0 of the particle that started at position x D at time t = 0. The flow


q = q(x, t) satisfies the system of equations


q(x,
t) = u q(x, t), t ,
q(x, 0) = x,
for all (x, t) D [0, T ]. A straightforward though lengthy calculation (see
Chorin and Marsden [5] or Malham [13]) reveals that the Jacobian of the flow
det q = det x q(x, t) satisfies the system of equations


d
det q = u(q, t) det q.
dt
Since we assume the flow is incompressible so u = 0, and q(x, 0) = x, we
deduce for all t [0, T ] we have det q 1. This means that for all t [0, T ],
q( , , t) SDiff(D), the group of measure preserving diffeomorphisms on D. If
we now differentiate the evolution equations for q = q(x, t) above with respect
to time t and compare this to the Euler equations, we obtain the following
equivalent formulation for the Euler equations of incompressible flow in terms
of q t (x) := q(x, t) for all t [0, T ]:
t = p(q t , t),
q
with the constraint
q t SDiff(D).
We now demonstrate formally how these equations can be realized as a
geodesic flow on SDiff(D) equipped with the L2 (D; Rd ) metric induced from
the inner product
Z


v, L2 (D;Rd ) :=
v dx.
D

We consider SDiff(D) as an infinite dimensional submanifold of Diff(D), the


group of diffeomorphisms on D. By analogy with the finite dimensional case,
the curve q : t 7 q t on SDiff(D) is geodesic if
Tq SDiff(D).
q
Remark 17 Suppose the flow is not constrained and evolves on Diff(D). Then
= 0, i.e. Newtons Second Law, as
a geodesic would be characterized by q
the metric is flat. For the intrinsic velocity field (see below) we would have
u/t + (u )u = 0; see Tao [17].
Our goal now is to characterize the vector space orthogonal to Tq SDiff(D).
Using the definition of the flow above, we define the intrinsic velocity field
ut (x) = u(x, t) by ut := q t q 1
t . Using the result for the Jacobian det q
above we note that the inner product h , i above is invariant to transformations x 7 q t (x) SDiff(D). Further, we can thus characterize


Tq SDiff(D) = u(q t , t) : u(q t , t) = 0 and u n(q t , t) = 0 on D .

48

Simon J.A. Malham

Equivalently, since it is the Lie algebra of SDiff(D) which is the vector space
of all smooth divergence-free vector fields parallel to the boundary, we have


Tq SDiff(D) = ut : ut = 0 and ut n = 0 on D .
The HelmholtzHodge Decomposition Theorem tells us that any vector
L2 (D, Rd ) can be orthogonally decomposed into a divergence-free vector u
parallel to D and a solenoidal vector p. In other words we can write
= u + p,
where u = 0 and p = p for some scalar field p. See for example Chorin
and Marsden [5, p. 37]. In terms of tangent spaces, we have

Tq Diff(D) = Tq SDiff(D) Tq SDiff(D)
where
 

Tq SDiff(D) = p L2 (D, Rd ) : p = p .
t = p(q t , t) for q t SDiff(D), which are the Euler
Hence we deduce that q
equations for incompressible flow.

19 Exercises
Exercise 1 (EulerLagrange alternative form) Show that the EulerLagrange
equation is equivalent to


d
F
F

F yx
= 0.
x
dx
yx
Exercise 2 (Soap film) A soap film is stretched between two rings of radius
a which lie in parallel planes a distance 2x0 apartthe axis of symmetry of
the two rings is coincidentsee Figure 9.
(a) Explain why the surface area of the surface of revolution is given by
Z x0 p
J(y) = 2
y 1 + (yx )2 dx,
x0

where radius of the surface of revolution is given by y = y(x) for x [x0 , x0 ].


(b) Show that extremizing the surface area J(y) in part (a) leads to the
following ordinary differential equation for y = y(x):


dy
dx

2

where C is an arbitrary constant.

= C 2 y 2 1

Lagrangian and Hamiltonian mechanics

49

ds
y=y(x)
x 0

x0

surface of
revolution
Fig. 9 Soap film stretched between two concentric rings. The radius of the surface of revolution is given by y = y(x) for x [x0 , x0 ].

(c) Use the substitution y = C cosh and the identity cosh2 sinh2 = 1
to show that the solution to the ordinary differential equation in part (b) is

y = C cosh C 1 (x + b)
where b is another arbitrary constant. Explain why we can deduce that b = 0.
(d) Using the end-point conditions y = a at x = x0 , discuss the existence
of solutions in relation to the ratio a/x0 .
Exercise 3 (Hanging rope) We wish to compute the shape y = y(x) of a
uniform heavy hanging rope that is supported at the points (a, 0) and (a, 0).
The rope hangs so as to minimize its total potential energy which is given by
the functional
Z +a
p
gy 1 + (yx )2 dx,
a

where is the mass density of the rope and g is the acceleration due to gravity.
Suppose that the total length of the rope is fixed and given by `, i.e. we have
a constraint on the system given by
Z +a p
1 + (yx )2 dx = `.
a

(a) Use the method of Lagrange multipliers to show the EulerLagrange


equations in this case is
(yx )2 = c2 (y + )2 1,
where c is an arbitrary constant and the Lagrange multiplier. (Hint: you
may find the alternative form for the EulerLagrange equation more useful
here.)
(b) Use the substitution c(y + ) = cosh to show that the solution to the
ordinary differential equation in (a) is

y = c1 cosh c(x + b) ,

50

Simon J.A. Malham

for some constant b. Since the problem is symmetric about the origin, what
does this imply about b?
(c) Use the boundary conditions that y = 0 at x = a and the constraint
condition, respectively, to show that
c = cosh(ac),
c ` = 2 sinh(ac).
Under what condition does the second equation have a real solution? What is
the physical significance of this condition?
Exercise 4 (Motion of relativistic particles) A particle with position x(t)
R3 at time t prescribes a path that minimizes the functional
r

Z t1 
2
|x|
2
m0 c 1 2 U (x) dt,
c
t0
subject to x(t0 ) = a and x(t1 ) = b. Show the equation of evolution of the
particle is


d
dx
m0
m
= U,
where
m= q
.
dt
dt
2
1 |x|
c2
This is the equation of motion of a relativistic particle in an inertial system,
under the influence of the force U . Note the relativistic mass m of the particle depends on its velocity. This mass goes to infinity if the particle approaches
the velocity of light c.
Exercise 5 (Central force field) A particle of mass m moves under the central
force F = dV (r)/dr in the spherical coordinate system such that
x = r cos sin ,
y = r sin sin ,
z = r cos .
The total kinetic energy of the system T = 12 m(x 2 + y 2 + z 2 ) in spherical polar
coordinates is T = 21 m(r 2 + r2 2 + r2 sin2 2 ). Hence the Lagrangian is given
by
L = 12 m(r 2 + r2 2 + r2 sin2 2 ) V (r).
From this Lagrangian, show that: (i) the quantity mr2 sin2 is a constant of
the motion (call this h); (ii) the two remaining equations of motion are
h2
d 2 
r = 2 2 cot cosec2 ,
dt
m r
h2
1 dV
r = r2 + 2 3 cosec2
.
m r
m dr

Lagrangian and Hamiltonian mechanics

51
particle slides on frictionless plane

particle only moves up and down

Fig. 10 Horizontal Atwoods machine: a string of length `, with a mass m at each end,
passes through a hole in a horizontal frictionless plane. One mass moves horizontally on the
plane, the other hangs vertically downwards and only moves up and down

Exercise 6 (Spherical pendulum) An inextensible string of length ` is fixed at


one end and has a bob of mass m attached to the other. This bob swings freely
under gravity, forming a spherical pendulum. Explain why the Lagrangian for
this system is given by
)
= 1 m`2 (2 + sin2 2 ) + mg` cos ,
L(, , ,
2
where (, ) are spherical angle coordinates centred at the fixed end of the
pendulum where measures the angle to the vertical downward direction, and
represents the azimuthal angle. Identify a conserved quantity. Write down
the pair of Lagrange equations and use them to show, first that
m`2 sin2 = constant = K,
and second, the equation of motion is given by

2
g
K
= sin +
cot cosec2 .
`
m`2
There is a solution to the spherical pendulum for which the bob traces out
a horizontal circlei.e. the bob rotates maintaining a fixed angle 0 to the
vertical. Show that this is only possible for values of 0 satisfying
  2 2
m`
g
sin4 0 = cos 0 .
`
K
Does a solution 0 < 0 < exist?
Exercise 7 (Horizontal Atwood machine) A string of length ` has a mass m
at each end, and passes through a hole in a horizontal frictionless plane. One
mass moves horizontally on the plane, the other hangs vertically downwards
see Figure 10. The Lagrangian for this system has the form
= 1 m(2r 2 + r2 2 ) + mg(` r),
L(r, , r,
)
2

52

Simon J.A. Malham

where (r, ) are the plane polar coordinates of the mass that moves on the
plane.
(a) Show that the generalized momenta pr and p corresponding to the
coordinates r and , respectively, are given by
pr = 2mr

and

p = mr2 .

(b) Using the results from part (a), show that the Hamiltonian for this
system is given by
H(r, , pr , p ) =

p2r
p2
mg(` r).
+
4m 2mr2

(c) Explain why the Hamiltonian H and generalized momentum p are


constants of the motion. Explain why the Hamiltonian equals the total energy
of the system.
(d) In light of the information in part (c) above, we can express the Hamiltonian in the form
p2
H(r, , pr , p ) = r + V (r),
4m
where
p2
V (r) =
mg(` r).
2mr2
In other words, we can now think of the system as a particle moving in a
potential given by V (r).
Sketch V as a function of r. Describe qualitatively the different dynamics
for the particle you might expect to see. (Hint: Use that the Hamiltonian,
which is the total energy, is constant.)
Exercise 8 (Pendulum with moving frictionless support) A pendulum system consists of a light rod, of length `, with a mass M connected at one end
that can slide freely along the x-axis, and a mass m at the other end that
swings freely in the vertical plane containing the x-axissee Figure 11 on the
next page. Let (t) represent the position of the mass M along the x-axis, and
(t) the angle the rod makes with the vertical, at time t.
(a) Show that the Lagrangian for this system is
= 1 M 2 + 1 m(`2 2 + 2 + 2` cos ) + mg` cos .
L(, , ,
)
2
2
(b) Derive explicit expressions for the generalized momenta p and p corresponding to the coordinates and , respectively.
(c) Explain why the Hamiltonian (no need to derive it) and p are constants
of the motion.
(d) Assume p = 0 (this corresponds to assuming that the centre of mass
of the system is not uniformly translating in the x-direction) and show that
(M + m) = m` sin + A,

Lagrangian and Hamiltonian mechanics

53

y
M

Fig. 11 Pendulum with moving frictionless support.

where A is an arbitrary constant.


(e) Using the result from part (d), write down Lagranges equation of
motion for the angle = (t).
(f) Using the result for = (t) in part (d) above, show that the position
of the mass m at time t in Cartesian x and y coordinates is given by


M`
A
x=
sin +
,
M +m
M +m
y = ` cos .
What is the shape of this curve with respect to the x and y coordinates?
Exercise 9 (Swinging Atwood machine) The swinging Atwood machine is
a mechanism that resembles a simple Atwood machine except that one of
the masses is allowed to swing in a two-dimensional planesee Figure 12. A
string of length `, with a mass M at one end and a mass m at the other,
is stretched over two frictionless pulleys as shown in Figure 12. The mass M
hangs vertically downwards; it only moves up and down. The mass m on the
other hand is free to swing in a vertical plane as shown. The Lagrangian for
this system has the form
= 1 (M + m)r 2 + 1 mr2 2 gr(M m cos ),
L(r, , r,
)
2
2
where (r, ) are the plane polar coordinates of the mass m that can swing in
the vertical plane. Here g is the acceleration due to gravity.
(a) Show that the generalized momenta pr and p corresponding to the
coordinates r and , respectively, are given by
pr = (M + m)r

and

p = mr2 .

(b) Using the results from part (a), show that the Hamiltonian for this
system is given by
H(r, , pr , p ) =

p2
p2r
+
+ gr(M m cos ).
2(M + m) 2mr2

54

Simon J.A. Malham

Fig. 12 Swinging Atwoods machine: a string of length `, with a mass M at one end and a
mass m at the other, is stretched over two pulleys. The mass M hangs vertically downwards;
it only moves up and down. The mass m is free to swing in a vertical plane.

(c) Explain why the Hamiltonian H is a constant of the motion. Is the


Hamiltonian H equal to the total energy?
(d) By either using Lagranges equations of motion, or, using Hamiltons
equations of motion, show that the swinging Atwoods machine evolves according to a pair of second order ordinary differential equations

1
mr2 g(M m cos ) ,
M +m
r = 2r g sin .
r =

Exercise 10 (Particle in a cone) A cone of semi-angle has its axis vertical


and vertex downwards, as in Figure 13. A point mass m slides without friction
on the inside of the cone under the influence of gravity which acts along the
negative z direction. The Lagrangian for the particle is


2
mgr
= 1 m r2 2 + r
L(r, , r,
)

,
2
tan
sin2
where (r, ) are plane polar coordinates as shown in Figure 13.
(a) Show that the generalized momenta pr and p corresponding to the
coordinates r and , respectively, are given by
pr =

mr
sin2

and

p = mr2 .

(b) Show that the Hamiltonian for this system is given by


H(r, , pr , p ) =

sin2 2
p2
mgr
pr +
+
.
2m
2mr2
tan

(c) Explain why the Hamiltonian H and generalized momentum p are


constants of the motion.

Lagrangian and Hamiltonian mechanics

55

Fig. 13 Particle sliding without friction inside a cone of semi-angle , axis vertical and
vertex downwards.

(d) In light of the information in part (c) above, we can express the Hamiltonian in the form
H(r, , pr , p ) =

sin2 2
p + V (r),
2m r

where

p2
mgr
.
+
2mr2
tan
In other words, we can now think of the system as a particle moving in a
potential given by V (r).
Sketch V as a function of r. Describe qualitatively the different dynamics
for the particle you might expect to see.
V (r) =

Exercise 11 (Spherical pendulum revisited) An inextensible string of length


` is fixed at one end and has a bob of mass m attached to the other. This
bob swings freely under gravity, forming a spherical pendulum. Recall the
form of the Lagrangian from the exercise above. Write down the Hamiltonian
for this system, and identify a constant, J, of the motion (distinct from the
Hamiltonian, which is also conserved). If is the angle the string makes with
the vertical, show that the Hamiltonian can be written in the form
H=

p2
+ U ().
2m`2

where and p are the canonical coordinates and U () is the effective potential.
Sketch U () showing that it has a local minimum at 0 , where 0 satisfies,


J
cos 0 = g` sin4 0 .
m`

56

Simon J.A. Malham

Briefly describe the possible behaviour of this system.


Exercise 12 (Axisymmetric top) The axisymmetric top is the spinning top
that was once a standard childs toysee Figure 8 in the notes. It consists of a
body of mass m that spins around its axis of symmetry moving under gravity.
It has a fixed point on its axis of symmetryin Figure 8 it is pivoted at the
narrow pointed end that touches the ground. Suppose the centre of mass is a
distance a from the fixed point, and the constant principle moments of inertia
are A = B 6= C. We assume there are no torques about the symmetry or
vertical axes. The configuration of the top is given in terms of the Euler angles
(, , ) as shown in Figure 8. Besides spinning about its axis of symmetry,
the top typically precesses about the vertical axis = 0. The Lagrangian for
an axisymmetric top has the form
L = 12 A(2 + 2 sin2 ) + 21 C( + cos )2 mga cos .
Here g is the acceleration due to gravity.
(a) Show that the generalized momenta p , p and p corresponding to the
coordinates , and , respectively, are given by

p = A,
p = A sin2 + C cos ( + cos ),
p = C( + cos ).
By looking at the form for the Lagrangian L, explain why p and p are
constants of the motion. Further, explain why we know that the Hamiltonian
H is a constant of the motion as well. Is the Hamiltonian H equal to the total
energy?
(b) The Hamiltonian for this system can be expressed in the form (note,
you may take this as given):
H=

p2
+ U (),
2A

where

p2
(p p cos )2
+
+ mga cos .
2
2C
2A sin
Using the substitution z = cos in the potential U , and recalling from part (a)
above that p , p and H are constants of the motion, show that the motion of
the axisymmetric top must at all times satisfy the constraint F (z) = 0 where

F (z) := (p p z)2 + (A/C)p2 + 2Amgaz + p2 2AH (1 z 2 ).
U () =

(c) Note that the function F = F (z) in part (b) above is a cubic polynomial
in z and 1 z +1. Assume for the moment that p is fixed (i.e. temporarily
ignore that p = p (t) evolves, and along with = (t), describes the motion
of the axisymmetric top) and thus consider F = F (z) as simply a function

Lagrangian and Hamiltonian mechanics

57
z

y
b

Fig. 14 The goal is to find the path on the surface of the sphere that minimizes the distance
between two arbitrary points a and b that lie on the sphere. It is natural to use spherical
polar coordinates (r, , ) and to take the radial distance to be fixed, say r = r0 with r0
constant. The angles and are the latitude (measured from the north pole axis) and
azimuthal angles, respectively. We can specify a path on the surface by a function = ().

of z. Show that F (1) > 0 and F (+1) > 0. Using this result, explain why,
between z = 1 and z = +1, F (z) may have at most two roots.
(d) Returning to the dynamics of the axisymmetric top, note that U ()
H and that U () = H if and only if p = 0, i.e. when = 0. Assuming that,
when p = 0, the function F = F (z) has exactly two roots z1 = cos 1 and
z2 = cos 2 , describe the possible motion of the top in this case.

Exercise 13 (Spherical geodesic) The goal of this problem is to find the path
on the surface of the sphere of radius r that minimizes the distance between
two arbitrary points a and b that lie on the sphere. It is natural to use spherical
polar coordinates and to take the radial distance to be fixed, say r = r0 with
r0 constant. The relationship between spherical and cartesian coordinates is
x = r sin cos ,
y = r sin sin ,
z = r cos ,
where and are the latitude (measured from the north pole axis) and azimuthal angles, respectively. See the setup in Figure 14. We thus wish to
minimize the total arclength from the point a to the point b on the surface of
the sphere, i.e. to minimize the total arclength functional
Z

ds,
a

58

Simon J.A. Malham

where s measures arclength on the surface of the sphere.


(a) The position on the surface of the sphere can be specified by the azimuthal angle and the latitudinal angle as shown in Figure 14, i.e. we
can specify a path on the surface by a function = (). Use spherical polar
coordinates to show that we can express the total arclength functional in the
form
Z b q
2
J() := r0
1 + sin2 0 d,
a
0

where = d/d. Here a and b are the latitude angles


p of points a and b on
the sphere surface. Hint: you need to compute ds = (dx)2 + (dy)2 + (dz)2 ,
though remember that r = r0 is fixed.
(b) Write down the EulerLagrange equation that the path = () that
minimizes J must satisfy, and hence show that it is equivalent to the following
first order ordinary differential equation:
sin2 0
1 + sin2 (0 )2

 12 = c,

for some arbitrary constant c.


(c) Note that we can always orient our coordinate system so that a =
0. Using this initial condition and the EulerLagrange equation in part (b),
deduce that the solution is an arc of a great circle (a great circle is cut out
on the surface of a sphere by a plane that passes through the centre of the
sphere).
(d) What is an everyday application of this knowledge?

Acknowledgements
These notes are dedicated to Dr. Frank Berkshire whose enthusiasm and knowledge inspired me as a student. The lecture notes herein, are largely based on
the first half of Franks Dynamics course that I attended as a third year undergraduate at Imperial College in the Autumn term of 1989.

References
1. Abraham, R. and Marsden, J.E. 1978 Foundations of mechanics, Second edition, Westview Press.
2. Agrachev, A., Barilari, D. and Boscain, U. 2013 Introduction to Riemannian and SubRiemannian geometry (from Hamiltonian viewpoint), Preprint SISSA 09/2012/M.
3. Arnold, V.I. 1978 Mathematical methods of classical mechanics, Graduate Texts in
Mathematics.
4. Berkshire, F. 1989 Lecture notes on Dynamics, Imperial College Mathematics Department.
5. Chorin, A.J. and Marsden, J.E. 1990 A mathematical introducton to fluid mechanics,
Third edition, SpringerVerlag, New York.
6. Daneri, S. and Figalli, A. 2012 Variational models for the incompresible Euler equations,

Lagrangian and Hamiltonian mechanics

59

7. Evans, L.C. 1998 Partial differential equations Graduate Studies in Mathematics, Volume 19, American Mathematical Society.
8. Jost, J. 2008 Riemannian geometry and geometric analysis, Universitext, Fifth Edition,
Springer.
9. Keener, J.P. 2000 Principles of applied mathematics: transformation and approximation, Perseus Books.
10. Krantz, S.G. 1999 How to teach mathematics, Second Edition, American Mathematical
Society.
11. Kibble, T.W.B. and Berkshire, F.H. 1996 Classical mechanics, Fourth Edition, Longman.
12. Goldstein, H. 1950 Classical mechanics, AddisonWesley.
13. Malham, S.J.A. 2014 Introductory fluid mechanics,
http://www.macs.hw.ac.uk/simonm/fluidsnotes.pdf
14. McCallum, W.G. et. al. 1997 Multivariable calculus, Wiley.
15. Marsden, J.E. and Ratiu, T.S. 1999 Introduction to mechanics and symmetry, Second
edition, Springer.
16. Montgomery, R. 2002 A tour of subRiemannian geometries, their geodesics and applications, Mathematical Surveys and Monographs, Volume 91, American Mathematical
Society.
17. Tao, T. 2010 The Euler-Arnold Equation,
http://terrytao.wordpress.com/2010/06/07/the-euler-arnold-equation/
18. http://en.wikipedia.org/wiki/Dido (Queen of Carthage)

You might also like