You are on page 1of 186

Classical mechanics and deterministic chaos

Martin Scholtz
December 20, 2010

Contents

Contents

1 Introduction
1.1 Isaac Newton and the origin of physics . . . . . . . . . . . . . . . . . . . .

5
5

2 Mathematical introduction
2.1 ODEs in Maple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2 Multivariable calculus . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2.2.1 Partial derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . .

7
7
12
15

3 Classical mechanics
3.1 Newtons laws of motion . . . . . . . . . . . .
3.2 A crash course on dierential geometry . . . .
3.2.1 Coordinates, directional derivative and
3.2.2 Polar coordinates . . . . . . . . . . . .
3.2.3 Spherical coordinates . . . . . . . . . .

. . . . . . . . .
. . . . . . . . .
transformation
. . . . . . . . .
. . . . . . . . .

. . . . . .
. . . . . .
of vectors
. . . . . .
. . . . . .

.
.
.
.
.

17
17
20
24
27
29

4 Lagranges equations
4.1 Lagranges equations . . . . . . . . . . . . .
4.1.1 Rayleighs dissipation function . . .
4.1.2 Particle in the electromagnetic eld
4.1.3 Hamiltons principle . . . . . . . . .
4.2 Lagranges equations in Maple . . . . . . . .
4.2.1 Homogeneous gravitational eld . .
4.2.2 Motion with resisting force . . . . .

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

33
33
37
38
41
45
45
51

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

.
.
.
.
.
.
.

CONTENTS

4.2.3
4.2.4
4.2.5
4.2.6

Homogeneous magnetic eld . . . .


Library Mechanics . . . . . . . . .
Additional functions of the library
Harmonic oscillator . . . . . . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

53
56
61
62

5 Hamiltons equations
5.1 Derivation of Hamiltons equation . . . . . .
5.2 Integrals of motion . . . . . . . . . . . . . . .
5.3 Variational derivation of Hamiltons equations
5.4 Canonical transformations . . . . . . . . . . .
5.5 Motion as canonical transformation . . . . . .
5.6 Hamilton-Jacobi equation . . . . . . . . . . .
5.6.1 Harmonic oscillator . . . . . . . . . . .
5.7 Hamiltons equations in Maple . . . . . . . . .
5.8 Mathematical pendulum . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.

75
75
80
83
84
87
88
91
94
97

6 Dynamical systems
6.1 Vector elds as dynamical systems
6.2 Stability of critical points . . . . .
6.3 Classication of critical points . . .
6.4 Chaotic pendulum . . . . . . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

105
105
107
108
119

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

7 Discrete systems and fractals


127
7.1 Mandelbrot set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
8 Fluid mechanics
137
8.1 Continuity equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
8.2 Eulers equation of hydrodynamics . . . . . . . . . . . . . . . . . . . . . . 141
9 Two dimensional potential ow
9.1 Potential and stream function .
9.2 Complex potential . . . . . . .
9.3 Uniform ow . . . . . . . . . .
9.4 Line source and line sink . . . .

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

.
.
.
.

147
147
150
152
154

A Maple: An introduction
A.1 First steps . . . . . . . . . . . . . . .
A.2 Overview . . . . . . . . . . . . . . .
A.2.1 Types . . . . . . . . . . . . .
A.2.2 Procedures in Maple . . . . .
A.3 Vector Calculus . . . . . . . . . . . .
A.3.1 Basic operations with vectors

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

.
.
.
.
.
.

159
159
167
169
172
173
173

.
.
.
.

.
.
.
.

B Eigenvalues and eigenvectors

177

C Numerical methods for solving dierential equations

179

D Laplace transform
181
D.1 Inverse Laplace transform . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

CONTENTS

D.2 Laplace transform and dierential equations . . . . . . . . . . . . . . . . . 185

Chapter 1

Introduction

The subject of this book is so called deterministic chaos. What is chaos and what is its
role in our understanding of the Nature? How can chaos be deterministic? What other
kinds of chaos do exist? How can chaos appear in exact sciences and is it of any practical
use? In this introductory chapter we will try to answer these more general questions.
Intuitively we feel that the word chaos is an opposite to order, chaotic system is
system without rules and laws. This word is derived from ancient Greek word
o,
where it originally meant the initial state of the Universe. Later it acquired several
dierent but related meanings: space, darkness, depth or abyss. The meaning of chaos
in mathematics and physics is, however, more close to disorder. Chaotic system is
very sensitive to the initial conditions, it is dicult or even impossible to predict its
behaviour. Such systems can be found everywhere in the Nature and we will see a lot
of examples. Important and still not completely solved question is: if, as we believe, the
world is described by precise mathematical and physical laws, how can any sort of chaos
emerge? It is a deep question and the answer is even deeper. The attitude we advocate in
this book is that the understanding of chaos in 20th century belongs to great revolutions
in physics. Why? Let us tell something about the other revolutions, then we can fully
appreciate the nature of chaos.

1.1

Isaac Newton and the origin of physics

Roughly speaking, physical theories can be divided into two large groups. Fundamental
theories are trying to describe the very basic laws of Nature. They are trying to understand gravitational forces, the structure of atoms, the elds, the interactions between
matter and elds, thery are studying properties like energy, mass, electric charge, etc.
In other words, fundamental theories are looking for the equations which the world is
governed by. We can say that the motivation for the fundamental research is purely
emotional: some people want to understand the world we live in, and their desire is so
strong that they spend all their lives by thinking about the basic laws of physics. And
they are so clever or ingenious that they also nd the answers, they are able to formulate
sophisticated theories, full of esoteric mathematics and strange ideas. It is a kind of
miracle that these theories work and describe our Universe with fascinating precision.
5

CHAPTER 1. INTRODUCTION

On the other hand, applied physics is using fundamental theories to describe real,
non-idealized systems in the Nature. One thing is to understand the interaction between
particles or quantization of energy, the other thing is to understand the piece of iron
consisting of millions of particles. One thing is to understand the law of gravitational
force, the other thing is to describe the formation of galaxies or explain the stability
of the Solar system. The purpose of applied research is to solve equations discovered
by fundamental theories for real systems and practical situations. We can say that the
motivation for applied research is practical: we want to use our fundamental theories for
improving the technology. We want faster computers, more reliable cars, more precise
electronic navigating systems, safer aeroplanes, etc. It is worth to say that applied
research would be impossible without the fundamental one. The theory of chaos is one
of the rare cases, where fundamental and practical questions meet each other in the
same theory. This introductory chapter is a brief review of fundamental theories which
changed our picture of the Universe.
The common feature of all revolutions is that they are connected with introducing
(or even invention of) new mathematical formalism.

Chapter 2

Mathematical introduction

2.1

ODEs in Maple

In this section we analyze few examples of dierential equations we meet in physics.


These equations have exact solutions and we will derive them both by hand and by
Maple.
Example 1. Free-fall of the body with constant acceleration g (pointing downwards)
is described by equation y = g, where y = y(t) is the altitude of the body. The
assumption of constant acceleration is an idealization, because the acclereation actualy
depends on the altitude. But since the change of gravitational acceleration is very small
in usual conditions, this simplication is valid and does not aect the result too much. On
the other hand, free-falling body experiences the resisting force pointing upwards, which
slows the motion of the body. This force is not negligible even in simple experiments.
The more realistic equation of falling body therefore must include also the resistance due
to friction between the surface of a body and the air. In the simplest model the resisting
force is proportional to the velocity of falling body. Corresponding equation is

y = g y.

We added a new term y,


where is some coecient of the friction. The resisting force
is then x,
i.e. it is proportional to the velocity and has an opposite direction.
To solve this equation we rst rewrite it as

y + y = g.
It is linear equation with constant coecient with non-zero right hand side. First we
look for the solution of homogeneous equation, i.e. without right hand side:

y + y = 0.
7

CHAPTER 2. MATHEMATICAL INTRODUCTION

Homogeneous linear equations with constant coecients can always be solved by setting
y = e t and inserting this ansatz into the equation. After cancelling common term e t
we get an algebraic equation
2 + = 0.
This is a quadratic equation and has two roots, in this case

1 = 0,

2 = .

The general solution of homogeneous equation therefore is


yh = C1 + C2 e t .
According to mathematical theorems, the general solution of inhomogeneous equation
(with r.h.s.) is the sum of general homogeneous solution and arbitrary particular solution
of full equation. So far, we have obtained the rst of these ingredients. Particular solution
of inhomogeneous equation y + y = g can be found on the physical ground. We expect
that falling body will accelerate and the resisting force will increase until the gravitational
and the resisting force become equal. In this equilibrium state the acceleration is zero
and the body moves uniformly. Written in symbols, y = 0 (acceleration is zero). This
equation integrates to

y = t + ,
where and are integration constants. Without loss of generality we set = 0 (why
can we do this?). Inserting ansatz x = t into inhomogeneous equation we nd
=

g
.

The general solution of equation y + y = g therefore reads


y(t) = C1 + C2 et

gt
.

Now we impose initial conditions. Position at time t = 0 will be denoted by y0 = y(0).


It is natural to assume that the in the beggining, the body is at rest, i.e. y(0)

= 0. These
conditions lead to equations
C1 + C2 = 0, C2

g
= 0,

so that

C1 = y0 +

g
,
2

C2 =

g
.
2

2.1. ODES IN MAPLE

Finally, we can write the solution in the form

y(t) = y0 +

)
g (
g
1 e t
t.
2

We know that if the coecient = 0, so there is no resisting force, the solution is


y=0 = y0

1 2
gt .
2

Our solution is formally very dierent. We cannot set = 0 as we get non-dened


expression. However, it is possible to show that the limit

lim y(t) = y=0 (t).

One way is to use the Taylor expansion of the exponential function,


ex = 1 + x +

1 2
1 3
x +
x + .
2!
3!

Then
[
(
)]
( 3)
g
1 2 2
g
1

t
+

t
+
O

t
2

1 2
= y0 g t + O () .
2

y(t) =

y0 +

Taking limit 0 we nd
lim y(t) = y0

1 2
gt .
2

Thus, in the limit of zero friction we recover the solution for free-fall.
Let us now turn to nding the solution using Maple. First we dene variable representing the equation we want to solve.
eqs := D[1,1](y)(t) = -g - alpha*(D(y)(t));
Symbol D represents derivative. It can be applied to function of one or more variables. If
we need the rst derivative of one-variable function we simply write D(y)(t). If we need
second derivative, we use D[1,1](y)(t), which means that we dierentiate function y(t)
twice with respect to rst variable (actually there is only one variable). Next we dene
initial conditions
ic := y(0)=y[0], D(y)(0)=0;
which is equivalent of

y(0) = y0 , y(0)

= 0.
Now we can solve equations eqs for initial conditions ic by

10

CHAPTER 2. MATHEMATICAL INTRODUCTION

sol := dsolve( {eqs, ic} , {y(t)});


By this command we say that we are solving the list of equations between curled brackets
with respect to variable y(t). The solution is stored in variable sol. Check that this
solution is identical with the solution we have found above. Now we want to extract the
solution from the variable sol and plot it. If we type
sol;
Maple displays the expression of the form
y(t) = (solution)
We need only the right hand side, which can be extracted by the function rhs(sol). We
dene new function Y (t) representing our solution by
Y := unapply( rhs(sol), t);
Function unapply(expr, var) analyzes the expression expr, replaces all occurences of variable var by an abstract variable and returns the function of this variable. Thus, Y is now
a function of t dened by the right hand side of solution sol. If we type simply
Y(t);
Maple displays the solution of our equation. We can check that Y (t) reduces to the
solution for the free-fall by
limit(Y(t), alpha=0);
Finally, we can plot the solution. To do this, we must assign numerical values to
constants y0 , g and . We have chosen values y0 = 100, g = 10, = 1. Following code
displays the graph of the solution:
alpha:=1; g:=10; y[0] := 100;
with(plots):
plot( [Y(t)], t=0..10);

Example 2. Probably the simplest non-trivial dierential equation used in physics is


that of radioactive decay. Atoms consist of two qualitatively distinct parts: the nucleus
and electron cloud surrounding the nucleus. The electrons are negatively charged and
are attracted to positively charged nucleus. Nucleus consists of protons (positive charge)
and neutrons (zero charge). Since protons with positive charge are concetrated in very
small volume, they experience very strong repulsive electromagnetic interaction. There is,
however, even stronger nuclear interaction between nucleons (protons+neutrons) which
is attractive and keeps the nucleus in stable form. This force is stronger than electromagnetic one, but it acts only on very small distances. That is, one nucleon is attracting
only a few of other nucleons close to it, but does not act on more distant nucleons. Thus,
if the nucleus is too big, nuclear force is not strong enough to keep the nucleus stable
and some nucleons can spontaneously leave the nucleus. This phenomenon is known as

2.1. ODES IN MAPLE

11

radioactive decay. Since the chemical properties of atoms are determined by the number
of protons (and therefore the number of electrons of neutral atom), emission of the nucleons leads to the transmutation of the atom. If we have certain amount of radioactive
material, this amount is decreasing by radioactive decay.
The emission of nucleons is spontaneous and has purely probabilistic character. Theory cannot predict the time of emission. It is an example of quantum chaos, where the
impossibility of prediction does not come from our lack of knowledge, but is an essential property of quantum system. However, if we have a large number of radioactive
atoms, which is usually the case, we can describe radioactive decay by phenomenological
equation

dN
= N (t).
dt
Here N = N (t) is the number of radioactive particles and is constant. It is connected
to the probability of decay of one individual particle. The equation then says that the
bigger is number of particles, the bigger is probability of their decay.
Excercise: solve the equation of radioactive decay by hand and then using Maple.
What are initial conditions for this equation? Plot the solution for arbitrarily chosen
initial conditions.
Example 3. In this book we will extensively discuss properties of harmonic oscillator
and its generalizations. Harmonic oscillator is, for example, an idealized spring oscillating
about its equilibrium position. As in the previous case, we can obtain more realistic
model by introducing a friction term. Harmonic oscillator with resisting force is called
damped oscillator. Without explanation, which will come later in the text, we claim that
equation of damped oscillator is

x
+ x + 2 x = 0.
Exercise: Solve this equation using Maple(later we will see how to obtain the solution by
hand) and plot the solution. An example of the result can be seen on gure 2.1.
Example 4. Consider charged particle in homogeneou magnetic eld. Magnetic eld is
described by constant vector B. Particle moving with velocity v feels the magnetic force

F = e v B,
where e is the charge of particle. To simplify the problem, we can assume without loss
of generality that B has direction of zaxis, i.e. B = (0, 0, B).
Exercise. Derive the equations of motion and solve them in Maple. What are initial
conditions for these equations? For which initial conditions the trajectory is straight line
and for which it is a spiral?

12

CHAPTER 2. MATHEMATICAL INTRODUCTION

Figure 2.1: Solution for damped oscillator with x0 = 2, = 2, = 1, t (0, 10).

2.2

Multivariable calculus

In mathematics and physics we often work with functions depending on more than one
variable. The trivial example is the volume of rectangular cuboid. If the lengths of edges
are a, b and c, the volume is simply

V (a, b, c) = a b c.
Thus, the volume is function of three variables. Another example can be the distance
of the point with coordinates (x, y) from the origin of the coordinate system,

(x, y) =

x2 + y 2 .

We know that the graph of one-variable function f is a curve in the plane, the set of
points (x, f (x)). Here, x is an independent variable and f (x) is determined by the value
of x. What is the graph of two-variables function? It is the set of points (x, y, f (x, y)).
Variables x and y are independent and all ordered pairs of (x, y) form a plane. To
each point (x, y) of the plane we assign the point (x, y, f (x, y)) in the three-dimensional
space, see gure 2.2. Thus, the points of the graph constitute a two-dimensional surface
embedded into three-dimensional space. To draw such a surface in Maple we can use
follwing simple code, see gure 2.3.
with(plots):
plot3d( sin(x)*cos(y)/(1+x^2+y^2), x=-3..3, y=-3..3,

13

2.2. MULTIVARIABLE CALCULUS

(x, y, f (x, y))

y
(x, y)

Figure 2.2: The graph of function f = f (x, y) is a 2D-surface in 3D-space.

style=patchnogrid, axes = normal,


shading=zgrayscale, lightmodel=light2);
Details about the command plot3d can be found in appendix (A). Similarly, graph of
function of n variables is ndimensional surfce embedded into n + 1dimensional space.
It is therefore impossible to plot graphs of functions of more than two variables. In such
cases we must x n 2 variables and plot the graph of remaining 2 variables.
Consider, for example, isotropic wave propagating in the plane x, y. Such a wave
depends on time and is described by the function of two variables
(
r )
f (t, r) = cos (t ) ,
c
where t is time, r is the distance from the origin, is the angular frequency of the wave
and c is the speed of wave. On the other hand, r is itself a function of coordinates x and
y:

r(x, y) =

x2 + y 2 .

The wave is then in fact function of three variables,


(
)
r(x, y)
f (t, x, y) = f (t, r(x, y)) = cos (t
) .
c
The graph of function f is 3dimensional surface embedded into 4dimensional surface
and encapsulates the wave in the plane for all instants of time. If we want to plot the
wave, we must x the time, say t = 0, and plot the function f (0, x, y), which is already
feasible. Then we choose some other time, say t = 1, and plot the graph of f (1, x, y),
etc. See gures 2.4 and 2.5.

14

CHAPTER 2. MATHEMATICAL INTRODUCTION

Figure 2.3: The graph of function

sin x sin y
1+x2 +y 2 .

Figure 2.4: The graph of wave f (0, x, y) for = 1/2, c = 1.

2.2. MULTIVARIABLE CALCULUS

15

Figure 2.5: Graph of the same wave at later time: f (5, x, y).

2.2.1

Partial derivatives

The notion of derivative naturally extends to functions of more variables. We start with
geometric motivation. Consider function f of n variables x1 , x2 , . . . xn . The ntuple of
variables xi can be understood as a components of some vector

x = (x1 , x2 , . . . xn ) .
In other words, xi are coordinates of vector x with respect to some xed Cartesian
coordinate system. Then we can treat function f as function of vector x rather than
function of n numbers,

f = f (x).
For n = 2 or n = 3 we often write also x = (x, y) and x = (x, y, z). As an example we
will discuss function of two variables

f (x) = f (x, y) = x2 + y 2 .

Chapter 3

Classical mechanics

3.1

Newtons laws of motion

In this chapter we start with reformulation of non-relativistic classical, i.e. Newtonian,


dynamics. In Newtonian dynamics, physical bodies or idealized point particles are moving and interacting according to Newtons laws of motion. Newton himself formulated
them in his Mathematical Principles of Natural Philosophy as follows:
1. Law of inertia
Every body persists in its state of being at rest or of moving uniformly straight
forward, except insofar as it is compelled to change its state by force impressed.
2. Law of force
The alteration of motion is ever proportional to the motive force impressed; and is
made in the direction of the right line in which that force is impressed.
3. Law of action and reaction
To every action there is always an equal and opposite reaction: or the forces of two
bodies on each other are always equal and are directed in opposite directions.
These laws involve important notions of force, momentum and mass and we assume that
reader is familiar with them.
Consider a point particle of mass m. Choosing some xed point O (origin) in the
space, we can describe motion of the particle by position vector (radius vector) r. Position
vector is time-dependent if the body is moving with respect to the origin O: r = r(t).
Trajectory of the point particle is the set of all end-points of the position vector in some
time interval (see g. 3.1). Velocity is dened as derivative of r(t) with respect to time:

v(t) =

dr
.
dt

Total derivative with respect to time will be often denoted by dot, so that the last
equation is briey written as v = r(t)
= r.
Sometimes it is useful to parametrize position
vector by other parameter than time, for example by the length of the trajectory. In
17

18

CHAPTER 3. CLASSICAL MECHANICS

trajectory

(position at time t)

v(t)
r(t)

(velocity)

(radius vector)

O(origin)

Figure 3.1:

such cases, dot means the total derivative of arbitrary function of one variable with
respect to its argument.
Similarly, second derivative with respect to time will be denoted by double-dot. The
most important example is the denition of acceleration, which is the second derivative
of position vector with respect to time:

a(t) =

d2 r
dv

=
= r = v.
dt2
dt

Quantities r, v and a are so called kinematical quantities. They describe the motion
independently of the causes and reasons of motion. According to Aristotle, the motion is
caused by forces, but this is wrong. Aristotles opinion was so inuential that it stopped
the progress in physics for the next two thousands years. Experimental research of Galileo
Galilei, his discovery of the law of inertia, and nally the grand work of Isaac Newton
founded the basis of modern physics.
Why is Aristotles point of view wrong? Well, we have to clarify what we mean by
the statement the motion is caused by the forces. The law of inertia says that if there
is no force, the body will move uniformly along the straight line. We need the force
to change the motion, not to preserve it. Therefore there is no connection between the
force and velocity, but there must be a relation between the force and acceleration. This
crucial point was missed by Aristotle.
The precise form of the relation between force and acceleration is given by Newtons
second law, the law of force. We expect that acceleration has the same direction like the
force, and that bigger force will cause bigger acceleration. Experience teaches us that
we need bigger force to change the motion of heavier bodies, so the acceleration must
be inversely proportional to the mass. This simple consideration directly leads us to the
suggestion

a =

F
,
m

where m is the mass of the body and F is the force acting on the body. The last formula
is a mathematical expression of Newtons second law and the experiments show that it
is in perfect accordance with the reality.

3.1. NEWTONS LAWS OF MOTION

19

We can formulate this law in slightly dierent form by dening the (linear) momentum
p of the body:
p = m v.
Momentum incorporates both the measure of the inertia, mass, and the state of motion,
velocity. The force can then be dened as the change of the momentum in time, i.e.

F =

dp
.
dt

If the mass of the body is constant in time, we have p = mv = ma, which is again
Newtons law

F = m a.
Here we arrived at some kind of circular argument. Acceleration is determined by
the force. What is the force? It is the reason of acceleration. What we need is some
independent denition of the force. Our present denition allows us to calculate the force
if we know the acceleration caused by it. But in order to predict the acceleration we have
to calculate the force in an independent way, i.e. we have to understand what is the
source of the force. As we believe today, there are only four fundamental forces in the
Nature: gravitational, electromagnetic, and weak and strong nuclear force. Historically,
it was gravitational force which was rst correctly described by mathematical equations
and it was again Newton who did it. In his theory of gravitation, mass is the source of
gravitational force. Two point (or perfectly spherical) bodies with masses m1 and m2 ,
respectively, act on each other by the atractive gravitational force of magnitude given by
Newtons gravitational law :

m1 m2
,
r2

(3.1)

where r is the distance between bodies and is gravitational constant, a fundamental


constant of Nature. Electromagnetic interaction was described much later by James Clerk
Maxwell in terms of eld theory. Afterwards, the notion of eld appeared to be more
appropriate for desription of the interactions than the notion of forces. In 1916 Albert
Einstein formulated his general theory of relativity which is essentially the eld theory
of gravitation. Weak and strong interactions have been investigated during nineteen
seventies.
Notice, however, that the law (3.1) satises our requirements. Namely, it allows us to
calculate gravitational forces and then insert them into Newtons law and calculate the
acceleration of the bodies, on which gravitational forces act. If we know their positions
and velocities at one instance of time, we can solve the equations of motion and therefore
calculate the trajectories of all bodies.
We can summarize classical Newtonian mechanics in the following way. Kinematics
is the branch of mechanics describing the motion of body in terms of position vector r,
velocity v and acceleration a. Dynamics then describes how forces acting on a body
determine its acceleration. And nally, we have gravitational law which says how big the
forces are and what are their directions.

20

CHAPTER 3. CLASSICAL MECHANICS

P(x,y)

Py (0,y)

P(x,0)

Figure 3.2:

3.2

A crash course on dierential geometry

Let us return to Newtons second law in the form

F = m a.
This abstract equation has clear physical meaning explained above, but as it stands, it is
almost useless for practical calculations. Quantities F and a are vectors, i.e. they have
not only magnitude but also the direction. But how are we to describe the direction of,
say, acceleration? Words like left, right, slightly higher have their meanings only
with respect to something. Physical space is three-dimensional and therefore we have
to assign three coordinates with each point to obtain an unambiguous correspondence
between the physical space and mathematical space of ordered triples. Then we can
describe the positions or the directions of vectors in terms of ordered triples and apply
mathematical methods.
Perhaps the rst mathematician who realized that the space can be identied with
ordered triples was Rene Descartes (Renatus Cartesius in Latin). To simplify following
discussion we restrict our considerations to the two-dimensional plane (denoted E 2 ) instead of three-dimensional space (E 3 ) , as there is no essential dierence between them
at this stage. The most natural choice of the coordinate system is so called Cartesian
coordinate system, see g. 3.2. In this system there is a xed origin O and two orthogonal straight lines, axes, intersecting in O. One of axes is called x and the second one
is y. Let P E 2 be an arbitrary point lying in the plane. According to the parallel
postulate of Euclidean geometry, there exists exactly one line intersecting the point P
and parallel to xaxis. This line is necessarily orthogonal to yaxis and intersects it
in the point denoted Py . Similarly, there exists exactly one line intersecting the point
P and parallel to yaxis, which is orthogonal to xaxis and intersects it in point Px .
In this notation, letter E stands for Euclidean. Euclidean space of dimension n is denoted by E n .
By Euclidean space we mean at space where Euclids axioms of geometry, especially the fth one,
parallel postulate, hold.

3.2. A CRASH COURSE ON DIFFERENTIAL GEOMETRY

21

We dene the Cartesian coordinates of the point P as the ordered pair of real numbers
(x, y), where x = |P Py | and y = |P Px | (here |AB| means the distance of points A and
B). This is all quite trivial and without any doubts the reader is very familiar with the
Cartesian coordinate systems. However, there are some subtleties hidden in the above
construction, although we will not discuss all of them here.
So far, we constructed a coordinate system which allows us to identify the points
of plane E 2 and ordered pairs (x, y) of real numbers. All possible ordered pairs (x, y)
form a set R2 = R R. Operation is, not by accident, called Cartesian product.
Euclidean space E n is so called ane space, while Rn forms linear or vector space,
and coordinate system is their mutual identication. Then we can add and subtract
two vectors or add a vector to a point in usual way. The specic feature of Cartesian
coordinate system is that if we move the vector without changing its direction, also
its coordinates remain unchanged. And it is a specic feature of Euclidean space that
Cartesian coordinate system can be constructed. The geometry of Euclidean space is
encapsulated in Pythagoras theorem. Let P E 2 be an arbitrary point in the Euclidean
plane and let (x, y) R2 be the Cartesian coordinates of P with respect to some xed
Cartesian coordinate system with the origin O. Pythagoras theorem then states that
the distance of points O and P is given by formula

x2 + y 2 .

|OP | =

In an ndimensional Euclidean space E n we can introduce Cartesian coordinates


x1 , x2 , . . . xn . These coordinates form the position vector

r = (x1 , x2 , . . . xn ),
whose components are xi , where i = 1, 2, . . . n. The length or magnitude or norm r of
the position vector is, according to Pythagoras theorem, given by

r2 = x21 + x22 + . . . + x2n .

(3.2)

This can be given into simpler and more inspiring form. Expression (3.2) is a quadratic
form in variables xi . We dene the unit matrix of type n n

1n =

1 0
0 1
..
.
0 0

..
.
...

0
.

Its components are given by so-called Kronecker symbol or Kroneckcer delta:


{
ij =

1 for i = j
0 for i = j

}
.

The norm of vector can be then written in component form:

22

CHAPTER 3. CLASSICAL MECHANICS

r2

n
n

ij xi xj .

(3.3)

i=1 j=1

Whenever possible, we will use so-called Einsteins summation convention. In (3.3)


we sum through two indices i and j. Similar expressions appear very frequently and it
is annoying to write symbol so often. The Einstein convention is that if some index
i, say, appears in the expression exactly twice, the summation through it is assumed
automatically. For example

ai bi =

ai bi = a1 b1 + a2 b2 + + an bn .

i=1

Such index is called dummy index and, obviously, it can be renamed without changing
the meaning of an expression, e.g. ai bi = aj bj . In this convention, we can write the norm
of a vector simply as

r2 = ij xi xj .
In this double sum (through i and j) there are only terms with i = j because of Kronecker
symbol. Thus, we can write

r2 = xi xi .
Einsteins convention is very useful and helpful and it is being used widely in mathematical physics and dierential geometry. Here we use its simplied version when there
is no dierence between covariant and contravariant components of vectors.
So far, we have introduced one-to-one correspondence between the Euclidean space E n
and the space of ordered ntuple Rn . This correspondence is not unique, as it depends
on the choice of the axes. We say that the identication of E n and Rn is not canonical
which means that there is no preferred choice. It is thus important to understand how
the components of vectors tranform under the change of the coordinate system. Before
examining this general question we must say something about the bases of vector spaces.
The fact that E n is ndimensional can be expressed also as a statement that there
exist n linearly independent vectors. Vectors v1 , . . . vn are said to be linearly dependent,
if there exist coecients a 1, . . . an , at least one of them non-zero, for which

a1 v1 + + an vn = 0.

(3.4)

In other words, if vectors are linearly dependent, one of these vectors can be written as a
linear combination of the others. Per contra, vectors are linearly independent if equation
(3.4) holds only for a1 = = an = 0, i.e. if none of the vectors can be expressed as a
combination of the others.

3.2. A CRASH COURSE ON DIFFERENTIAL GEOMETRY

23

Thus, in E n there exist n linearly independent vectors v1 , . . . vn . An arbitrary vector


u is then a linear combination of these vectors:
u = u1 v1 + . . . + un vn = ui vi .
Vectors vi form a basis of E n (as a vector space) and ui are components of vector u with
respect to the basis vi .
It is clear that the basis is not unique, because any set of n linearly independent
vectors can serve as a basis. In xed Cartesian coordinate system, however, there is a
canonical, preferred choice of the basis. We simply take ei to be the unit vector tangent
to ith axis. Coordinates of these vectors read

e1 = (1, 0, . . . , 0) ,

e2 = (0, 1, . . . , 0) ,

ei = (0, 0, . . . 1, 0, . . . 0) .

(3.5)

This canonical basis has two important properties. First, vectors ei are normalized to
unity, i.e.

ei 2 = 1.
Second, they are orthogonal to each other, i.e.

ei ej = 0,

for i = j.

where the dot means ordinary scalar product. Basis with these properties is called
orthonormal and the condition of orthonormality can be conveniently formulated using
the Kronecker symbol:

ei ej = ij .

(3.6)

Now, since vectors ei form a basis, any vector u can be written as their linear combination,

u = u i ei ,
where ui are usual Cartesian components of vector u. They can be expressed invariantly
as scalar products of ei and u, since the following holds:

u ei = uj ej ei = uj ij = ui .

24

3.2.1

CHAPTER 3. CLASSICAL MECHANICS

Coordinates, directional derivative and transformation of vectors

Cartesian coordinates, while always available in Euclidean spaces, are not always useful
for particular problems. For example, as we will see in the chapter about mathematical
pendulum, it is much more convenient to describe the position of the pendulum by the
angle of deection, than by two Cartesian coordinates x and y. In fact, the choice of
coordinate system has no physical meaning. All coordinates systems are equivalently
good in the sense that reality does not depend on the choice of coordinates. But some
coordinates can be more useful, i.e. the problem can have simpler formulation in some
particular coordinates. Thus, we must be able to switch from one coordinate system into
the other freely.
As in the previous section and in the entire textbook, we denote original Cartesian
coordinates by xi , where i = 1, . . . n, n being the dimension of Euclidean space. Cartesian
coordinates are called also rectilinear coordinates. Next we introduce arbitrary curvilinear
coordinates or generalized coordinates which will be denoted by qa , a = 1, . . . n. As a
special case, qa can be again Cartesian coordinates, for example rotated by some angle
about some axis. Generalized coordinates depend on original Cartesian coordinates:
qa = qa (x).
In addition, if the description by qa is to be equivalent to description by xi , we must
assume the existence of inverse coordinate transformation
xi = xi (q).
This is again a delicate issue and leads to a concept of manifold. We will return to this
question later, but for the moment, we assume that both direct and inverse transformation exist and they are regular.
Since qa are functions of xi and xi are again functions of qa , we can write
qa = qa (x(q)).
Dierentiate this relation with respect to qb and use the chain rule for partial derivatives
to nd
qa
qa xi
=
.
qb
xi qb
On the other hand, coordinates qa must be independent on each other, so that
qa
= ab .
qb
We thus arrive at important identity
qa xi
xi qb

= ab .

(3.7)

Similarly, considering identity xi = xi (q(x)) it is possible to derive


xi qa
qa xj

= ij .

(3.8)

We have established the coordinate transformation from Cartesian coordinates xi to


generalized coordinates qa . Next we investigate how several objects or their components

3.2. A CRASH COURSE ON DIFFERENTIAL GEOMETRY

25

change under coordinate transformation. The simplest objects are scalars, i.e. singlevalued functions. If f = f (x) is the function of Cartesian coordinates, we can dene new
function f = f(q) simply by
f(q) = f (x(q)).
In other words, scalar functions do not change under cordinate transformation, we just
have to express original Cartesian coordinates as functions of new coordinates qa .
The transformation of vectors is not that trivial. One way how to nd the rule for
transformation of vector components is through the notion of directional derivative. Let
u be a vector with Cartesian components ui with respect to orthonormal basis ei :
u = ui ei .
Moreover, let f = f (x) be a scalar function of Cartesian coordinates. Directional derivative of f , i.e. the derivative of f in the direction of vector u, is dened as
u f = ui i f

i=1

ui

f
u1 x f + u2 y f + .
xi

Introducing operator
= (x , y , ) ,
directional derivative can be written formally as a scalar product of u and (pronounced
nabla):
u f = u f.
Relation
u f = ui i f
allows us to nd components of u with respect to generalized coordinates, for the value
of u f cannot depend on coordinates; it is an invariant with direct geometrical meaning. Imagine that the scalar funtion is temperature. Then you can measure how the
temperature changes in some direction u. The change of temperature between two close
points is denitely coordinate independent.
So, using the chain rule we can write
u f = u i

f
f qa
f
= ui
= ua
ua a f,
xi
qa xi
qa

where we denoted
ua = ui

qa
.
xi

Now we have two formally identical expressions for the derivative of f in the direction
of u:
u f = ui i f = ua a f.

26

CHAPTER 3. CLASSICAL MECHANICS

In the rst, ui is component of u with respect to Cartesian coordinates xi , and i is


derivative with respect to xi . In the second expression, a is derivative with respect to
generalized coordinate qa . Thus, ua must be component of u with respect to coordinates
qa .
To conclude, under transformation xi 7 qa , components ui of arbitrary vector u
transform according to rule
ui

7 ua = ui

qa
.
xi

(3.9)

Later we will meet even more general quantities than vectors tensors. For example, tensor of second rank can be represented by matrix tij , whose elements transform
according to
tij

tab = tij

qa qb
.
xi xj

(3.10)

Let us return to transformation rule for vectors (3.9). Inverse transformation can be
obtained by multiplying equation (3.9) with xj /qa and using identity (3.8):
ua

xj
= ui ij = uj .
qa

The inverse transformation thus reads


ua 7 ui = ua

xi
.
qa

Vector u can be then written as


u = ui ei = ua

xi
ei .
qa

We can dene new basis adapted to generalized coordinates qa by


ea

xi
ei ,
qa

(3.11)

so that vector u with respect to new basis is


u = ua ea .
As in the previous section we assume that Cartesian basis ir orthonormal, i.e. it satises
relations of orthonormality
ei ej = ij .
New basis, however, is not necessarily normalized. For we have
ea eb =

xi xj
xi xj
xi xi
ei ej =
ij =
.
qa qb
qa qb
qa qb

So, the properties of basis ea depend on the properties of coordinate transformation and
we cannot say more about them in general:
ea eb

xi xi
.
qa qb

(3.12)

3.2. A CRASH COURSE ON DIFFERENTIAL GEOMETRY

27

r sin
r

r cos

Figure 3.3: Polar coordinates

3.2.2

Polar coordinates

Polar coordinates (r, ) are dened in the Euclidean plane with Cartesian coordinates
(x, y) via relations

x = r cos ,

y = r sin .

(3.13)

Coordinate r is the distance of the point from the origin, coordinate is the angle between
xaxis and the position vector of the point, see gure (3.3). Inverse transformation reads

r =

x2 + y 2 ,

y
= arctan ,
x

(3.14)

as can be easily veried. Straightforward calculation shows that


r
x
=
,
x
r

y
= 2,
x
r

r
y
=
,
y
r

x
= 2.
y
r

(3.15)

Furthermore, if all coordinates are functions of time,

r(t)

(t)

=
=

r
x

x(t)

x +

r
y

x x + y y
,
r2
x y y x
.
=
r2

(3.16)

Imagine point moving in the plane. Its position vector is r(t) = (x(t), y(t)) and it is

time dependent. The velocity is then v(t) = r(t).


Written in Cartesian coordinates, the
components of velocity read

28

CHAPTER 3. CLASSICAL MECHANICS

v = vx ex + vy ey = x ex + y ey .
Cartesian coordinates will be denoted by xi , i = 1, 2, and polar coordinates by qa ,
a = 1, 2. Similarly, components of vectors with respect to Cartesian coordinates will
carry indices i, j, . . . while components with respect to polar coordinates will carry indices
a, b, . . . . Thus, polar components of the velocity are

va =

qa
qa dxi
vi =
xi
xi dt

dqa
qa .
dt

We can see that polar components of the velocity are simply

vr = r,

v = .

The magnitude of velocity expressed in polar coordinates is


v 2 = vx2 + vy2 = r 2 + r2 2 ,
where
vx = r cos r sin ,

vy = r sin + r cos .

Angular momentum with respect to the origin is dened as


l = r p,
where r is the position vector and p is linear momentum with Cartesian coordinates

p = (px , py , pz ) = m (x,
y,
z).

In the plane, however, zcoordinate of r and p is zero (or any other constant). Angular
momentum, on the other hand, is orthogonal to the plane and has only zcoordinate lz :
l z = x p y y px .
In polar coordinates we nd

lz = m r2 .

If the particle is moving uniformly along the circle, is the angular velocity and v = r.
Angular momentum is then given by

lz = m v r,

29

3.2. A CRASH COURSE ON DIFFERENTIAL GEOMETRY

which is familiar relation from elementray physics.


Finally we establish convenient vector basis adapted to polar coordinates. Let us
dene, following (3.11),
er

xi
x
y
ei =
e1 +
e2 = cos e1 + sin e2 ,
r
r
r
xi
x
y
ei =
e1 +
e2 = r sin e1 + r cos e2 ,

where e1 and e2 are vectors of standard basis normalized by


ei ej = ij .
By direct calculation we can nd that
(
ea eb =

1 0
0 r2

)
.

This means that ea is orthogonal, i.e. er e = 0, but not orthonormal, because


e e = r2 = 1.
Since it is more convenient to work with orthonormal basis, we redene our basis as
er

cos e1 + sin e2 ,

= sin e1 + cos e2 .

We can see that new basis at each point is merely Cartesian basis ei rotated by angle .
Obviously, inverse transformation is rotation of ea by angle , so that
e1

cos er sin e ,

e2

sin er + cos e .

These relations can be obtained by direct calculation. Components of arbitrary vector


u with respect to basis ea are
vr

= u1 cos + u2 sin ,

u1 sin + u2 cos .

(3.17)

Nabla operator in polar coordinates reads


= er

3.2.3

1
+ e
.
r
r

(3.18)

Spherical coordinates

Spherical coordinates (r, , ) are dened in Euclidean three-dimensional space. Radial


coordinate r is again the distance of the point r = (x, y, z) from the origin. Angle is the
angle betwwen zaxis and the position vector r. Finally, angle is the angle between
the projection of r into plane z = 0 and the xaxis, see gure 3.4. Relations between
Cartesian and spherical coordinates are given by following equations:

30

CHAPTER 3. CLASSICAL MECHANICS

x = r sin cos ,
y

= r sin sin ,

= r cos .

(3.19)

The inverse transformation is

x2 + y 2 + z 2 ,

x2 + y 2
= arcsin
2
x + y2 + z2
y
= arctan .
x
r

z
= arccos
,
x2 + y 2 + z 2
(3.20)

We will need also partial derivatives. Derivatives xi /qa are easy from the denition of spherical cordinates. Since we have also inverse relations, we can compute also
derivatives qa /xi . It is, however, instructive to see an alternative way. Jacobi matrix
of the coordinate transformation qa 7 xi is dened as

Jia

xi
=
qa

sin cos r cos cos r sin sin


(x, y, z)
=
= sin sin r cos sin r sin cos .
(r, , )
cos
r sin
0

Let J be the Jacobi matrix of inverse transformation xi 7 qa :


qa
Jai =
xi

(r, , )
.
(x, y, z)

Composition of two considered transformations must be an identity, which is also expressed by basic relation for partial derivatives
xi qa
qa xj

= ij ,

or, in matrix form,


J J = 13 ,
where 13 is unity matrix 3 3. Thus, the matrix J we are looking form, is simply the
inverse of the rst Jacobi matrix J:

J = J 1 =

cos sin

sin sin

cos cos
r

rsin
sin

cos sin
r
cos
r sin

cos
sinr .
0

Magnitude of velocity in spherical coordinates reads

31

3.2. A CRASH COURSE ON DIFFERENTIAL GEOMETRY

(x, y, z)

Figure 3.4: Spherical coordinates.

(
)
v 2 = r 2 + r2 2 + sin2 2 .
Since we are now in three dimension, angular momentum has all three components:

ly

(
)
= y pz z py = m r2 sin + cos sin cos ,
(
)
= z px x pz = m r2 cos + cos sin sin ,

lz

= x py y px = m r2 sin2 .

lx

(3.21)

This looks quite complicated. Things get better for spherical components of l. Components transform according to

la =

qa
li ,
xi

which implies

lr

= 0,

= m r sin ,
r
.
= m
sin

Magnitude of l in spherical coordinates reads


)
(
l2 = m r4 2 + sin2 2 .

(3.22)

Chapter 4

Lagranges equations

4.1

Lagranges equations

We start our considerations with one particle moving in Euclidean space E 3 . We also
suppose that there is some force F acting on that particle. This force depends on the
position r of the particle and possibly also on time. This is a restrictive assumption,
because, for example, magnetic force depends also on the velocity of the particle. We
will return to this point later. But if these assumptions hold, Newtons law has familiar
form

F (t, r) = m a(t).
This abstract law can be expressed in some xed Cartesian coordinate system in the
component form as

Fi = m x
i ,

i = 1, 2, 3.

(4.1)

Thus, Newtons law is the system of three ordinary dierential equations of second order
for the unknown functions xi = xi (t). Although the given form of Newtons law is
perfectly understandable and simple, it suers several drawbacks. First, the Cartesian
corrdinates are not always convenient for the description of the motion of the particle. It
is not obvious how to write down the equation of motion in dierent coordinate system.
Lagranges formulation provides us with very ecient and elegant way how to write down
equations of motion in an arbitrary coordinate system. This allows us to analyze system
which is subject to some constraints.
Suppose that xi are Cartesian coordinates and qi are arbitrary curvilinear coordinates
of the particle. The coordinate transformation from xi to qi and the inverse transformation are formally given by relations

xi = xi (q1 , q2 , q3 ),

qa = qa (x1 , x2 , x3 ),

or briey
33

(4.2)

34

CHAPTER 4. LAGRANGES EQUATIONS

xi = xi (q),

qa = qa (x),

(4.3)

where i, a = 1, 2, 3. In the context of analytical mechanics, the coordinates qi are called


generalized coordinates. Their time derivatives qi = dqi /dt are called generalized velocities. The crucial point now is that we will treat coordinates qi and velocities qi as
independent variables :
qa
= ab ,
qb

qa
= 0.
qb

Equation (4.1) is expressed in Cartesian coordinates and we are going to translate it


to curvilinear coordinate system qi . Kinetic energy T of the particle is dened as
1
1
1
m v2 =
m r 2 =
m x i x i .
2
2
2

T =

For now we treat x i , the velocity with respect to Cartesian coordinates, as an independent
variable, we can write
T
x i

= m x j ij = m x i

and
d
dt

T
x i

)
= mx
i .

Newtons law thus can be written in the form


d
dt

T
x i

)
= Fi .

(4.4)

Now we transform it to the curvilinear coordinate system. Components of the force Fi


with respect to coordinates qi are given by

Qa =

xi
Fi .
qa

Quantities Qa are called generalized forces, but from the geometrical point of view they
are just components of F with respect to curvilinear coordinate system. Multiply (4.4)
with xi /qa :
xi d T
qa dt x i

= Qa .

(4.5)

Of course, these quantities are not really independent, since for given q = q (t) the velocity q is
i
i
i
uniquely determined. These matters can be rigorously discussed in terms of tangent bundle over the
conguration space.

35

4.1. LAGRANGES EQUATIONS

Take the coordinate transformation xi = xi (q) and dierentiate it with respect to the
time to obtain
d
xi
xi (q) =
qa ,
dt
qa

x i =

(4.6)

from which we immediately have


x i
qa

xi
.
qa

(4.7)

Using the Leibniz rule for the derivative of a product,

d
d
d
b =
a b b a,
dt
dt
dt

we can rewrite (4.5) as

Qa =

d
dt

x i T
qa x i

T d
x i dt

xi
qa

)
(4.8)

The rst term on the right hand side is simply


d
dt

x i T
qa x i

)
=

d
dt

T
qa

)
.

The second term can be arranged as follows:


d xi
dt qa

2 xi

=
qb =
qa qb
qa

xi
qb
qb

)
=

dxi
qa dt

x i
.
qa

Here we used the fact that qb /qa = 0, since qa and qa are considered to be independent.
Thus, we have
T d
x i dt

xi
qa

)
=

T
.
qa

The second term on the right hande side of (4.8) is therefore just the curvilinear component of T /xi .
Collecting all these results we nd that Newtons law of force can be written in the
form
d T
T

dt qa
qa

= Qa .

(4.9)

These equations are called Lagranges equations of the second kind . Although they look
more complicated then original Newtons law (4.1), they have several advantages. The
Lagranges equations of the rst kind are not discussed in this textbook. Their disadvantage is that
they involve the constraints explicitly.

36

CHAPTER 4. LAGRANGES EQUATIONS

simple form of (4.1) is mainly due to the use of Cartesian coordinate system, while (4.9)
is valid in every coordinate system. Before examining the properties of these equations
we will bring them into slightly dierent form.
We have made some assumptions about the acting force, namely, that it depends only
on time and the position of the particle. We also mentioned that the magnetic force does
depend also on the velocity of the particle. Nevertheless, in pure classical physics all
forces satisfy this properties. In addition, the forces are supposed to be conservative, i.e.
they are gradients of some scalar function V :

F = V,

or Fi =

V
.
xi

The sign - is conventional and is related to the choice of zero energy level. Function
V is called potential of the force F . In accordance with our previous assumptions, it
depends only on coordinates xi or qa , not on velocities. So, in Cartesian coordinates we
have Fi = i V . Let us calculate the generalized forces:

Qa =

xi V
xi
Fi =
qa
qa xi

V
.
qa

We can see that the generalized forces are just partial derivatives of potential with respect
to generalized coordinates. Lagranges equations of second kind then read
d T
T

dt qa
qa

V
.
qa

It is useful to introduce a new function, the Lagrangian, as a dierence between the


kinetic energy and the potential,

= T V.

(4.10)

Because V does not depend on the velocities, we have


L
qa

T
.
qa

Lagranges equations of second kind then acquire simple form


L
d L

dt qa
qa

= 0.

(4.11)

These equations are called simply Lagranges equations and they are not as general as Lagranges equations of second kind, since we have used some additional assumptions about
the force. But in classical physics these assumptions are usually satised and we will see
Electromagnetism is not part of the pure classical physics. Maxwells equations are field equations,
while in the classical physics there are no elds, only bodies and forces.

4.1. LAGRANGES EQUATIONS

37

that Lagranges equations are appropriate even for the description of electromagnetism
although there is in general no potential for electromagnetic force.
Let us recapitulate the advantages of Lagranges equations (4.11). They are valid in
arbitrary coordinate system. To write down equations of motion we have to compute
only one scalar function L in Cartesian coordinates and then express it in generalized coordinates qi , which is a straightforward procedure. Then by simple partial dierentiation
of Lagrangian we obtain equations of motion. If the system is subject to constraints, we
can choose generalized coordinates in such a way that these constraints are automatically
satised. In addition, the Lagrangian formulation of mechanics allows us to investigate
general properties of the system, often without solving equations of motion explicitly.

4.1.1

Rayleighs dissipation function

Although we will use Lagranges equations primarily in the form (4.11), it is useful to
analyze also more general case (4.9). There are two typical examples of non-conservative
forces: electromagnetic forces and forces of friction. In this subsection we aim our attention on dissipative forces, electromagnetic eld will be discussed in the next one.
Dissipative forces are not fundamental like gravitational or electromagnetic forces.
They arise as a consequence of complicated interactions of electromagnetic nature between objects and particles on molecular level. The overall eect of these forces is the
so-called friction. The word dissipative is derived from the fact that friction does
not conserve mechanical energy. In other words, moving body is loosing its mechanical
energy because of friction, and the mechanical energy is transforming into heat. Thus,
dissipative forces are genuinely non-conservative. In order to incorporate them in the
Lagrangian formalism, we have to use Lagranges equations of the second kind
d T
T

dt qa
qa

= Qa .

As we mentioned, the friction is very complex and complicated phenomenon. We need


some simple model which will allow us to compute the forces of friction with accuracy
sucient for practical calculations. The experience shows that the friction depends on
the shape of the body and on its speed. The higher is the velocity, the higher is the
friction. If the speed is not too high, this dependence is linear, for higher speed the
dependence is approximately quadratic. What is low and what is high speed depends on
circumstances.
These simple cases can be treated by using the dissipation function. Suppose that the
resisting force is proportional to the velocity of the particle and has opposite direction:
F = k v.
The coecient k incorporates the shape of the body, the properties of the material, etc.
In analogy with conservative forces, we introduce Rayleighs dissipation function R,
R =

1
k v 2 = k vi vi ,
2

so that the resisting force is given by

(4.12)

38

CHAPTER 4. LAGRANGES EQUATIONS

Fi

R
= k vi = k x i .
vi

(4.13)

Corresponding generalized force is then, using (4.7),

Qa =

xi
x i R
R
Fi =
=
.
qa
qa x i
qa

Suppose now that the particle is under inuence of the conservative force with potential V and the resisting force with dissipation function R. Then the equations of motion
are
d T
T

dt qa
qa

V
R

,
qa
qa

or, if we dene the Lagrangian L = T V ,


d L
L
R

+
dt qa
qa
qa

= 0.

(4.14)

Later we will see how these equations can be used for the analysis of the damped harmonic
oscillator.

4.1.2

Particle in the electromagnetic eld

Consider once more Lagranges equations of second kind


d T
T

dt qa
qa

= Qa .

If the force Qa is conservative with the potential V we can dene the Lagrangian L =
T V and obtain Lagranges equations (4.11). But, obviously, if the force has the form

Qa =

d U
U

,
dt qa
qa

(4.15)

then we can dene L = T U and obtain the Lagranges equations again:


L
d L

dt qa
qa

= 0.

This is again a restrictive assumption about the force. But it includes all conservative
forces, for which U does not depend on velocities qa . In addition, electromagnetic force
has also the form (4.15).
Electromagnetic eld is characterized by the electric eld E and the magnetic eld
B. They satisfy Maxwells eld equations

39

4.1. LAGRANGES EQUATIONS

,
0
E
B = 0 j + 0 0
,
t
E =

B = 0,
E =

B
.
t

(4.16)

These equations can also be derived from an appropriate Lagrangian (more precisely,
Lagrangian density), but we will not dicuss this here, since we do not investigate the
electromagnetic eld itself. We are, however, interested in the eect of the eld on the
particles moving in this eld. We know from elementary physics, that particle with
charge e and the velocity v moving in the electromagnetic eld characterized by E and
B experiences the so-called Lorentz force

= e (E + v B) .

(4.17)

This force does not have a potential, but it is of the form (4.15). To see this, we must
introduce the potentials of electromagnetic eld.
Maxwells equation B = 0 implies that there exists a vector eld A, called vector
potential, so that

B = A.
Divergence of the curl is always zero, so if B has this form, its divergence automatically
vanishes. That the converse also holds is the content of the Poincare lemma . Now, from
the equation for the curl of E we nd

E =

A
,
t

from which we have


(
)
A
E +
= 0.
t
The curl of a gradient is always zero, so the last equation and Poincares lemma tell us
that E + t A is a gradient of some scalar function , called scalar potential. Thus, we
have

E =

A
.
t

The Poincar
e lemma states that on contractible manifold every closed form is also exact. Intuitively,
manifold is a space where the physical objects, bodies, exist. If every closed curve, the loops, can be
continuously deformed into a point, the manifold is contractible. Euclidean space satises this property.
Poincar
es lemma then asserts that if divergence of curl of some vector eld is zero, then each eld with
zero divergence is the curl of some other vector eld. Similarly, the curl of gradient is always zero, and
Poincar
es lemma states, that if the curl of some vector eld is zero, then it is a gradient of some scalar
eld.
Again, we put E + A to be minus the gradient.
t

40

CHAPTER 4. LAGRANGES EQUATIONS

So, we can describe the electromagnetic eld in terms of electric and magnetic vectors
E and B, or equivalently in terms of scalar potential and vector potential A. Electric
and magnetic vectors are physical, i.e. directly measurable, quantities. On the other
hand, potentials are not physical quantities, since we cannot measure them. In addition,
potentials are not unique. For if we replace them with new potentials according to the
rule

A 7 A + f,

7 +

f
,
t

resulting electromagnetic eld is the same (check!). Here, f is an arbitrary function


of space and time. This freedom in the choice of the potentials is known as gauge
freedom and corresponding change of the potentials is called gauge freedom. Gauge
freedom has sophisticated geometrical meaning and it plays a crucial role in modern
quantum eld theories and particularly in the standard model of elementary particles.
All these things can be fully understood only in the frame of relativistic theory and the
theory of represenations of the Poincare group. For us it is important that potentials are
quantities without direct physical meaning, which follows also from the fact that they
are not unique, and there is a large class of potentials dening the same electromagnetic
eld.
After this digression we return to the Lagrangian formulation of the problem. We
claim that the Lagrangian L = T U , where

e e A v,

(4.18)

correctly describes the motion of the particle moving in the given electromagnetic eld
characterized by potentials , A. In Cartesian coordinates we have
U = e e Ai x i .
Generalized forces are

Qi =

d U
U

.
dt x i
xi

Let us compute individual terms. The second one is trivial:


U
xi

= e

Aj
e x j
.
xi
xi

Derivative of U with respect to the velocity is also simple:


U
x i

= e Ai .

Now we have to dierentiate the last equation with respect to time (recall that potentials
are time-dependent):

4.1. LAGRANGES EQUATIONS

d U
dt x i

= e

41

Ai
Ai
x j e
.
xj
t

Collecting these partial results together we nd

Qi

[
(
)]

Ai
Aj
Ai
= e
+ x j
= e [E + v B]i .

xi
t
xi
xj

So, we have shown that the function U indeed yields the Lorentz force. We can conclude
that the Lagrangian of the particle in given electromagnetic eld is

L = T U =

4.1.3

1
m v 2 e + e A v.
2

(4.19)

Hamiltons principle

We have derived Lagranges equations for one particle starting from Newtons law of force
and transforming it to generalized coordinates. In this subsection we show an alternative
derivation of Lagranges equation which starts from Hamiltons principle. This approach
is much more fundamental and works even in such cases, when Newtons law does not
hold! This happens in special and general theory of relativity, in quantum mechanics
and in quantum eld theory. For this reason Lagranges equations are regarded as more
general than Newtons law.
First we try to motivate the origin of Hamiltons principle. Following discussion is very
informal and non-rigorous. Newtons law of force is a dierential equation of second order.
It describes how an acting force aects the motion of the particle. It is a kind of local law.
The solution of force law for one particle contains two parameters, integration constants.
Once we solve the equation of motion, we have to impose some initial conditions. Usually
we prescribe the initial position of the particle and its initial velocity, i.e. we prescribe the
values of unknown functions and their rst derivatives at given time. Then the solution
satisfying those initial conditions is unique. But there is also another possibility: we can
prescribe the initial position at time t1 and the nal position at time t2 > t1 . We have
again two conditions which uniquely determine integration constants.
Hamiltons principle is a more sophisticated idea. Imagine that we know two positions
r1 and r2 of the particle at two dierent times t1 and t2 but we do not know the solution
of equations of motion. That is, we do not know the function r = r(t), only its two values
r1 = r(t1 ) and r2 = r(t2 ). Of course, there are innitely many trajectories connecting
points r1 and r2 , see gure 4.1.3. What we want is to assign some number (called action)
to each trajectory and then nd a rule which will select only one from all these possible
trajectories. The rule is Hamiltons principle and it is a kind of integral law, in contrast
to local law, because it does not work with the position of the particle at some time,
acting force, and the acceleration. Instead, it works with entire trajectories. Hamiltons
principle states that the action, a number assigned to each trajectory, is extremal for the
real trajectory. Usually the extrem is minimum. In other words, particle is moving along
trajectory for which the action is minimal. Let us formulate this more precisely.
Consider classical system of particles described by n generalized coordinates qa and
corresponding velocities qa . Here n is the number of degrees of freedom of the system.

42

CHAPTER 4. LAGRANGES EQUATIONS

r2
r1
O
Figure 4.1: There are innitely many possible trajectories connecting positions r1
and r2 .

We assume that there exists a scalar function L, the Lagrangian, describing the system
in some sense. Since we know that the evolution of the system is fully determined by
initial corrdinates and initial velocities, we assume that the Lagrangian depends only on
generalized coordinates and generalized velocities and possibly on time:
L = L (q, q,
t) ,
where symbol q stands for ntuple of coordinates qi . Lagrangian characterizes the state
of the system at some time t, but it does not characterize the trajectory, as we wish. Let
qi = qi (t) be arbitrary trajectory an let us denote

qi (t1 ) = ai ,

qi (t2 ) = bi ,

for arbitrary but xed times t1 and t2 > t1 . So, the trajectory passes through point A
with generalized coordinates ai at time t1 and through point B with coordinates bi . The
action along the trajectory qi (t) is dened as an integral of the Lagrangian along the
trajectory:
t2
L(q(t), q(t),

t) dt.

I[q] =

(4.20)

t1

The action is a functional on the space of trajectories, i.e. space of functions q(t). Thus,
the action takes the trajectory as an argument and integrates the Lagrangian over this
trajectory, which yields the real number I[q]. We use the square brackets [ ] instead of
() in order to emphasize that the action depends on the whole trajectory, not on the
position at some particular time.
In

mathematics, the functional is a mapping f : L 7 F, where L is the vector space over eld F.

43

4.1. LAGRANGES EQUATIONS

Now we have characterized each possible trajectory between A and B by a real number, the action. Hamiltons principle postulates that the real trajectory is one for which
I[q] is extremal. We know that ordinary function f = f (x), x Rn can have extremes
at points where its derivatives vanish:
f
xi

= 0,

for all i = 1, 2, . . . n.

But what is the analogue of derivative of functional I[q]? How can we dierentiate the
functional with respect to trajectory? It is intuitively clear that we need to compare
the actions for two close trajectories. Both trajectories must start at point A and end at
point B. If qi (t) is our xed trajectory, we can dene new trajectory
qi (t) = qi (t) + i (t).
Here i (t) is arbitrary set of functions vanishing at the beginning and at the end,

(t1 ) = (t2 ) = 0.
Parameter determines how close two trajectories qi and qi are. If << 1, we can
say that these trajectories are innitesimally close. See also gure 4.1.3. Now we can
dene the functional derivative or variation of the action :
[
I[q]

d
I[q + ]
d

]
.

(4.21)

=0

To evaluate the functional derivative of an action, we have to write the action I[q + ],
dierentiate with respect to parameter and then set = 0.
Now we can formulate Hamiltons principle mathematically. Among all trajectories
connecting points A and B, the real system will move along trajectory, for which
t2
L (q, q,
t) = 0.

I[q] =
t1

Although this is an integral law, it is equivalent to certain set of dierential equations,


which we are going to derive. The varied action is

I[q + ] =

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

Derivative with respect to gives


Here we do not enter into some details. Functional derivative is in fact distribution, not ordinary
function. What we denote as I[q] is actually distribution I[q]/q applied to a test function . We
believe that our simplication is appropriate for this textbook.

44

CHAPTER 4. LAGRANGES EQUATIONS

d
I[q + ] =
d

]
L
L
dt
i +
i .
qi
qi

The second term on the right hand side can be integrated per partes:
t2

L
i dt =
qi

t1

[
]t
(
)

L 2
d L
i

i
dt.
qi t1
dt qi

Now the rst term on the right hand side vanishes, because i (t1 ) = i (t2 ) = 0. For the
variation of the action we thus nd
t2 [
I[q] =

]
d L
L

i dt = 0.
qi
dt qi

t1

Since the functions i are arbitrary and the xed points A and B as well, the last
integral equation can be satised only if the intregrand vanishes. We therefore arrive at
Lagranges equations
L
d L

= 0.
qi
dt qi
In the context of variational principles these equations are also called the Euler-Lagrange
equations.
So far we did not specify what the Lagrangian is. The power of Hamiltons principle
rests in the fact that we can often guess the Lagrangian of the system. This is important
especially in relativistic eld theories. Let us see try to guess the Lagrangian for the
free particle. We use the Cartesian coordinates. The state of particle is described by its
position r and velocity v. Euclidean space is homogeneous, i.e. all points are equivalent, all points have the same properties, and there is no preferred point. The position
vector r, however, depends on the choice of the origin. But the state of motion of the
particle cannot depend on the choice of the origin, because of homogeneity of the space.
Lagrangian therefore cannot depend on the position vector r and it must depend only on
velocity v. The space is also isotropic, i.e. all directions in the space are equivalent, and
so the Lagrangian cannot depend on the direction of v. In addition, Lagrangian must
be scalar, and the only scalar which can be built from the vector v is its square v 2 . We
can conclude that the Lagrangian must be of the form

L = a v2 .
From the previous discussion we know that the constant a is in fact equal to m/2. We
can see that for a free particle we nd

L = T.

45

4.2. LAGRANGES EQUATIONS IN MAPLE

q
q(t)+lx(t)

q(t)

t
Figure 4.2: Two close trajectories q(t) and q(t) + (t).

If the particle is not free but moving in the force eld with potential V , we must add an
appropriate term into Lagrangian:

L = T V,
where the sign minus is conventional.

4.2

Lagranges equations in Maple

In this subsection we will show how the formalism of Lagranges equations can be implemented in Maple. Examples include the motion in homogeneous gravitational eld,
homogeneous magnetic eld and harmonic oscillator. These examples are quite trivial
which allows us to calculate the result by hand and it is not necessary to use Maple. It
is, however, instructive to compare results obtained by Maple and by honest calculation.
Next we will see examples, where Maple is really helpful.

4.2.1

Homogeneous gravitational eld

Consider two-dimensional motion of the point mass in homogeneous gravitational eld


with intensity g. We introduce Cartesian coordinates (x, y), the axis x being parallel to
the surface of the Earth, the axis y being perpendicular to it. Surface of the Earth is
given by equation y = 0. In these coordinates

g = (0, g),
where g =9.80665

m s2 is the gravitational acceleration. The kinetic energy is simply

T =

1
1
m v 2 = m (x 2 + y 2 ).
2
2

46

CHAPTER 4. LAGRANGES EQUATIONS

Gravitational force is
F = m g = m (0, g) ,
so Fx = 0 and Fy = mg. Potential for this force is, by denition, function V satisfying
Fx =

V
= 0,
x

Fy =

V
= m g.
y

First of these equations tells us that V does not depend on x. The second equation
integrates to

V = m g y + C,
where C is the integration constant. This constant does not enter the equations of motion
and can be chosen arbitrarily. We choose C = 0 so that V = 0 on the Earth surface.
The Lagrangian is therefore

)
1 ( 2
m x + y 2 m g y.
2

(4.22)

Equations of motion are now obtained by straightforward calculation. We have two


Lagranges equations
d L
L
=
,
dt x
x

d L
L
=
.
dt y
y

Individual terms read


d L
d
=
m x = m x
,
dt x
dt
L
= 0,
x

d L
d
=
m y = m y.
dt y
dt
L
= m g.
y

We arrive at following equations of motion:

mx
= 0,

m y = m g.

(4.23)

These are familiar equations for particle moving in homogeneous gravitational eld. Trivial integration gives

x(t) =

a1 + b1 t,

y(t) =

a2 + b2 t

1 2
gt .
2

The solution is not, of course, unique, because it contains four arbitrary constants. These
constants are determined only when initial conditions are imposed. The meaning of the
constants can be easily revealed. For t = 0 we have

4.2. LAGRANGES EQUATIONS IN MAPLE

x(0) = a1 ,

47

y(0) = a2 , x(0)

= b1 , y(0)

= b2 .

We cas see that a1 and a2 are initial coordinates x0 and y0 at time t = 0, while b1 and
b2 are initial velocities v0x and v0y . We can summarize the general solution as

x(t)

= x0 + v0x t,

y(t)

= y0 + v0y t

1 2
gt .
2

(4.24)

Physicaly, the particle is moving uniformly (without acceleration) in xdirection, but


with constant acceleration g in the direction of axis y. Now we want to obtain the same
result using Maple.
First we must dene the Lagrangian

L =

)
1( 2
x (t) + y 2 (t) m g y(t).
2

Here we emphasized that coordinates x and y depend on time. In Maple we can write
L := (m/2)*( x(t)^2 + y(t)^2 ) - m*g*y(t);
This denes the variable L. Maple can dierentiate such expressions symbolically. But we
need variables x, y and x,
y to be independent, while x(t)

is determined by x(t) uniquely.


Before deriving the Lagrange equations we have to replace velocities and coordinates by
dierent variables. We thus dene substitution rules
subst1 := { x(t) = q[1], y(t) = q[2], x(t) = v[1], y(t) = v[2] }:
subst2 := { q[1] = x(t), q[2] = y(t), v[1] = x(t), v[2] = y(t):
The rst rule subst1 tells Maple to replace coordinates x(t) and y(t) by variables q1 and
q2 , and velocities x(t)

and y(t)

by variables v1 and v2 . The second rule represents the


inverse replacement of q1 by x(t) etc. Now we can dene the auxiliary variable l1 by
l1 := subs( subst1, L );
This command will make substitutions dened in subst1 in the variable L. Maple will
produce the result

l1 =

1
m (v12 + v22 ) m g q2 .
2

The variable l1 can now be dierentiated. Since we have two coordinates x, y (and two
velocities x,
y),
there are two Lagranges equations. This is very simple case, but in
general, there are as many of Lagranges equations as is the number of coordinates. For
the future purposes, it is useful to dene a variable dim, dimension of the conguration
space, which in our case has value 2:
dim := 2:

48

CHAPTER 4. LAGRANGES EQUATIONS

Lagranges equations consist of two terms,


d L
,
dt x i

and

L
.
xi

Derivative of the Lagrangian with respect to velocity vi can be typed as di(l1, v[i]),
where i = 1,...dim. We can use the command seq to generate the list of dim derivatives
L/ x i :
term1 := [ seq( diff(l1, v[i]), i=1..dim) ]:
Similarly we can dene the list of derivatives with respect to coordinates qi :
term2 := [ seq( diff(l1, q[i]), i=1..dim) ]:
Now we need to dierentiate term1 with respect to time. But this variable does not
contain any time dependece, because we have replaced xi (t) by symbols qi and x i by vi .
To recover the original variables we use the substition rules subst2 dened above. Then
we can dierentiate each element term1[i] with respect to time. Similarly, we perform
inverse substitution in term2. Finally, we generate the list of Lagranges equations:
Term1 := [ seq( diff( subs(subst2,term1[i]), t ), i=1..dim ) ]:
Term2 := [ seq( subs( subst2, term2[i] ), i=1..dim ) ]:
LagrEqs := seq( Term1[i] - Term2[i] = 0, i =1..dim );
This sequence of command yields the following result:
LagrEqs = mD(2) (x)(t) = 0,

mD(2) (y)(t) + mg = 0.

We can see that these equations are identical with (4.23) and Maple is able to nd their
general solution analytically. Here we show how to nd unique solution for given initial
conditions.
Suppose that the particle was launched from the initial position is (x0 , y0 ) with the
initial velocity (vx , vy ). Then we can insert the initial conditions by assignment
InitConds := x(0) = x[0], y(0) = 0, x(0) = v[x], y(0) = v[y];
System of Lagranges equations and initial conditions is solved by
sol := dsolve( {LagrEqs, InitConds} );
Maple returns the solution in the form
{
sol :=

x(t) = vx t + x0 , y(t) =

}
1 2
g t + vy t + y0 .
2

Variable sol is the list of two elements

sol[1] = x(t) = vx t + x0 ,

and

sol[2] = y(t) =

1 2
g t + vy t + y0 .
2

4.2. LAGRANGES EQUATIONS IN MAPLE

49

Imagine that we want to plot the solution for some particular values of vx and vy . It is
useful to dene new variable which will be derived from the variable sol, but all constants
will be replaced by numerical values. If, for example, if the particle is launched from the
origin (0, 0) with velocities vx = 10 m s1 and vy = 10 m s1 , we can type
Sol := subs( {g=9.80655, x[0] = 0, y[0] = 0, v[x]=10, v[y]=10}, sol );
Now the variable Sol is again the list of two elements,
{
}
Sol := x(t) = 10 t, y(t) = 4.903275 t2 + 10t .
Finally, we would like to have two functions X(t) and Y (t) given by the solution Sol.
This can be done by
X := unapply( rhs( Sol[1] ), t );
Y := unapply( rhs( Sol[2] ), t );
Explanation: Sol[1] is the rst element of the list Sol, i.e.

Sol[1] = x(t) = 10 t.
The right hand side of this equation can be extracted with function rhs():

rhs(Sol[1]) = 10 t.
Function unapply( expr., t) nds the occurence of variable t in the expression expr. and
replaces it by an abstract variable. Assignment X := unapply( expr., t) will make X
the function of this abstract variable. After the assignment, expression X(t) means 10t,
expression X(s) means 10s, etc.
Now we are prepared to plot the solution. We know that launched body will, after
some time T , fall back on the ground. This time can be computed by
T := solve( Y(t) = 0);
Maplends two solutions

T := 0, 2.039453223.
This is understandable, since Y (t) is a quadratic function. Only the second solution is
relevant for us, because we know that the body was launched from the ground at time
t = 0. The solution can be then plotted by
plot( [ X(t), Y(t), t = 0..T[2] ] );
The result can be seen on the gure 4.3.

50

CHAPTER 4. LAGRANGES EQUATIONS

Figure 4.3: Visualisation of the solution for the motion in homogeneous gravitational
eld.

Figure 4.4: Visualisation of the solution for the motion in homogeneous gravitational
eld, where the friction between the body and the air has been taken into account.

4.2. LAGRANGES EQUATIONS IN MAPLE

51

Figure 4.5: Comparison of motion with and without friction.

4.2.2

Motion with resisting force

In the previous subsection we analyzed the motion of point mass in the homogeneous
gravitational eld. Our model was simplied by the assumption that there are no nongravitational forces. In such a case the trajectory of the particle is always a parabola.
Now we consider a more realistic model. The real body experiences also a resisting force
due to friction between the body and the surrounding medium, usualy the air. We can
introduce Rayleighs dissipation function

R =

)
1
1 (
k v 2 = k x 2 + y 2
2
2

and use modied Lagranges equations (4.14),


d L
L
R

+
= 0.
dt qa
qa
qa
We can easily modify the Maple code from previous example. Instead of explaining all
again we just give the full code. The meaning of individual commands should be clear.
subst1 := {x(t) = q[1], y(t) = q[2], x(t) = v[1], y(t)(t) = v[2]}:
subst2 := {q[1] = x(t), q[2] = y(t), v[1] = x(t), v[2] = y(t)}:
R := (1/2)*k*(x(t)^2 + y(t)^2):
# Rayleighs function
L := (1/2)*m*(x(t)^2 + y(t)^2) - m*g*y(t): # Lagrangian
l1 := subs(subst1, L):
dim := 2:
term1 := [seq(diff(l1, v[i]), i = 1 .. dim)]:
term2 := [seq(diff(l1, q[i]), i = 1 .. dim)]:

52

CHAPTER 4. LAGRANGES EQUATIONS

term3 := [seq(diff(subs(subst1, R), v[i]), i =


Term1 := [seq(diff(subs(subst2, term1[i]), t),
Term2 := [seq(subs(subst2, term2[i]), i = 1 ..
Term3 := [seq(subs(subst2, term3[i]), i = 1 ..
LagrEqs := seq(Term1[i]-Term2[i]+Term3[i] = 0,

1 .. dim)]:
i = 1 .. dim)]:
dim)]:
dim)]:
i = 1 .. dim);

This produces Lagranges equations

LagrEqs := mD(2) (x)(t) + kD(x)(t) = 0, mD(2) (y)(t) + mg + kD(y)(t) = 0,


or, in usual notation,

mx
+ k x = 0,

m y + m g + k y = 0.

These are inhomogeneous linear dierential equations with constant coecients and can
be solved by standard techniques . However, we can avoid doing this boring procedure
and leave it for Maple.
InitConds := x(0) = x[0], x(0) = v[x], y(0) = y[0], y(0) = v[y]:
sol := dsolve({LagrEqs, InitConds});
This commands give us general solution. Mass m and parameter k enter the solution
only through terms m/k. We can thus introduce a new single parameter

m
,
k

and use the following command for solving Lagranges equations:


sol := simplify(subs(m = k*mu, dsolve({LagrEqs, InitConds})));
Maple then returns the solution
(
)
x(t) = x0 + vx 1 et/ ,

(
)
(
)
y(t) = y0 g t+ vy 1 et/ +2 g 1 et/ .

We continue by inserting some numerical values, calculating the time of the fall, and
ploting the result.
Sol:=subs({g=9.80655,mu=1,v[x]=10,v[y]=10,x[0]=0,y[0]=0},sol):
X := unapply(rhs(Sol[1]), t):
Y := unapply(rhs(Sol[2]), t):
T := solve(Y(t) = 0, t);
plot([X(t), Y(t), t = 0 .. T[1]]);
We

are looking the solution in the form x(t) = e t . This ansatz is inserted into the equation for x,
from which we nd quadratic equation for , so called characteristic equation, m2 + k = 0, which can
be easily solved. The same procedure is then repeated for y. Equation for y contains also inhomogeneous
term mg, so we have to use Lagranges method of variation of the constant or guess the particular
solution.

4.2. LAGRANGES EQUATIONS IN MAPLE

53

Instead of gure 4.3 we now obtain gure 4.4. The trajectory is not a parabola anymore,
but the ballistic curve.
In order to appreciate the role of the friction, we can ploth both curves into one
picture. Now we have the solution with the presence of the friction in variables X and Y.
We can store the solution in new variables X1 and Y1 by
X1 := unapply( X(t), t ):
Y1 := unapply( Y(t), t ):
T1 := T;
Then we set R = 0 and run through the derivation and solution of Lagranges equation
once more. Finally, we can plot both solutions into one picture by
plot({[X(t), Y(t), t = 0 .. T[2]], [X1(t), Y1(t), t = 0 .. T1[1]]});
The result is drawn on gure 4.5.

4.2.3

Homogeneous magnetic eld

Consider now the particle with charge e moving in the homogeneous magnetic eld B of
magnitude B. Let (x, y, z) be the Cartesian coordinates chosen in such a way that

B = (0, 0, B)
with respect to these coordinates. As mentioned in the section 4.1.2, the Lagrangian of
the particle in electromagnetic eld is

L =

1
m v 2 e + e A v,
2

(4.25)

where and A are scalar and vector potentials of the eld:

E =

A
,
t

B = A.

Thus, in order to write down the Lagrangian, we have to nd potentials for homogeneous
magnetic eld. This can be done in a lot of ways. We choose the one which could be
perhaps more interesting. Recall that potentials are not uniquely determined by elds
E and B and so there is a large class of potentials leading to desired result. First, since
there is no electric eld, we can put

= 0,

A
= 0.
t

The scalar potential is therefore equal to zero, and the vector potential depends only on
spatial coordinates,

A = A(x, y, z).

54

CHAPTER 4. LAGRANGES EQUATIONS

From the geometrical meaning of the curl-operation it should be clear that the potential
A can be chosen to be independent of the coordinate z. Roughly speaking, the integral
lines of A are expected to form circles orthogonal to constant vector B. Here we can use
an analogy with the angular velocity . It is an elementary fact that the translational
velocity v of the rigid body rotating about the xed axis is given by
v = r.
The integral lines of v are circles with axis . It is clear that the velocity depends on
the distance from the axis, but not on the zcoordinate. In addition, the relation

1
v
2

(4.26)

holds (see section A.3). Angular velocity is therefore (proportional to) the curl of the
velocity eld v. Thus, we have two analogous relations

1
v,
2

B = A,

(4.27)

where vectors on the left hand sides are constant. Since v = r, we can guess that
the potential A of the homogeneous magnetic eld B is given by

A =

1
B r.
2

That this suggestion is correct can be veried directly, or by Maple. In our coordinate
system, where B has only zcomponent, we have

Ax =

By
,
2

Ay =

Bx
.
2

(4.28)

In fact, Maple is able to nd a vector potential for given vector eld. If we dene
vector eld
B := VectorField(<0, 0, b>);
we can nd its vector potential (if it exists), i.e. vector eld A for which B = A, by
A := VectorPotential( B );
Notice that in this particular case Maple nds
A := b y ex ,
which diers from our potential (4.28). We can verify again that it leads to the same
homogeneous eld B. This is a demonstration of mentioned gauge invariance of electromagnetic eld.

4.2. LAGRANGES EQUATIONS IN MAPLE

55

We will use the potential given by (4.28). The Lagrangian is then

L =

)
1 ( 2
eB
m x + y 2 + z 2 +
(x y x y) .
2
2

From now we proceed in a straightforward way. Again, we just show slightly modied
version of the Maple code for deriving and solving corresponding Lagranges equations.
# usual substition rules
subst1 := {x(t) = q[1], y(t) =
x(t) = v[1], y(t)
subst2 := {q[1] = x(t), q[2] =
v[1] = x(t), v[2] =

q[2], z(t) = q[3],


= v[2], z(t) = v[3]}:
y(t), q[3] = z(t),
y(t), v[3] = z(t)}:

# definition of potential and velocity


with(VectorCalculus):
SetCoordinates(cartesian[x,y,z]):
V := VectorField( <x(t), y(t), z(t)>):
A := VectorField( < - B*y(t)/2, B*x(t)/2, 0 > ):
# Lagrangian
L := (m/2)*(V.V) + e A.V:
l1 := subs( subst1, L );
# calculation of Lagranges equations
dim := 3:
term1 := [seq(diff(l1, v[i]), i = 1 .. dim)]:
term2 := [seq(diff(l1, q[i]), i = 1 .. dim)]:
Term1 := seq(diff(subs(subst2, term1[i]), t), i = 1 .. dim):
Term2 := seq(subs(subst2, term2[i]), i = 1 .. dim):
LagrEqs := seq(simplify(Term1[i] - Term2[i] = 0), i = 1 .. dim);
# initial conditions
InitConds:=x(0)=x[0],y(0)=y[0],z(0)=z[0],
x(0)=v[x],y(0)=v[y],z(0)=v[z]:
# solution
sol := dsolve( {LagrEqs, InitConds} );
# substitution of numerical values
Sol:=subs({B=2,e=1,m=3,v[x]=0,v[y]=3,v[z]=3,
x[0]=2,y[0]=0,z[0]=0},sol):
#
X
Y
Z

definition of curve representing solution


:= unapply(rhs(Sol[1]), t):
:= unapply(rhs(Sol[2]), t):
:= unapply(rhs(Sol[3]), t):

56

CHAPTER 4. LAGRANGES EQUATIONS

Figure 4.6: Motion of the charged particle in homogeneous magnetic eld.

# plotting of the solution


with(plots);
spacecurve([X(t),Y(t),Z(t)],t=0..10*Pi,
axes=NORMAL,color=black,numpoints=100);
This code generates the general solution

x(t) =
y(t) =
z(t) =

(
)
m
m
eBt
eBt
vy +
vx sin
+ vy cos
,
eB
eB
m
m
(
)
m
m
eBt
eBt
y0 +
vx +
vx cos
+ vy sin
,
eB
eB
m
m
z0 + vz t,
x0

and plots the solution for t (0, 10), gure 4.6.

4.2.4

Library Mechanics

In this subsection we start writing a new library (package) in Maple. In the examples
above we have seen how to implement several tasks connected to the Lagrangian formalism. For each particular case we had to modify the source code in order to adapt it
for our purposes. Here we show how to encapsulate the Lagrangian formalism into an
independent library. This library should be designated in such a way that no modications will be necessary. During the rest of the course we will expand this library by new
functions and abilities.
Create a new, empty, document in Maple. The name of our new library will be
Mechanics, but the reader is invited to choose a better one. All variables and procedures dened by our library will be the part of so called module. Start with following
declaration:

4.2. LAGRANGES EQUATIONS IN MAPLE

57

Mechanics := module()
export SetVariables, LagrangeEqs;
option package;
local subst1, subst2, varN, t;
end module;
This denes a new module Mechanics. Denition of the module ends with key words
end module. Everything connected to our library will be written inside the module. The
module can have a lot of internal, local, variables and routines, which are not visible
from the outside. But some of these variables and routines must be visible. These are
routines which can be used by the user. The word export tells Maplewhich symbols will
be exported by the module, i.e. which symbols will be accesible by the external user of
the library. The command option package means that module Mechanics will be used as
a library. Then, local variables subst1, subst2, varN and t are declared. Their meaning
will be explained soon.
Next we continue by implementation of exported functions. The rst procedure,
SetVariables, will have two arguments, the list of generalized coordinates and the name
of time-variable. For example,
SetVariables( [x, y, z], t );
will mean that we use three coordinates (x, y, z) and they depend on time t. The second procedure, LagrangeEqs, will have only one argument, the Lagrangian expressed in
coordinates (x, y, z), and it calculates the list of corresponding Lagranges equations.
Denition of both procedures must be inserted before end module;. This is a code of
SetVariables:
SetVariables = proc( vars:: list, time )
local i;
t := time;
varN := nops( vars );
subst1 := {};
subst2 := {};
for i from 1 to var N do
subst1 := subst1 union
{vars[i](t) = q[i], diff(vars[i](t), t) = v[i]};
subst2 := subst2 union
{q[i] = vars[i](t), v[i] = diff(vars[i](t), t)};
end do;
print( subst1 );
print( subst2 );
NULL;

58

CHAPTER 4. LAGRANGES EQUATIONS

end proc;
Head of the procedure SetVariables = proc( vars:: list, time ) informs that the procedure
has two arguments, the list vars and arbitrary variable time. Next, the procedure uses
one local variable i. We assign the variable time to variable t. This variable is dened as
local variable of the module, which means that it is not visible from the outside of the
module. But in the module, t is a global variable, i.e. it is a global variable for procedure
SetVariables. All other procedure will use the variable t as a time coordinate.
Function nops(vars) returns the number of elements of the list vars and this number is
stored in the variable varN. It is actually the number of generalized coordinates. Variables
subst1 and subst2 are sets containing substitution rules, which replace coordinates and
their derivatives by q1 , q2 . . . and v1 , v2 , . . . and vice versa. At the beginning these
variables are chosen to be empty sets represented by {}.
The cycle for sets variable i to 1 and succesively increases it by 1 until i acquires value
varN. For each value of i=1..varN performs the body of the cycle, the code between do
and end do. In this cycle, the elements of sets subst1, subst2 are generated. The set
{vars[i](t) = q[i], diff(vars[i](t), t) = v[i]}
contains two elements. The rst one is the rule which replaces ith variable of the list
as a function of the time by symbol qi . Similarly, the second one replaces the derivative
of ith variable with respect to time by symbol vi . This two elements set is then added
to the set subst1 by the operation of set union
subst1 := subst1 union
{vars[i](t) = q[i], diff(vars[i](t), t) = v[i]};
Similarly for subst2.
For example, if we call the procedure with arguments
SetVariables( [x, y, z], t );
then vars = [x,y,z] and time = t. Variable varN, the number of elements of the list vars,
has value 3. Variable i runs from 1 to 3. For i = 1 we have vars[i] = x;, and the two
elements set is
{x(t) = q[1], diff( x(t), t ) = v[1].
The same is repeated for i = 1, 2, 3. At the end of the cycle we have two sets
subst1 = {x(t)=q[1], y(t)=q[2], z(t)=q[3],
D(x)(t)=v[1], D(y)(t)=v[2], D(z)(t)=v[3]};
subst2 = {q[1]=x(t), q[2]=y(t), q[3]=z(t),
v[1]=D(x)(t), v[2]=D(y)(t), v[3]=D(z)(t)};
and their content is shown by the command print. Finally, the procedure SetVariables
returns symbol NULL meaning that the procedure has no output, no return value which
could be stored in some variable.
After this detailed explanation of the rst procedure we only show the source code of
the second one:

4.2. LAGRANGES EQUATIONS IN MAPLE

59

LagrangeEqs := proc (L)


local i, l1, term1, term2;
l1 := subs(subst1, L):
for i to varN do
term1 := [seq(diff(subs(subst2, diff(l1, v[i])), t), i = 1..varN)]:
term2 := [seq(subs(subst2, diff(l1, q[i])), i = 1..varN)]:
end do;
[ seq(simplify(term1[i]-term2[i]) = 0, i = 1..varN) ];
end proc;
The meaning of this procedure should be clear to the reader.
Now we can test the functionality of our module.
# test1
# Harmonic oscillator
with(Mechanics):
SetVariables( [x], t );
eqs := Lagrange( (m/2)*diff(x(t),t)^2 - (m/2)*omega^2*x(t)^2;
Output:

subst1 = {x(t) = q[1], D(x)(t) = v[1]},


subst2 = {q[1] = x(t), v[1] = D(x)(t)},
(
)
m D(2) (x)(t) + 2 x(t)2 = 0.
# test2
# Homogeneous grav. field
with(Mechanics):
SetVariables( [x,y], t );
eqs := LagrangeEqs( (m/2)*(diff(x(t),t)^2+diff(y(t),t)^2) - m*g*y(t);
This example produces again the corresponding substitution rules and correct Lagranges
equations (try!).
It is perhaps obvious that using the module can be extremely useful, as we do not
have to modify the code for generating Lagranges equations. The module can be stored
as a library and accesible from any Maple document. When using command with(library),
Maple looks for the library in directories which are listed in the global variable libname.
To see what these directories are, type
libname;
After the installation of Maple, this variable contains only one item, string with the full
path to the standard libraries of Maple, e.g.

60

CHAPTER 4. LAGRANGES EQUATIONS

"c:/program files/maple 13/lib".


Thus, if we create a new library, we must either put the library in the predened directory,
or create a new directory and add it to tha variable libname. Since it is easy to create a lot
of libraries and loose the control of them, we prefer the second possibility. Create a new
directory MyLibraries on desired location (e.g. d:/MapleLibs) and save the document
containing module Mechanics there (the name of the document is arbitrary). Close the
document and reopen it and run the module. Typing
newlibdir := currentdir();
now yields (for our particular example)
newlibdir := "d:/MapleLibs".
Type
march( create, newlibdir );
savelib(Mechanics);
First line creates a new library in the directory newlibdir, the second one saves the module
into this library.
To check the functionality of the module, restart the kernel of Maple. Since our
library is not in the Maples directory, we have to add the name of the directory to the
variable libname.
restart;
libname := "d:/MapleLibs", libname;
From now we can proceed in a usual way:
with(Mechanics);
SetVariables([x,y], t);
LagrangeEqs( (1/2)*m*(diff(x(t), t)^2 + diff(y(t), t)^2);
One nal remark. Whenever we want to use our library, we have to assign corresponding directory to the variable libname. This can be avoided using the initialization
le maple.ini (details can be found in Maples help). In this le, if it exists, there is a list
of all commands which are executed when the kernel starts. The le maple.ini should be
located in the subdirectory Users of Maples root directory, e.g.
c:/program files/Maple 13/Users.
Open the le (if it does not exist, create it) and add the following line:
libname := "d:/MapleLibs", libname:
We can check that it works by
restart;
libname;
Directory d:/MapleLibs should now appear in the list.

4.2. LAGRANGES EQUATIONS IN MAPLE

4.2.5

61

Additional functions of the library

In this section we would like to extend our simple library by additional functions. Until
now we implemented only the derivation of Lagranges equations for given Lagrangian.
In order to incorporate also dissipative systems we can write a procedure for calculating
Lagranges equations with Rayleighs function. This procedure is a simple modication
of procedure LagrangeEqs:
RayleighEqs := proc(L, R)
local i, l1, r1, term1, term2, term3;
l1 := subs( subst1, L ):
r1 := subs( subst1, R ):
for i from 1 to varN do
term1:=[seq(diff(subs(subst2, diff(l1, v[i])), t), i=1..varN)]:
term2:=[seq(subs(subst2, diff(l1, q[i])), i=1..varN)]:
term3:=[seq(subs(subst2, diff(r1, v[i])), i=1..varN)]:
end do:
[ seq(simplify(term1[i]-term2[i]+term3[i]), i=1..varN) ];
end proc;
Lagranges equations of the second kind (with arbitrary generalized forces) can be
implemented in a similar way. In the code below we assume that Q is a list of components
of generalized force.
LagrEqsII := proc( L, Q::list )
local i, l1, term1, term2;
l1 := subs(subst1, L):
for i to varN do
term1 := [seq(diff(subs(subst2, diff(l1, v[i])), t), i = 1 .. varN)]:
term2 := [seq(subs(subst2, diff(l1, q[i])), i = 1 .. varN)]:
end do;
[seq(simplify(term1[i]-term2[i]) = Q[i], i = 1 .. varN)];
end proc;
If we need to use Lagranges equations of the second kind with Rayleighs dissipation
function, the following procedure is necessary.
LagrEqsIII := proc (L, R, Q::list)
local i, l1, r1, term1, term2, term3;
l1 := subs(subst1, L):
r1 := subs(subst1, R):
for i to varN do

62

CHAPTER 4. LAGRANGES EQUATIONS

term1 := [seq(diff(subs(subst2, diff(l1, v[i])), t), i = 1 .. varN)]:


term2 := [seq(subs(subst2, diff(l1, q[i])), i = 1 .. varN)]:
term3 := [seq(subs(subst2, diff(r1, v[i])), i = 1 .. varN)]:
end do;
[seq(simplify(term1[i]-term2[i]+term3[i]) = Q[i], i = 1 .. varN)];
end proc;
Procedures LagrangeEqs, LagrEqsII, LagrEqsIII, RayleighEqs all return the equations of
motion for a system described by given Lagrangian, or Rayleighs dissipation function and
generalized force. The following procedure nds a general solution of returned equations.
Integration constants are chosen to be initial positions qi and velocities vi .
GeneralSol := proc (eqs::list)
local i, initconds, eqs2;
initconds := NULL:
eqs2 := eqs[][]:
for i to varN do
initconds:=VarNames[i](0)=q[i], (D(VarNames[i]))(0)=v[i], initconds:
end do;
dsolve({initconds, eqs2});
end proc;

4.2.6

Harmonic oscillator

A typical example of harmonic oscillator in classical mechanics is a spring oscillating


around an equilibrium position. If the displacement from this equilibrium position is x,
the spring experiences restoring force

F = k x,
where the sign minus expresses that the force acts against the displacement. This force
is obviously conservative, since
d
F = kx =
dx

)
1
2
kx .
2

The potential is therefore

V =

1
k x2 .
2

According to Newtons law of force, the equation of motion of harmonic oscillator is

4.2. LAGRANGES EQUATIONS IN MAPLE

63

mx
= k x.
It is useful to introduce new constant by relation

2 =

k
.
m

Then the potential and the equation of motion are

V =

1
m 2 x2 ,
2

x
+ 2 x = 0.

The equation of motion is again ordinary dierential equation of the second order with
constant coecients and without the right hand side. It can be solved by looking for the
solution of the form et (although we did not mention it, the coordinate x is the function
of time). Since it has some relevance for the concept of Fourier transform discussed
(much) later, we analyze the solution in more detail. Harmonic oscillator is one of the
most basic models in physics, it appears in classical mechanics, quantum mechanics, and
it is a fundamental concept in quantum eld theory.
First we derive the solution in a standard way. Multiply equation
x
+ 2 x = 0

(4.29)

by x and use the identities


d 2
x = 2 x x,

dt

d 2
x = 2 x x
,
dt

so that the equation acquires the form


)
1 d ( 2
x + 2 x2 = 0.
2 dt
This integrates to
x 2 + 2 x2 = constant.
For the expression on the left hand side is manifestly positive, so must be the constant
on the right hand side, and thus it can be writen as a square of some real number, say,
C:
x 2 + 2 x2 = C 2 .
After an obvious arrangement we nd

C2

dx
2 x2

= dt.

64

CHAPTER 4. LAGRANGES EQUATIONS

Indenite integral of the left hand side is

dx
C 2 2 x2

1
C

dx

( )2
1 x
C

1
x
arcsin
.

Integral of the right hand side is simply t+ constant, so we have

arcsin

x
= t + D
C

for some real D. Applying sine on the both sides and introducing A = C/, 0 = D
we arrive at

x(t) = A sin ( t + 0 ) .

(4.30)

The constant A is known as amplitude and is equal to maximal displacement of the


oscillator from the equilibrium position. Function

(t) = t + 0
is the phase, the constant 0 is the initial phase.
Solution (4.30) can be rewritten using familiar identity

sin( + ) = sin cos + sin cos


as

x(t) = A cos 0 sin t + A sin 0 cos t.

(4.31)

We can conclude, that the general solution of equation (4.29) is the linear combination
of functions sin t and cos t:

x(t) = cos t + sin t,

(4.32)

where constants and are determined by the initial conditions.


But there is also another, powerful, method how to solve the equation of harmonic
oscillator. Suppose that the solution has form
x(t) = e t
and insert it into equation (4.29). The advantage of exponential function is that its nth
derivative is simply a multiple of the original function,
dn
x(t) = n x(t).
dtn

4.2. LAGRANGES EQUATIONS IN MAPLE

65

Equation (4.29) therefore gives so called characteristic equation for

2 + 2 = 0.
Using the exponential function we translated the dierential equation into an algebraic
one. This equation, however, does not possess the real solution, only two imaginary
solutions:
= i ,
where i is imaginary unit dened by i2 = 1. Two linearly independent solutions of the
original equations are

ei t ,

e i t .

Formally everything seems to be all right, but how are we to interpret such a solution?
How can we exponentiate number e to some imaginary power? The answer is one of the
most striking results of mathematics. Unfortunately, we cannot go into details in this
textbook (although the author would like to). The key is famous Eulers formula

ei = cos + i sin .
This formula can be proved for example by using Taylors expansion of the function ex
and substituting x = i. Geometrical meaning of Eulers formula is sketched on gure
4.7. Since cosine is even and sine is odd function, we have
e i = cos i sin .
Adding or subtracting last two equations leads to the inverse relations

cos =

ei + ei
,
2

sin =

ei ei
.
2i

(4.33)

General (complex) solution of (4.29) can be written in the form


x(t) = A ei t + B e i t .

(4.34)

This is not a contradiction with the statement that the general solution is given by (4.32),
however. For if we choose

A =

i
,
2

B =

+ i
,
2

and use(4.33), we transform the solution (4.34) to the form (4.32). So, if we admit
complex coecients, these two solutions are equivalent. It is only a matter of convenience

66

CHAPTER 4. LAGRANGES EQUATIONS

Im
cos f + i sin f = e i f

sin f

f
cos f

Re

Figure 4.7: Geometric interpretation of number ei = cos + i sin . xcoordinate


of the point on the unit circle is the cosine of angle , ycoordinate is the sine of
this angle.

which form we prefer. On the other hand, expression (4.34) is not manifestly real. Indeed,
if A and B are not complex conjugate of each other, the solution has non-zero imaginary
part. Expression (4.32) is always real, if and are real. The most usual method is
following. We write the solution as a complex function

x
(t) = A ei ( t+0 ) ,
and say that the actual physical solution is the real (or imaginary) part of the complex
solution:
x(t) = (
x(t)) = A cos( t + 0 ) = A cos 0 cos t A sin 0 sin t.
We can see that the real part of the complex solution x
(t) is of the form (4.32) (verify
that it holds also for imaginary part of x
(t)!). If we work in the complex representation
of the solution, we often write
x
(t) = A ei t ,
where A = A ei 0 is the complex amplitude.
Let us return to Maple. We can use the library Mechanics from the section (4.2.4).
with(Mechanics):
SetVariables([x], t);
L := (1/2)*m*diff(x(t), t)^2 - (1/2)*m*omega^2 * x(t)^2;
eqs := LagrangeEqs(L);
sol := GeneralSol( eqs );
X := unapply( rhs(sol), t );
#insert numerical values

4.2. LAGRANGES EQUATIONS IN MAPLE

67

Figure 4.8: Solution for the harmonic oscillator plotted by Maple.

numsol := unapply(subs({omega = 2, q[1] = 0, v[1] = 1}, X(t)), t);


plot( numsol(t), t = 0..2*Pi );
Running through the previous code we obtain a general solution

x(t) =

vx
sin t + x0 cos t,

and for given values = 2, q1 = 0, v1 = 1 plots the gure 4.8. The solution obtained by
Maple is of the form (4.32).
Consider now equation of motion
x
(t) + 2 x(t)

= f (t).

(4.35)

It is similar to the equation of harmonic oscillator, but on the right hand side there is
a time-dependent function f (t). This equation describes situation, when the oscillator
experiences the external driving force. First we solve this equation in the case of periodic
external force. In complex notation
f(t) = f0 ei t ,
where f0 = f0 ei 0 is the complex amplitude of the force, f0 is the real amplitude and 0
is the initial phase of the force, and is its angular frequency. Equation (4.35) is inhomogeneous. General solution is the sum of general solution of corresponding homogeneous
equation and an arbitrary particular solution of the inhomogeneous equation.
We can guess the particular solution on the physical basis. We can expect that for
appropriate initial conditions the oscillator wil oscillate simultaneously with the driving
force, with the same phase and frequency. This particular solution must have the form

68

CHAPTER 4. LAGRANGES EQUATIONS

x
(t) = A ei t .
Inserting this into equation (4.35) we nd the amplitude

A =

f0
,
2

(4.36)

and therefore particular solution reads

x
(t) =

f0
ei t .
2 2

(4.37)

Since we already know the general solution of the homogeneous equation, we can immediatelly write the general solution for driven harmonic oscillator:

x
(t) =

f0
ei t + ei t + e i t .
2

(4.38)

Physical solution is the real (or imaginary) of the last equation and can be written in
the form

x(t) =

f0
cos t + A cos( t + 0 ).
2 2

(4.39)

Here, f0 is the amplitude of the driving force, constants 0 and A are determined by
the initial conditions. We can see that actual motion of the oscillator is the sum of two
independent oscillations: one with the self-frequency and one with the frequency
of the driving force. Setting A = 0 eliminates the rst, but the second one cannot be
eliminated by any choice of the initial conditions.
To nd the solution by Maple we use the library Mechanics, if we use function LagrEqsII
for the Lagranges equations of the second kind, instead of function LagrangeEqs.
with(Mechanics):
SetVariables([x], t):
L := (1/2)*(diff(x(t), t))^2-(1/2)*omega^2*x(t)^2:
Q := t -> [ f*cos(Omega*t) ]:
eqs := LagrEqsII(L, Q(t));
X := unapply(rhs(GeneralSol(eqs)), t);
Check that the solution found by Maple is equivalent to (4.39)!
Next we plot the solution for particular values of the constants involved. We also plot
time-dependence of the force Q(t).
vals := {f = 1, Omega = 2, omega = 1, q[1] = 1, v[1] = 0};
y1 := unapply(subs(vals, X(t)), t):
y2 := unapply(subs(vals, Q(t)[]), t):
plot([y1(t), y2(t)], t = 0..4*Pi);

4.2. LAGRANGES EQUATIONS IN MAPLE

69

Figure 4.9: Driven harmonic oscillator for = 1, = 2, f = 1, q1 = 1, v1 = 0.

Figure 4.10: Driven harmonic oscillator for = 1, = 1.5, f = 1, q1 = 0, v1 = 2.

Resulting graph is drawn on gure 4.9. The red line represents the solution x(t) and
the green one is driving force. Another example, for dierent initial conditions, is shown
on gure 4.10. Think about these two gures and try to explain the dierence between
them physically.
Expression (4.36) for the amplitude of the driven harmonic oscillator tells us, that
the amplitude depends on the dierence 2 2 . If || ||, i.e. if frequencies and
dier signicantly, the the amplitude is small and the harmonic oscillator is only weakly

70

CHAPTER 4. LAGRANGES EQUATIONS

Figure 4.11: Driven harmonic oscillator for = 1, = 7, f = 1, q1 = 0, v1 = 2.

Figure 4.12: Driven harmonic oscillator for = 1, = 1.2, f = 1, q1 = 0, v1 =


2, t 0, 15.

71

4.2. LAGRANGES EQUATIONS IN MAPLE

aected by the driving force. For example, if we choose = 1, = 7, we obtain gure


4.11, where the red line is almost harmonic curve (sine or cosine, possibly shifted) which
does not copy the oscillations of the green line, the force. The situation is qualitatively
dierent for close values of and , for example, = 1, = 1.2. Now the red line is
not a harmonic curve, because its amplitude is being modulated in a periodic way. For
= we obtain an innite amplitude, which is a physical non-sense. The reason is that
for close frequencies our model is unphysical, as we neglected the forces of friction, the
limited rigidity of material etc. Let us try to introduce also the friction and see how the
result changes.
First we investigate the equation of motion in the absence of external driving force.
Such a system is called damped harmonic oscillator. If the resisting force is proportional
to the velocity, the equation of motion is

x
+ x + 2 x =

0.

(4.40)

Again, we look for the solution of the form x = ei t . The characteristic equation is

2 + i + 2 = 0
and its solutions read

i
=

2
.
4

We thus have two independent solutions


2 2

e 2 t i /4 t .
Obviously, the character of the solution depends on values of and (both these quantities are assumed to be real and positive). For if

2 > ,

the square-root 2 2 /4 is real, and the solution has oscillatory character (because
the exponent has imaginary part). If, on the other hand, 2 < holds, the square-root
is imaginary and entire exponent is a real number, so there will be only non-periodic
exponential time-dependence. From now we assume 2 > . The real part of the
exponent, t/2, causes the exponential decrease of the amplitude.
Solution can be found by Maple in a usual way. In order to introduce friction we use
function RayleighEqs from our library.
with(Mechanics):
SetVariables([x], t):
L := (1/2)*(diff(x(t), t))^2-(1/2)*omega^2*x(t)^2:
R := (1/2)*mu*(diff(x(t), t))^2:
eqs := RayleighEqs(L, R);

72

CHAPTER 4. LAGRANGES EQUATIONS

X := unapply(rhs(GeneralSol(eqs)), t):
vals := {f = 1, mu = 1/5, Omega = 2, omega = 1, q[1] = 0, v[1] = 2}:
y1 := unapply(subs(vals, X(t)), t);
plot(y1(t), t = 0 .. 10*Pi);
As the result, the gure 4.13 is drawn.
Finally, we analyze the most general case, damped harmonic oscillator with external
force. Corresponding equation of motion is

x
+ x + 2 x = f.
We already know the general solution of homogeneous equation (with f = 0), therefore
we look only for the particular solution of the full inhomogeneous equation. As before,
we assume f = f0 ei t . Again, suppose that the particular solution is oscillating with
the same freqeuency,

x
(t) = A ei t .
Inserting this into the equation of motion and expressing the amplitude we nd

A =

f0
= f0 ei ,
2 + i

where we denoted and

ei =

1
.
2 2 + i

Multiply the numerator and denominator by 2 2 i (the complex conjugate of


denominator) to nd

ei =

2 2 i
.
( 2 2 )2 + 2 2

3The module is given by

2 =

1
1
1

=
.
2 2 + i 2 2 i
( 2 2 )2 + 2 2

The phase can be computed from the fact that tan is the ratio of imaginary and real
part of the complex number, in our case

tan =

.
2

If we now take the solution

4.2. LAGRANGES EQUATIONS IN MAPLE

73

Figure 4.13: Damped harmonic oscillator without external force.

x
(t) = A ei t = f0 ei (+ t) ,
we can see, that the frequency of the solution is the same as the frequency of the force,
but the phase of the solution is shifted by constant . Now, even for = we nd
1 i ( t + /2)
x
(t) = f0
e
.

The solution is not divergent as before, but it is shifted by /2 against the driving force.
At the end, we nd the solution with Maple.
with(Mechanics):
SetVariables([x], t):
L := (1/2)*(diff(x(t), t))^2-(1/2)*omega^2*x(t)^2:
Q := t -> [ f*cos(omega*t) ]:
R := (1/2)*mu*(diff(x(t), t))^2:
eqs := LagrEqsIII(L, R, Q(t));
X := unapply(rhs(GeneralSol(eqs)), t):
vals := {f = 1/3, mu = 1/5, Omega = 2, omega = 1, q[1] = 5, v[1] = 2}:
y1 := unapply(subs(vals, X(t)), t):
y2 := unapply(subs(vals, Q(t)[]), t):
plot([y1(t), y2(t)], t = 0 .. 20*Pi)
The result is on gure 4.14. Interpret it physically!

74

CHAPTER 4. LAGRANGES EQUATIONS

Figure 4.14: Damped harmonic oscillator with external force.

Chapter 5

Hamiltons equations

We hope that the reader is now familiar with Lagranges formalism and its implementation in Maple. Lagranges equations are equivalent to Newtons law of force, but they
can be written down in an arbitrary coordinate system. In addition, we need only one
scalar function, the Lagrangian, to describe the system. Lagranges formalism is very
fundamental concept and appears not only in classical mechanics. In fact, all modern
theories (quantum eld theory, general relativity, but also string theory) are formulated
in the frame of Lagranges formalism.
There is, however, another approach how to equivalently formulate the laws of Newtons dynamics Hamiltons formalism. It has all advantages of Lagranges formalism:
the system is described by one scalar function, the Hamiltonian, and equations of motion,
Hamiltons equations, can be directly written down in an arbitrary coordinate system.
Another advantage is that Hamiltons equations are formally of the rst order, while
Lagranges equations are of second order. Hamiltons formalism is useful when we study
the evolution of the system in time. For this reason the Hamiltonian formalism is more
important in statistical or quantum physics, where the dependence of the state of the
system on time is a central question. Also in this textbook we study the evolution of
chaotic systems and primarily Hamiltons formalism will be used. On the other hand,
in relativistic theories, where there is no formal dierence between spatial and time coordinates, Hamiltons formalism plays secondary role and the Lagrangian approach is
emphasized. There is a deep geometrical connection between Lagranges and Hamiltons
approach. From this point of view, both approaches are complementary or dual, but we
do not discuss this connection here.

5.1

Derivation of Hamiltons equation

Recall that Lagrangian is a function of generalized coordinates and generalized velocities,


and possibly of time, L = L(q, q,
t). Typical Lagrangian of the particle is (in Cartesian
coordinates)

L =

1
m v2 V
2

1
m x i x i V (x).
2
75

76

CHAPTER 5. HAMILTONS EQUATIONS

Equations of motion are Lagranges equations


d L
L
=
.
dt x i
xi
For this particular Lagrangian we have
L
x i

= m x i .

But this is the momentum

pi = m x i .
The potential does not depend on the velocity and the kinetic energy does not depend
on the position, so
L
xi

V
.
xi

We can see that in Cartesian coordinate system Lagranges equations immediately reduce
to Newtons law of force:

pi =

V
= Fi .
xi

Inspired by this observation, we can dened the generalized momentum pa in an arbitrary


curvilinear coordinate system by

pa

L
.
qa

(5.1)

In Cartesian coordinates and with conservative forces, the generalized momentum is equal
to ordinary linear momentum, but in general it is diferrent. For example, in the case of
electromagnetic eld, the Lagrangian is given by (4.25),

L =

1
m v 2 e + e A v.
2

The generalized momentum is then

pi = m vi + e Ai = m x i + e Ai .
The generalized momentum is therefore in general dierent from ordinary kinematical
momentum.
In Lagranges formalism, generalized coordinates qa and generalized velocities qa are
treated as independent variables. In Hamiltons formalism, velocities are replaced by
generalized momenta. Instead of Lagrangian depending on coordinates and velocities we

5.1. DERIVATION OF HAMILTONS EQUATION

77

need another scalar function depending on coordinates and momenta. In general, the
transition from one set of variables to the other set is known as Legendre transformation.
Consider function f = f (x1 , . . . xn ) f (x). Its total dierential is

df =

f
f
dxi
dxi .
xi
xi
i=1

Conversely, if from equation

df = yi dxi
we can deduce that function f depends on variables xi and yi = f /xi . Suppose now
that we want to construct function F depending on variables yi = f /xi from function
f depending on xi . That is, we want a function F = F (y) for which

dF = hi dyi .
where hi = F/yi . This is easy to achieve, since by Leibniz rule we have
df = yi dxi = d (xi yi ) xi dyi ,
or equivalently,

d (xi yi f ) = xi dyi .
On the right hand side we have exactly what we want. Dene

F = xi yi f.
Then

dF = xi dyi ,
which means

F = F (y)

and xi =

F
.
yi

Function F is the Legendre transform of function f .


We can apply this method to our case. Since L = L(q, q,
t), its dierential is

dL =

L
L
L
dqa +
dqa +
dt.
qa
qa
t

78

CHAPTER 5. HAMILTONS EQUATIONS

Now we want to replace variables qa by pa = L/qa . We dene the Hamiltonian H as


the Legendre transform of the Lagrangian:

= pa qa L.

(5.2)

Its total dierential is

dH = pa dqa + qa dpa dL.


Lagranges equations say that pa = L/qa . Then we have

dH = qa dpa pa dqa +

L
dt.
t

(5.3)

From the last expression we nd that Hamiltons function H is function of qa , pa


and t as we wanted. Moreover, since the coecients standing in front of dierentials are
partial derivatives, we arrive at Hamiltons equations

qa =

H
,
pa

pa =

H
.
qa

(5.4)

Hamiltons equations are of the rst order. Because of their symmetric form thay are
sometimes called canonical equations. Since qa and pa are independent variables, we can
imagine that they are coordinates on some abstract 2ndimensional space (manifold)
called phase space. The state of the system is determined by 2ntuple of coordinates

z = (q1 , . . . qn , p1 , . . . pn ) .
Thus the state of the system can be represented by a point in the phase space. Hamiltons
equations then determine the evolution of the system in time, i.e. motion in the phase
space. These matters will be discussed later.
In the most cases, the Hamiltonian has important physical meaning. Suppose that
constraints are time-independent, i.e xi = xi (q) and xi /t = 0. In addition, suppose
that forces are conservative. Kinetic energy is then

L =

1
1 xi xi
m x i x i = m
qa qb gab qa qb .
2
2 qa qb

Coecients gab form what is called metric tensor on the conguration space. Obviously

qa

T
qa

= 2 m gab qa qb = 2 T.

This is a special case of more general Eulers formula for homogeneous functions. T
is homogeneous function of degree 2, i.e. qa 7 qa leads to T 7 2 T . In general, if
f = f (x) is homogeneous function of degree N ,

5.1. DERIVATION OF HAMILTONS EQUATION

79

f ( x) = N f (x).
Dierentiate it with respect to ;

xi

f
(x) = N N 1 f (x).
xi

Finally, for = 1 we arrive at Eulers formula

xi

f
xi

= N f (x).

For f = T (q),
N = 2, Eulers formula leads to qa T / qa = 2T , which is the previous
result.
Let us now evaluate the Hamiltonian:
H = pa qa L = qa

L
(T V ) = 2 T (T V ) = T + V.
qa

Thus, Hamiltonian is the sum of kinetic and potential energy, i.e. Hamiltonian is the
total energy. This statement does not hold in general, only under given assumptions and
some other cases.
Summa summarum, while in Lagranges formulation variables describing the system
are generalized coordinates and velocities, if Hamiltons picture velocities are replaced
by generalized momenta. Hamiltonian, which is the Legendre transform of Lagrangian,
is therefore function of coorinates, momenta and possibly of time:
H = H(q, p, t).
In many physically interesting situations Hamiltonian is equal to the total energy of the
system. In any case, equations of motion are given by Hamiltons equations

qa =

H
,
pa

pa =

H
,
qa

a = 1, 2, . . . n,

where n is the number of degrees of freedom.


State of mechanical system described by Hamiltonian H(q, p) is completely determined by values of qa and pa . We can imagine that qa , pa are coordinates on abstract
2ndimensional space of states of the system. This abstract space is called phase space
and each point of the phase space corresponds to one state. Hamiltons equations determine evolution of the state in time. The solution of Hamiltons equations conists of 2n
functions

qa = qa (t),

pa = pa (t).

These functions then dene a trajectory (or orbit) in the phase space. Hamiltonian
system is a special case of dynamical system. This notion is discussed in later chapters.

80

5.2

CHAPTER 5. HAMILTONS EQUATIONS

Integrals of motion

If the number of degrees of freedom is n, we have 2n Hamiltons equations: n equations


for qa (t) and n equations for pa (t). They are of rst order, so the solution contains 2n
integration constants C1 , C2 , . . . C2n . Formally we can write
qa (t) = qa (C1 , . . . C2n , t),

pa (t) = pa (C1 , . . . , Cn , t),

which means that solution depends on 2n constants C1 , . . . Cn . Inverting these relations


we nd

CI = CI (q1 , . . . , qn , p1 , . . . pn , t), I = 1, 2, . . . 2n.


In other words, there exist 2n constant functions CI . These functions depend on dynamical variables qa and pa and on time, but their total time derivative is zero, since CI are
constants:
dCI
dt

= 0.

Dynamical quantities, i.e. quantities depending on coordinates, momenta and time,


which are constant are called integrals of motion or rst integrals. We also say that CI
are conserved quantities. Of course, any function f = f (C1 , . . . C2n ) is also constant in
time and therefore is integral of motion. Finding integrals of motion is an important
task in mechanics, because knowledge of them dramatically simplies the solution of
equations of motion. Sometimes we even do not have to solve Hamiltons equations, if
we know integrals of motion!
The most important conserved quantity is energy. We have shown that Hamiltonian
is usually equal to the total energy of the system, H = E. Total time-derivative of
Hamiltonian is
dH
H
H
H
H
=
qa +
pa +
=
,
dt
qa
pa
t
t
where we used Hamiltons equations. We can see that if the Hamiltonian does not
explicitly depend on time, then the energy is conserved.
Suppose that Hamiltonian does not depend on coordinate qb for some xed b, i.e.
H/qb = 0. Coordinate qb is then called cyclic and Hamitlons equations immediately
give

pb = 0,
which means that momentum pb is constant of motion. Let us see two simple examples.
In previous chapter we studied particle in homogeneous gravitational eld. Lagrangian
of particle is given by (4.22), which implies Hamiltonian
H =

)
1 ( 2
m x + y 2 + m g y.
2

81

5.2. INTEGRALS OF MOTION

Generalized momenta are px = mx and py = my,


which are Cartesian components of
ordinary linear momentum p = mv. Hamiltonian does not depend on coordinate x, so
the corresponding momentum is conserved:

px = 0,
or equivalently

x
= 0.
In other words, xcomponent of the velocity is constant. This is what we expect, because
there is no force acting in xdirection.
Less trivial example is particle moving in the sphericaly symmetric gravitational eld
produced by an immovable point mas. We introduce spherical coordinates with the origin
in the point mass, so that r is distance of our particle from the source of gravitation.
Then the gravitational force is proportional to r2 and points to the origin. Potential of
such force is

m
,
r

where m is the mass of test particle and = M , where is gravitational constant and
M is the mass of the source. The Lagrangian therefore is

L =

1
m v2 V
2

(
)]
1 [ 2
m
m r + r2 2 + sin2 2
+
.
2
r

Generalized momenta are

pr

= m r,

= m r2 ,
= m r2 sin2 .

(5.5)

Comparing this with (3.21) we can see that p is actually zcomponent of angular
momentum lz . Since Lagrangian does not depend explicitly on coordinate ,
L
= 0,

coordinate is cyclic and momentum p is conserved. So, we arrive at conservation law


for the zcomponent of angular momentum:

lz = const.
Let A = A(q, p, t) be an arbitrary dynamical quantity. Its total time derivative is

82

CHAPTER 5. HAMILTONS EQUATIONS

dA
A
A
A
=
qa +
pa +
.
dt
qa
pa
t
Using Hamiltons equations again we arrive at

A =

A H
A H
A

+
.
qa pa
pa qa
t

This combination of quantities A and H appears frequently and has an important meaning, especially in quantum mechanics.
In general, for two dynamical variables A and B we dene their Poissons brackets as

{A, B}

A B
A B

.
qa pa
pa qa

(5.6)

The time-derivative is then


A
A = {A, H} +
.
t
In this notation we can say that quantity A is integral of motion, if it does not explicitly
depend on time and its Poissons brackets with Hamiltonian vanish:

A(q, p) = const.

{A(q, p), H} = 0.

(5.7)

Poissons brackets play an important role in the abstract formulation of Hamiltonian


dynamics. They satisfy following properties (check them!)
linearity
{A + B, C} = {A, C} + {B, C} , where is a constant;
antisymmetry
{A, B} = {B, A};
Jacobi identity
{A, {B, C}} + {B, {C, A}} + {C, {A, B}} = 0.
Because of antisymmetry Poissons brackets are linear also in the second argument
(prove). Operation satisfying above properties is in general called Lie brackets and
denes Lie algebra. Poissons brackets are therefore Lie brackets acting on the space of
dynamical variables. In quantum mechanics dynamical variables are replaced by operators on Hilbert space. Poissons brackets are replaced by commutators of operators, i.e.
by expressions of type [A, B] = AB BA (operators in general do not commute). Commutators are also Lie brackets. The crucial point is that there is simple relation between
Poisson brackets in classical mechanics and commutators in quantum mechanics: they
are same (up to multiplicative factor i~). A lot of relations of Hamiltons formalism thus
can be translated to quantum mechanics.

5.3. VARIATIONAL DERIVATION OF HAMILTONS EQUATIONS

83

The most simple dynamical variables are of course coordinates qa and momenta pa .
They satisfy so-called fundamental Poissons brackets:
{qa , qb } = {pa , pb } =
{qa , pb } =

5.3

0,
ab .

(5.8)

Variational derivation of Hamiltons equations

In section 4.1.3 we have shown that Lagranges equations can be derived from Hamiltons
variational principle
S = 0,
where the action S is given by
t2
L(q, q,
t) dt.

S =
t1

Hamiltonian and Lagrangian are connected by Legendre transform H = pa qa L. The


action is therefore equal to

S =

(pa qa H(q, p, t)) .

(5.9)

If we now vary the action with respect to pa and qa , we obtain Hamiltons equations.
The variation is
)
(
H
H
S =
pa qa + qa pa
qa
pa dt.
qa
pa
We have three variations under the integral sign: qa , pa and qa . We know, however,
that in Hamiltons formulation of mechanics only coordinates qa and momenta pa are
independent. In order to get rid of qa we integrate per partes:

t
[pa qa ]t21

pa qa dt =

pa qa dt.

The rst term on the right hand side vanishes as the variation qa is zero on the boundary.
For the variation of action we thus nd
{(

S =

dt

H
pa +
qa

(
)
}
H
qa qa
pa
= 0.
pa

Since variation qa and pa are independent, and the time interval (t1 , t2 ) as well, the
last equation can be fullled only when Hamiltons equations hold:

qa =

H
,
pa

pa =

H
.
qa

84

CHAPTER 5. HAMILTONS EQUATIONS

5.4

Canonical transformations

Lagranges equations are covariant with respect to the change of coordinates, i.e. if we
change generalized coordinates qa to new coordinates qa , Lagranges equations do not
change their form:
d L
L

dt qa
qa

= 0.

In Hamiltons formalism, generalized coordinates and generalized momenta are considered as independent variables. As mentioned, they constitute a coordinate chart on the
phase space of the system. The question now is, whether there are coordinates transformations (qa , pa ) 7 (qa , pa ) preserving the form of Hamiltons equations. In fact, such
transformations exist and we are going to discuss their properties.
Suppose that we have a coordinate transformation
qa = qa (q1 , . . . qn , p1 , . . . pn ),

pa = pa (q1 , . . . , qn , p1 , . . . pn ).

(5.10)

Under this transformation the Hamiltonian transforms as


H 7 H .
In addition, we require that Hamiltons equations do not change their form, i.e. in new
coordinates the equations of motion read

qa =

H
,
pa

pa =

H
.
qa

Recall that Hamiltons equations can be derived from the variational principle with
action given by (5.9). Both triples (qa , pa , H) and (qa , pa , H ) should lead to Hamiltons
equations. So, we have two actions S and S with zero variation:

(pa qa H) dt = (pa qa H ) dt = 0.
|
{z
}
|
{z
}
S

Notice that integrands are not independent of each other, because primed and unprimed
quantities are related by (5.10). Since variations of both actions vanish, the actions must
dier by integral of f such that

S S =

f dt,

f dt = 0.

Under variation
qa 7 qa + qa ,

pa 7 pa + pa , q(t1 ) = q(t2 ) = p(t1 ) = p(t2 ),

5.4. CANONICAL TRANSFORMATIONS

85

only boundary values (at times t1 , t2 ) of qa and pa remain xed. Thus, if the variation

of dt is identically zero, the integral must depend only on boundary values:

f dt = F (t2 ) F (t1 ).
In other words, f must be a total derivative of function F with respect to time:

f =

dF
.
dt

Recapitulation. We consider transformation of coordinates (q, p) 7 (q , p ) given by


(5.10), which preserve the form of Hamiltons equations. Such transformations are called
canonical transformations. Since the form of Hamiltons equations is preserved, old and
new coordinates must be related by

pa qa H pa qa + H =

dF
,
dt

(5.11)

where F is some function called generating function. It can depend on time explicitly or
through 4n dynamical variables qa , qa , pa and pa . But these 4n variables are not independent as they are related by transformations (5.10), so we have only 2n independent
variables. We have four possibilities:
F = F (q, q , t),

F = F (q, p , t), F = F (p, q , t), F = F (p, p , t).

First we take generating function


F1 = F1 (q, q , t).
Its total time derivative is
dF1
dt

F1
F1
F1
qa +
qa +
.

qa
qa
t

Inserting this into (5.11) we nd

pa =

F1
,
qa

pa =

F1
F1
.
, H = H +
qa
t

(5.12)

Example. Consider Hamiltonian of particle moving along the axis z in homogeneous


gravitational eld:

H =
Set

p2
+ m g q.
2m

(5.13)

86

CHAPTER 5. HAMILTONS EQUATIONS

F1 (q, q , t) = q q .
From (5.12) we get

p = q ,

p = q,

H =

q
m g p .
2m
2

If we derive Hamiltons equations from H and express primed variables in terms of


unprimed ones, we arrive at Hamiltons equations derived from original Hamiltonian
H. This transformation is therefore canonical. Notice that considered transformation
replaced the roles of momentum p and coordinate q. It is an illustration of the fact that
momenta and coordinates are treated as independent variables.
The second type of generating function is
F2 = F2 (q, p , t).
Function F1 can be obtained from F2 by Legendre transform
F1 (q, q , t) = F2 (q, p , t) qa pa .
Then
dF1
dt

F2
F2
F2
p +
qa +
qa pa pa qa .
qa
pa a
t

Now we substitute F 1 for F into (5.11) and nd

pa =

F2
,
qa

qa =

F2
F2
, H = H +
.

pa
t

Example. Consider again Hamiltonian (5.13) and generating function


F2 (q, p , t) = q p .
Equations (5.14) give
p = p ,

q = q.

This transformation is therefore an identity.


Third kind of generating function is
F3 (p, q , t) = F1 (q, q , t) qa pa .
Derivative of F1 with respect to time is

(5.14)

5.5. MOTION AS CANONICAL TRANSFORMATION

dF1
dt

= =

87

F3
F3
F3
pa +
q +
+ pa , qa + qa pa .
pa
qa a
t

From (5.11) we get

qa =

F3
,
pa

pa =

F3
F3
, H = H +
.
qa
t

(5.15)

For example, if we take


F3 (p, q , t) = p q ,
new variables are
q = q ,

p = p.

This simple canonical transformation is therefore an inversion changing the sign of all
variables.
Finally, we dene fourth type of generating function
F4 (p, p , t) = F1 (q, q , t) + pa qa pa qa .
In this case we have
dF1
dt

F4
F4
F4
p +
pa +
+ qa pa + pa qa qa pa pa qa .
pa
pa a
t

Inserting this into (5.11) we arrive at

qa =

F4
,
pa

qa =

F4
F4
, H = H +
.
pa
t

(5.16)

Examples on canonical transformations shown here are trivial, but later we will see how
useful canonical transformations can be.

5.5

Motion as canonical transformation

In the example in the previous section we have seen a special case of identical transformation. In general, identical canonical transformation can be realized by generating
function F2 (q, p , t) of the second kind. Dene
F2 (q, p , t) = qa pa .
Then, by (5.14), we have

88

CHAPTER 5. HAMILTONS EQUATIONS

pa =

F2
= pa ,
qa

qa = qa ,

which is identity. This representation is useful when we work with transformation which
is close to identity. Such transformation is called innitesimal canonical transformation
and has form
F2 (q, p , t) = qa pa + G(q, p , t), || 1,
so that

pa = pa +

G
,
qa

qa = qa +

G
.
pa

Thus, under innitesimal transformation


qa 7 qa + qa ,

pa 7 pa + pa ,

where

qa = qa qa =

G
G
, pa = pa pa =
.
qa
pa

Obviously, putting
= dt, qa = dqa , pa = dpa , G = H,
we obtain
dqa
H
=
,
dt
pa

dpa
H
=
.
dt
qa

In this sense Hamiltons equations are equivalent to innitesimal transformation with


Hamiltonian as generating function. We can say that the real motion is continuous
canonical transformation generated by Hamiltonian. This remarkable and fundamental
property is claried in the next section devoted to Hamilton-Jacobi equation.

5.6

Hamilton-Jacobi equation

Suppose that functions qa = qa (t) and pa = pa (t) form solution of Hamiltons equations.
Then we can dene the action as function of time:
t
(pa (t) qa (t) H(q(t), p(t), t)) dt.

S(t) =
t0

89

5.6. HAMILTON-JACOBI EQUATION

Then the total dierential of the action reads

dS(t) = pa (t) dqa (t) H(q(t), p(t), t) dt,


which immediately implies

pa =

S
,
qa

S
= H.
t

(5.17)

We can see that momenta pa are derivatives of the action with respect to generalized
coordinates. In other words, momenta pa are components of the gradient of the action
with respect to generalized coordinates:
(
pa = (S)a a S,

S =

S
S
,...
q1
qn

)
.

If we replace pa by S/qa in second equation in (5.17), we arrive at Hamilton-Jacobi


equation

S
+ H (q, S, t) =
t

0.

(5.18)

Hamilton-Jacobi equation is equation for the action S as the function of coordinates qa


and time t. It is single rst-order non-linear equation. The non-linearity follows from the
presence of pa = a S, since momentum enters Hamiltonian quadratically. HamiltonJacobi equation has essentially two dierent interpretations. First we discuss Jacobis
method of derivation of this equation.
Hamiltons equations are formally of the rst order, but this advantage is often only
virtual, because momenta and coordinates are usually mixed. In order to separate unknown variables we thus have to convert Hamiltons equations into second order equations, i.e. Lagranges equations. The idea of Jacobis method is to transform variables
qa and pa by canonical transformation, so that new coordinates and momenta will be
constant. Resulting Hamiltons equations then can be integrated directly.
Consider canonical transformation with generating function
S = S(q, p , t).
This function is also called Hamiltons principal function. It is generating function of the
second kind, so we have

qa =

S
S
S
, H = H +
.
, pa =

pa
qa
t

If we choose H = 0, transformed coordinates qa , pa are trivially constant, since Hamiltons equations do not change their form under canonical transformation:

90

CHAPTER 5. HAMILTONS EQUATIONS

qa =

H
= 0,
pa

pa =

H
= 0.
qa

To achieve this we must solve equation


H +

S
= 0.
t

This is again the Hamilton-Jacobi equation. Using pa = a S we can write this equation
in more detailed form
H(q, S) +

S
(q, p , t) = 0.
t

This rst-order equation contains n + 1 derivatives: a S, a = 1, . . . n, and t S. The


solution therefore contains n + 1 integration constants. Obviously, one of this constant
is additive, i.e. if S is solution, then S+constant is also a solution. Since we need only
partial derivatives of S, this additive constant does not matter and can be set to zero.
Remaining n constants will be denoted by 1 , . . . n . The solution S therefore depends
on n integration constants a . On the other hand, we started with function S depending
on coordinates qa and constant momenta pa . Thus, we can identify these integration
constants and transformed constant momenta:
S = S(q, , t), = (1 , . . . n ), a = pa .
Next we denote = (1 , . . . n ), where a = qa , so that

a =

S
(q, , t).
a

From these equations we can express old coordinates qa as a function of constants, ,


and time:

qa = qa (, , t).
Old momenta are then given by

pa =

S
(q, , t).
qa

Recapitulation. In order to solve the equations of motion we rst solve HamiltonJacobi equation. The solution is

S = S(q, , t),
where is an ntuple of integration constants. S is generating function of canonical
transformation which sets Hamiltonian equal to zero and transformed coordinates and
momenta to be constant, i.e.

91

5.6. HAMILTON-JACOBI EQUATION

a =

S
(q, , t) = constant.
a

These equations can be solved with respect to qa = qa (, , t). Momenta are then given
by pa = a S. Constants and can be found from initial conditions. Functions
qa = qa (, , t),

pa = pa (, , t),

then constitute the solution of equations of motion.


Hamiltons principal function S has interesting physical meaning. Its time derivative
reads
dS
S
S
=
qa +
dt
qa
a
|{z}

a
|{z}
a =const.

pa

S
= pa qa H = L.
t
|{z}
H

In other words,

S =

L dt.

We can see that generating function which solves Hamilton-Jacobi equation is in fact the
action of the system.

5.6.1

Harmonic oscillator

In this section we show how Hamilton-Jacobi method can be used to solve the equations
of motions of harmonic oscillator. For the sake of simplicity, we take the Hamiltonian of
harmonic oscillator in the form

H =

p2
1
+ q2 .
2
2

We want to nd canonical transformation with the generating function S = S(q, P, t) such


that new Hamiltonian vanishes and equations of motion in termse of new coordinates
Q, P become trivial. Thus, we need to solve the Hamilton-Jacobi equation

H(q, p) +

S
(q, , t) = 0,
t

where is the constant of integration. Recall that for this kind of canonical transformation we have

S
, = 0,

p =

S
.
q

Because Hamiltonian does not depend explicitly on time, we can write the generating
function S in the form

92

CHAPTER 5. HAMILTONS EQUATIONS

S(q, , t) = t + W (q, ).
Function W is called Hamiltons characteristic function Substituting this into HamiltonJacobi equation we nd

= H.
But time-independent Hamiltonian is equal to the total energy E and it is conserved, so
we have

S(q, E, t) = E t + W (q, E),


and Hamilton-Jacobi equation becomes

H(q, p) = E.
We have replaced the constant of integration by energy E = . Generalized momentum is

p =

S
W
=
.
q
q

Using the explicit form of the Hamiltonian we have

1
2

W
q

)2
+

1 2
q = E,
2

so that nal form of Hamilton-Jacobi equation is

W
=
2 E q2 .
q
This can be integrated directly but for us it is sucient to write the solution in the form

W (q, E) =


2E q 2 dq.

Now, the transformed coordinate is


S

=
= t +
E
E


2E q 2 dq.

Since we integrate through variable q, but dierentiate with respect to E, we can change
the order of integration and dierentiation, i.e.

5.6. HAMILTON-JACOBI EQUATION

93

1
q

dq = t + arcsin .
2
2E
2E q

= t +

From this we nd the general solution

q(E, , t) =

2E sin(t + ).

The momentum is

p(E, , t) =

2E q 2 = 2E cos(t + ).

Imposing conditions

q(E, , 0) = A,

p(E, , 0) = 0,

we arrive at

,
2

E =

1 2
A ,
2

which gives familiar solution

q(t) = A cos(t)
for the oscillator, whose displacement at time t = 0 is equal to the amplitude. We can
also see that the energy of the oscillator is proportional to the square of amplitude, which
is well-known fact.
At the end if this section we compute Hamiltons characteristic function W . Its time
derivative is
dW
W
(q, E) =
q = p q.

dt
q
W can be therefore expressed as

W =

p q dt =

p dq.

In the case of harmonic oscillator we have already derived relation



W =
2E q 2 dq.
In order to evaluate this integral, we rst consider integral

94

CHAPTER 5. HAMILTONS EQUATIONS

I =


1 x2 dx.

We use the substitution x = sin , dx = cos d, so that 1 x2 = cos :

I =

cos2 d.

Using familiar relations cos = (1 + cos 2)/2 and sin 2 = 2 sin cos , we nd

I =

1
1
+
sin cos .
2
2

Returning to the original variable x we arrive at



1
1
arcsin x.
1 x2 = x 1 x2 +
2
2
Hamiltons characteristic function therefore is

W =

5.7

1
q
q 2E q 2 + E arcsin .
2
2E

Hamiltons equations in Maple

In this section we extend our library Mechanics again by implementing some functions
connected to Hamiltons formalism. First we modify our old procedure SetVariables:
SetVariables := proc (vars::list, time)
local i;
t := time;
VarNames := vars;
varN := nops(vars);
subst1 := {}; subst2 := {}; substP := {}; substPInv := {};
Momenta := NULL;
for i to varN do
subst1 := subst1 union
{diff(vars[i](t), t) = v[i], vars[i](t) = q[i]};
subst2 := subst2 union
{q[i] = vars[i](t), v[i] = diff(vars[i](t), t)};
substP := substP union
{p[i](t) = p[i]});
substPInv := substPInv union
{p[i] = p[i](t)};
Momenta := p[i], Momenta;

5.7. HAMILTONS EQUATIONS IN MAPLE

95

end do;
Momenta := [Momenta];
NULL;
end proc;
We create new substitution rules substP, substPInv, assuming that momentum conjugated
to variable vars[i] is simply p[i]. New substitution rules replace pi (t) by pi and vice versa.
Variable Momenta contains names of the momenta, implicitly
Momenta = { p[1], p[2], ... p[varN] };
In order to allow dierent names for momenta we can add procedure SetMomenta with
clear meaning:
SetMomenta := proc (mom::list)
local i;
substP := {}; substPInv := {};
for i to varN do
substP := substP union {mom[i](t) = p[i]};
substPInv := substPInv union {p[i] = mom[i](t)};
end do;
Momenta := mom;
NULL;
end proc;
Following procedure computes Hamiltonian from given Lagrangian using Legendre
transformation.
Hamiltonian := proc (L)
local l1, momenta, H, subst3, i;
l1 := subs(subst1, L);
momenta := [seq(diff(l1, v[j]), j = 1 .. varN)];
subst3 := {seq(v[i] = solve(momenta[i] = p[i], v[i]), i = 1 .. varN)};
H := simplify(subs(subst3, sum(p[j]*v[j], j = 1 .. varN)-l1));
for i to varN do
H := subs({p[i] = Momenta[i](t), q[i] = VarNames[i](t)}, H)
end do;
H;
end proc;
Brief description. As usually, variables and velocities are replaced by symbols qi and vi .
Then the momenta L/ qi are calculated. Hamiltonian is a function of qi and pi , so
the velocities vi must be expressed through pi and this is done using solve command.

96

CHAPTER 5. HAMILTONS EQUATIONS

Finally, Hamiltonian is calculated as H = pi qi L and auxiliary symbols q[i] and p[i]


are replaced by vars[i] and Momenta[i].
Hamiltons equations are derived in procedure HamiltonEqs:
HamiltonEqs := proc (H)
local i, eqs, h, s;
eqs := NULL;
h := subs(subst1, subs(substP, H));
s := subst2 union substPInv;
for i to varN do
eqs := eqs, diff(VarNames[i](t), t) = subs(s, diff(h, p[i])),
diff(Momenta[i](t), t) = -subs(s, diff(h, q[i]));
end do;
[eqs];
end proc;
We have to write a new procedure for solving Hamiltons equations, because we have
dierent initial conditions, because conditions are not imposed on the velocities but on
momenta.
GeneralHSol := proc( eqs ::list)
local i, initconds, eqs2;
initconds := NULL:
eqs2 := eqs[]:
for i from 1 to varN do
initconds :=VarNames[i](0)=VarNames[i][0],
Momenta[i](0)=Momenta[i][0],initconds:
end do;
dsolve( {eqs2, initconds} );
end proc;
As an example, we solve Hamiltons equation for harmonic oscillator:
with(Mechanics);
SetVariables([x], t);
SetMomenta([p]);
H := p(t)^2/(2*m)+(1/2)*m*omega^2*x(t)^2;
eqs := HamiltonEqs(H);
sol := GeneralHSol(eqs);
Compare obtained solution with solution found in Lagranges formalism!
What is the phase trajectory of harmonic oscillator?

97

5.8. MATHEMATICAL PENDULUM

r
y = r cos
r
x = r sin

Fg
Figure 5.1: Mathematical pendulum

5.8

Mathematical pendulum

Harmonic oscillator is the most simple example of the oscillator. We can imagine it as
the system of one xed point, one point particle which can move only in one direction,
and the ideal spring connecting the particle and the xed point. More realistic but also
more complicated system is the mathematical pendulum in homnogeneous gravitational
eld, gure 5.1. It consists of the xed point C, point mass m and massless thread of
length r. We assume that the thread cannot be deformed, so that the distance r of the
mass from the point O is constant. Angle between the thread and the vertical axis y
is denoted . If = 0, the pendulum is in equilibrium position. For non-zero the
gravitational force Fg = mg has non-zero torque and acts as a restoring force. We start
the analysis by deriving the equation of motion in a standard way, then we use Lagranges
and Hamiltons formalism. We assume that Cartesian system (x, y) with the origin I is
introduced.
Direct application of Newtons law in Cartesian coordinates is not as straightforward
as it can seem. In Cartesian coordinates we have

mx
= Fx ,

m y = Fy .

Here, Fx and Fy are Cartesian components of the force acting on the point mass m. But
what are these forces equal to? Apparently, Fy = mg and Fx = 0, since the gravitational
force is vertical and there is no horizontal force. This is wrong, however, for the point
mass is also interacting with the thread realizing the constraint x2 +y 2 = r2 . Thus, there
is also some horizontal force!
It is more useful to consider dierent directions than those of Cartesian axes, namely,
the direction tangential to the trajectory of the pendulum and the direction normal
(orthogonal) to it. It should be clear from gure 5.2, tangential and normal components
of the force Fg = mg are

98

CHAPTER 5. HAMILTONS EQUATIONS

O
x2 + y 2 = r 2

r
m
FN

Ft

Fg

Figure 5.2: Tangential and normal components of the gravitational force Fg .

Ft = m g sin ,

FN = m g cos .

The normal component causes the tension of the thread, while the tangential components
causes the acceleration of the pendulum. As it is known from elementary mechanics, the
angular acceleration and circumference acceleration at are related by
r = at .
Acceleration at is at = Ft /m by Newtons law, and therefore the equation of motion is
m r = Ft ,
or, after substitution for Ft ,
r = g sin .
If the constraints are more complicated, this approach is not ecient and we have to use
the Lagrangian or Hamiltonian formulation.
In Lagranges (or Hamiltons) formalism the constraints can be treated by introducing
an appropriate coordinate system. In the present case, it is obvious that the only degree
of freedom is the angle . It is therefore much more convenient to work with this angle
instead of Cartesian coordinates x and y which are not independent but subject to
constraint x2 + y 2 = r2 . Introduce polar coordinates with the origin O by relations

x(t) = r sin (t),

y(t) = r cos (t),

where we explicitly indicate that the angle is the function of time, while the radial
coordinate r is constant. Then the kinetic energy is

5.8. MATHEMATICAL PENDULUM

T =

99

)
1
1 ( 2
m x + y 2 = m r2 2 .
2
2

Potential energy is V = mgh, where h is the height of pendulum above the level of
zero energy. This zero level can be chosen arbitrarily, because the force is given by the
gradient of V and the gradient of constant is zero. We set V = 0 at the level of the point
O. If the pendulum is higher than O, its potential energy is positive, if it is lower, the
energy is negative. Picture 5.1 shows that potential energy of the pendulum is

= m g r cos .

The Lagrangian is therefore

L = T V

1
m r2 2 + m g r cos .
2

The generalized momentum conjugated to is

p =

= m r2 .

Notice that this is actually the angular momentum, because v = r is the circumference
velocity and thus p = mvr. We can see again that generalized momentum coincides with
usual linear momentum only in Cartesian coordinates.
Derivation of Lagranges equations (there is in fact only one) is straightforward and
easy:
g
+
sin
r

0.

(5.19)

It is the same equation as we derived above. If the angle is suciently small, we can
expand the sine into the Taylor series around the point zero:

sin =

1 3
1 5
+
....
3!
5!

For small the higher powers n are negligible compared to 1 . Omitting them we arrive
at

sin
and the equation of motion becomes
g
+ = 0,
r

100

CHAPTER 5. HAMILTONS EQUATIONS

which is the equation of harmonic oscilator with angular frquency g/r and we have
already analyzed this equation and its solutions. Here we want to examine the properties
of full non-linear equation (5.19).
Well, now we have the equation of motion, but the other thing is to solve it. Although
our equation looks relatively simple, it cannot be solved. More precisely, the solution
exists, but it cannot be expressed as a nite combination of elementary functions (elementary functions are polynomials, trigonometric functions, exponential function and
functions inverse to them). It is not because mathematicians are not clever enough,
but because elementary functions form too poor set of functions. This is not a big
surprise, however. Function is, from the mathematical point of view, arbitrary rule
assigning number y to a number x. Elementary functions are only very special examples
of such rule. Imagine Cartesian coordinate system and draw arbitrary curve such that
its direction is never vertical (otherwise you assign more numbers y to one number x).
Such a curve is graph of some function y = y(x), but there is no reason to expect that
it is expressible in terms of elementary functions. It is in fact a miracle that so many
physically interesting equations have simple solutions. On the other hand, the most
of these equations describe highly idealized situations, which are extremely useful for
understanding the main features of the problem, but they are not too realistic. Take
Newtons gravitational law as an example. In order to understand the properties of
gravitational force we study the two-body problem of two massive bodies orbiting about
their common centre (centre of mass). In this case, the equations of motion can be
solved explicitly and we nd that both bodies are moving along ellipses according to
Keplers laws. The solution illustrates basic properties of the gravitational force, e.g. the
conservation of energy or angular momentum, and it is nice and understandable model
of the Sun and, say, Earth. Unfortunately, if we want to describe system of Sun, Earth
and Moon, we fail. Three-body problem cannot be solved analytically, i.e. by elementary
functions. Again, it is not that big surprise, if we imagine how complicated the motion of
Moon with respect to Sun is! The biggest problem is that all three bodies are interacting
with each other. If we can neglect the interaction of two of them, problem is solvable
again. The Solar system, however, consists of the Sun, nine planets (or eight, since Pluto
is not a planet anymore), their satellites, and thousands or milions of other objects. We
cannot expect that solution of Newtons equations for the whole Solar system will be
something like sin(2x) + const. Fundamental theories can be usually applied to idealized
simple situations and corresponding solutions are also relatively simple and illustrative.
Once we apply the theory to a more realistic situation, the elegance is usually lost and
the solution is not only complicated, but we cannot even write it down.
Does it mean that we have to surrender on our way to understand and describe Nature? Not at all. We can predict the motion of planets and stars with an excellent
precision, we can calculate the properties of complicated molecules, we can even predict the motion of mathematical pendulum. Mathematicians and physicists developed
a lot of numerical and analytical methods for the analysis of such complicated realistic
systems. Especially the numerical methods are of great importance today, because the
computational power of modern computers has dramatically increased. This textbook
is not dedicated to numerical methods, but in appendix C reader can nd some very
basic principles of numerical solving of dierential equations. Maple has a lot of built-in
routines implementing numerical methods. Without going into details, we show how
equation (5.19) can be easily solved by Maple.

5.8. MATHEMATICAL PENDULUM

101

Before doing this, however, we rst write equation (5.19) in dimensionless form. The
motivation is that we want to eliminate as many paramters as possible. Equation (5.19)
contains two parameters, g and r. Since they enter the equation only as a ratio g/r, we
can dene

0 =

g
,
r

so that equation becomes


+ 02 sin = 0.
If we denote units of length and time by L and T (in SI system of units we measure
length in meters and time in seconds, i.e. L = m and T = s), we can write the physical
dimensions of g and r as
[r] = L,

[g] = L T 2 .

Dimension of 0 is therefore

[0 ] =

[ ]
g
r

= T 1 .

We can now dene new dimensionless time variable


t = 0 t.
Obviously, [t] = 1. For the derivative with respect to time we have
2
d
dt d
d
d2
2 d
=
= 0 ,
=

.
0
dt
dt dt
dt2
dt
dt2
Thus, our equation acquires form

t) + sin (t) = 0,
(
or, if we omit the tildas,
+ sin

= 0.

(5.20)

We have eliminated parameter 0 , but now the time is not measured in seconds, but in
units 01 . Lagrangian in these new units reads
1 2
+ cos
2
and we will use it from now. We have also set the mass m = 1, because the mass does
not enter the equation of motion.

Numerical solution for initial conditions (0) = 0, (0)


= 1 can be plotted by the
following sequence of commands:
L =

102

CHAPTER 5. HAMILTONS EQUATIONS

Figure 5.3: Numerical solution of pendulum equation.

sol := dsolve({theta(t)+sin(theta(t)) = 0,
theta(0)=0, theta(0)=1}, numeric, range=0..4*Pi):
with(plots):
odeplot( sol, refine=2 );
The result is plotted on gure 5.3. Notice that the period of oscillations is not equal to
2.
Let us now discuss mathematical pendulum in Hamiltons formalism. We can calculate Hamiltonian and Hamiltons equations easily by hand or by our celebrated library
in Maple:
with(Mechanics):
SetVariables([theta], t):
SetMomenta([p]);
L := (1/2)*diff( theta(t), t )^2 + cos(theta);
H := Hamiltonian(L);
eqs := HamiltonEqs(H);
The result is

[d

H :=

dt (t)

1
2

p(t)2 cos (t)

= p(t),

d
dt p(t)

= sin (t)

(5.21)

Hamiltons equations, of course, cannot be solved analyticaly. Their advantage is that


they are of the rst order and thus they dene a dynamical system in the sense to be

5.8. MATHEMATICAL PENDULUM

103

Figure 5.4: Phase diagram of mathematical pendulum.

explained in chapter 6. But although we cannot solve Hamltons equations, we can nd


an analytical expression for the phase trajectories of the pendulum. Since Hamiltonian
does not depend explicitly on time, it is the integral of motion and is equal to the energy
E:
p2
cos = E.
2
Momentum as a function of angle is

p = 2E + 2 cos .
Following Maple code plots phase trajectories for several values of E:
p := (E, theta) -> sqrt(2*(E+cos(theta)));
lst := [seq(p((1/2)*E, theta), E=0..5),
seq(-p((1/2)*E, theta), E=0 .. 5)]:
plot(lst, theta = -3*Pi..3*Pi, color = black, numpoints=1000);
The result is plotted at gure 5.4.
We can see that there are two kinds of trajectories: closed and open. Suppose that
initial angle is 0 < 0 < and initial momentum is p0 = 0. In other words, initial
position in the phase diagram lies on the horizontal axis between points 0 and . Since
momentum is assumed to be zero, it is the position with maximal deection. If we release
the pendulum from this position, the angle will start to decrease and momentum will
start to increase, as the pendulum will approach the equilibrium position. After reaching
it, angle will still decrease to the negative values, but momentum will now decrease too,
until = 0 and p = 0. Now the pendulum returns through the equilibrium position to
the initial point and the process repeats ad innitum. Obviously, the phase trajectory is
a closed curve and the pendulum is in oscillatory regime.

104

CHAPTER 5. HAMILTONS EQUATIONS

If the initial momentum p0 is non-zero, the deection is not maximal, since when
pendulum returns to the initial point, it still has momentum p0 a therefore it is still in
motion, until it reaches position with p = 0 and this is position with maximal deection.
If, however, the initial momentum is big enough, pendulum will reach the vertical position
with = but it will not stop there. In such case the angle will be always increasing
and never returns to 0 . In this regime the pendulum is not oscillating but rotating about
the origin O. The phase trajectory is not closed curve as can be seen at gure 5.4.

Chapter 6

Dynamical systems

We start this chapter by dening the dynamical system in terms of vector elds. The
notion of stability is then dened and ilustrated on dynamical systems with two degrees
of freedom which are described by autonomous system of two ordinary dierential equations. We will see that the behaviour of such system can crucially depend on the initial
conditions.

6.1

Vector elds as dynamical systems

The most general dynamical system is governed by equations

qa (t)

= Fa (q(t), t),

a = 1, 2, . . . n.

(6.1)

Here, N is the number of generalized coordinates qa = qa (t). Fa are functions of coordinates and possibly of time. If Fa does not depend on time explicitly, only through qa ,
the system is called autonomous. Notice that Hamiltons equations (5.4) have the same
form as (6.1), if momenta pa are considered to be independent variables (in Hamiltons
formalism, they are).
From the geometrical point of view, qa are coordinates on the abstract space of
possible states of the system. For example, if x is the displacement of the oscillator from
equilibrium position and p is its momentum, the state of the oscillator is completely
described by two coordinates q1 = x, q2 = p. Thus, we can identify the Euclidean plane
E 2 and the space of states of the oscillator. Solving the equations of motion we obtain
n functions qa = qa (t). They dene a curve, trajectory, in the space of states. At each
point, Fa form components of the vector tangent to the trajectory at that point. Let
us formulate these matters in a more abstract, but very useful and vivid way (reader is
referred to section 3.2 about dierential geometry).
Let M be an abstract manifold of dimension n representing states of dynamical
system. We will call it phase space. We can introduce a coordinate system on M in
an arbitrary way. Usually we choose coordinates adapted to the problem we are dealing
with, but from the physical point of view all coordinate systems are equivalent. The
ntuple of arbitrarily chosen coordinates will be denoted by q = (q1 , . . . qn ) or simply by
105

106

CHAPTER 6. DYNAMICAL SYSTEMS

qa , where a = 1, 2, . . . n. Recall that coordinate chart is in fact ntuple q of mappings


qa : M 7 R. In other words, qa can be understood as mapping which takes the point
P M and returns its ath coordinate qa (P ).
Curve on manifold M is mapping : R 7 M , i.e. mapping which takes a real
number called parameter and returns the point (t) M . This is an abstract denition
independent of the choice of coordinates. But if we want to dene some particular curve,
we have to describe it in terms of some particular coordinates. Coordinate expression of
the curve is mapping = qa , i.e. (t) = qa ((t)). This means that takes value
of parameter t and returns ath coordinate of the point (t). In practice, however, we
usually do not distinguish between the curve and its coordinate expression . Vector
tangent to the curve is denoted by

(t)

d
(t).
dt

If the coordinate expression of the curve is qa (t) = qa ((t)), the components of the
tangent vector are

a = qa (t).
Let F = F (q) be a vector eld. Its components with respect to coordinates qa will
be denoted by Fa = Fa (q). Curve is called integral curve of vector eld F if for each t

(t)

= F ((t)),
i.e. vector tangential to is equal to the value of vector eld F at the point (t). In
coordinates the last equation reads

qa (t) = Fa (q(t)).
This is in fact the system of n ordinary rst-order dierential equations. For each point
P M there is exactly one integral curve passing through this point, so dierent integral
curves never intersect each other. Point P where F = 0 is critical (or xed, or equilibrium
position) and integral curve is trivial mapping (t) = P . Points where F = 0 are called
regular.
Now we dene the important notion of the ow of the vector eld. Take arbitrary
regular point P M and integral curve P passing through P . Without loss of generality
we can set

P (0) = P.
Flow of vector eld F is mapping : R M 7 M dened by

t (P ) = P (t).

6.2. STABILITY OF CRITICAL POINTS

107

In other words, takes real number t and the point P and shifts P by parametric
distance t along the integral curve of vector eld F . Of course, t (P ) for xed P is itself
an integral curve:
d
t (P )|t=0 = F (P ),
dt

qa (t (P )) = Fa (t (P )) .

Flow of vector eld satises obvious but important properties

0 = id.,

t s = t+s ,

where id. stands for identity.

6.2

Stability of critical points

Consider dynamical system given by vector eld F , i.e. dynamical system


t (P ) = F (t (P )).

Solution of this equation is called orbit or trajectory. Let x0 be a critical point, i.e. point
for which F (x0 ) = 0. We know that orbit passing through the critical point is trivial
curve

t (xc ) = x0 .
Trajectory starting in xc will stay in xc forever. The question is how the solution will
change, if we choose another starting point x0 in the vicinity of xc . What are we interested
in is whether corresponding trajectories will approach critical point, or they will run away,
etc.
Critical point xc is called Ljapunov stable if for any neighbourhood U , xc U , there
exists some other neighbourhood V , xc V , such that
x0 V : t > 0 : t (x0 ) U.
In other words, critical point xc is stable if we can choose arbitrary neighbourhood U
of xc and nd point x0 suciently close to xc such that the trajectory starting from x0
never leaves U . So, if the initial conguration is close to xc , then it will remain close for
all later times.
Critical point xc is called asymptotically stable, if there exists a neighbourhood U ,
xc U , such that
x0 U : lim t (x) = xc .
t

If the initial conguration is close to xc , then system will always approach state xc as
t goes to innity. It is a stronger condition than Ljapunov stability, because now the
system not only stays in the vicinity of xc , but converges to xc .

108

6.3

CHAPTER 6. DYNAMICAL SYSTEMS

Classication of critical points

In this section we analyze dierent types of critical (xed) points. For simplicity we
restrict to systems with two degrees of freedom. Such systems are called planar systems,
since the phase space is two-dimensional and phase trajectories can be drawn in the
Euclidean plane coordinatized by variables representing two degrees of freedom. Planar
dynamical system is described by two-component vector eld Fa , written in coordinates,

qa = Fa (q), q = 1, 2.
Critical points qc are solutions of equation

Fa (qc ) = 0.
Vector eld Fa can depend on the variables non-linearly and we will be primarily interested in such cases. On the other hand, analysis of critical points in the most general case,
when Fa are arbitrary functions, is impossible. Henri Poincare introduced a hypothesis
that the behaviour of the system in the neighbourhood of critical point is not very dierent from the behaviour of the linearized system. Thus, we expect that by analyzing linear
systems we nd all important properties of critical points, even for non-linear systems.
The most general linear planar system is governed by equations

x(t)

a11 x(t) + a12 y(t),

y(t)

a21 x(t) + a22 y(t),

(6.2)

where aij are constants. These equations can be written in matrix form

x(t)

= Ax(t).

(6.3)

Here we denoted
(
x =

x(t)
y(t)

(
,

A =

a11
a21

a12
a22

)
.

(6.4)

Solution (x(t), y(t)) of system (6.2) denes a curve in the Euclidean plane called orbit
or trajectory. Given one point (x0 , y0 ) R2 the orbit is uniquely determined, because
the system is of the rst order. Points, where x = 0 are called critical points, because
once the trajectory meets such a point, it stops there.
In fact, system (6.3) can be transformed into system

= Jy,

(6.5)

where y = P x, J = P 1 AP for some matrix P such that J has one of following forms:

6.3. CLASSIFICATION OF CRITICAL POINTS

109

Figure 6.1: Field of linear system (x,


y)
= (x, 2y).

)
1 0
J =
,
0 2
(
)
0
J =
,
0

)

J =
,

(
)

J =
.
0

(6.6)

First we analyze the case when J = diag(1 , 2 ). Real numbers 1 and 2 are two
distinct eigenvalues of matrix J, and therefore also eigenvalues of matrix A. Thus, our
system after diagonalization has form

x = 1 x,

y = 2 y.

(6.7)

We are looking for the solutions of this system for diferrent initial conditions. At any
point x = (x, y), we can compute x = (1 x, 2 x), that is, vector tangential to the
trajectory passing through point (x, y). So to get some information about the character
of trajectories, we can plot tangent vectors in several points of the plane. This can be
easily done in Maple:
lambda[1] := 1;
lambda[2] := 2;
with(plots):
fieldplot( [ lambda[1]*x, lambda[2]*y ], x=-2..2, y=-2..2 );
This plots tangent vectors for values 1 = 1, 2 = 2, gure 6.1. Try several dierent
values of s and see how the pictures changes.
Equations (6.7) can be easily solved analyticaly:

110

CHAPTER 6. DYNAMICAL SYSTEMS

x(t) = x0 e1 t ,

y(t) = y0 e2 t .

So, we can use this solution to plot few trajectories. Imagine that starting points (x0 , y0 )
are uniformly distributed along the circle with the centre in the origin. We want to see
how trajectories passing through these points dier.
#choose some values of lambdas
lambda[1] := -1; lambda[2] := 2;
#parametrically defined trajectory
X := (t, x0) -> x0*exp(lambda[1]*t);
Y := (t, y0) -> y0*exp(lambda[2]*t);
#generate the initial points
lst := NULL:
for i to 20 do
x0 := 5*cos((2*Pi*(1/20))*i):
y0 := 5*sin((2*Pi*(1/20))*i):
lst := lst, [X(t,x0), Y(t, y0), t = 0..2]:
end do:
lst := [lst];
plot(lst);
It is obvious that there is only one critical point the origin (x, y) = (0, 0) (this is
the only point where both x and y vanish). The character of this critical point depends
on the values of 1 , 2 . If 1 , 2 > 0, the critical point is called unstable, see gure
6.2. If both eigenvalues are negative, the critical point is stable. Figure 6.3 is similar to
the previous one (notice, however, dierent ranges on the axes), but the orientation of
trajectories is opposite: they are approaching the centre instead of going away. Finally,
when eigenvalues have opposite signs, critical point is called saddle point, gure 6.4.
Suppose now that matrix J is of the form
(
J =

)
,

where , R. Eigenvalues of this matrix are solutions of secular equation (see appendix
B)

det(J I2 ) =

Since and are real, we have


= i ||,
and therefore
= i .



= ( )2 + 2 = 0.

6.3. CLASSIFICATION OF CRITICAL POINTS

111

Figure 6.2: Unstable critical point, 1 = 1, 2 = 2. Trajectories start on the circle


of radius 5 and go away from the centre.

Figure 6.3: Stable critical point, 1 = 1, = 2. Trajectories start on the circle


of radius 5 and go to the centre.

112

CHAPTER 6. DYNAMICAL SYSTEMS

Figure 6.4: Saddle critical point, 1 = 1, = 2. Trajectories start on the circle of


radius 5 and they are approaching yaxis, but going away from the xaxis.

We can see that J has two complex conjugated eigenvalues. Each eigenvalue has its own
eigenvector, i.e. we have two linearly independent eigenvectors

e2 = (1, i).

e1 = (1, i),

Linear system determined by matrix J is

x = x + y,

y = x + y.

It can be simplied introducing polar coordinates (r, ) and using relation (3.16):

r = r,

= .

(6.8)

Trivial integration gives

r(t) = r0 e t ,

(t) = 0 t.

We can see that the angle is always a linear function of t which means that the trajectory
orbits about the origin with angular velocity . The distance from origin, r, is constant
( = 0, critical point is center ), exponentially increasing ( > 0, unstable focus) or
decreasing ( < 0, stable focus). The trajectories are therefore circles or exponential
spirals. To draw corresponding pictures in Maple we can slightly modify the previous
code:

6.3. CLASSIFICATION OF CRITICAL POINTS

113

alpha := 1; beta := -1;


r := (t, r0) -> r0*exp(alpha*t);
theta := (t, theta0) -> theta0-beta*t;
lst := NULL;
for i to 20 do
r0 := 5;
theta0 := (2*Pi*(1/20))*i;
lst := lst, [r(t, evalf(r0)), theta(t, evalf(theta0)), t = 0..4];
end do;
lst := [lst];
with(plots):
polarplot(lst);
Resulting picture is on gure 6.5. In this example the initial points were distributed
along the circle. Now we let = /4 and the initial points will lie on the line passing
through origin.
alpha := 1; beta := -1;
r := (t, r0) -> r0*exp(alpha*t);
theta := (t, theta0) -> theta0-beta*t;
lst := NULL;
for i to 20 do
r0 := i;
theta0 := Pi/4;
lst := lst, [r(t, evalf(r0)), theta(t, evalf(theta0)), t = 0..4];
end do;
lst := [lst];
with(plots):
polarplot(lst);
In the gure 6.5 we can see that all trajectories are again being attracted to the origin.
Now suppose that matrix J is
(
J =

)
.

This matrix has one repeated eigenvalue and only one linearly independent eigenvector

e1 = (1, 0).
Let us solve explicitly the system

x = x + y,

y = y.

Equation for y can be solved immediately:


y(t) = y0 e t .

114

CHAPTER 6. DYNAMICAL SYSTEMS

Figure 6.5: Stable focus, = 1, = 2. Trajectories start on the circle of radius


5 and they are approaching the origin while rotating with constant angular velocity
in counterclockwise direction.

Figure 6.6: Stable focus, = 1, = 2. Trajectories start on the line passing


through origin with the slope 0 = /4 and they are approaching the origin while
rotating with constant angular velocity in counterclockwise direction.

6.3. CLASSIFICATION OF CRITICAL POINTS

115

We thus obtain an inhomogeneous equation for x:


x x = y0 e t .
Obviously e t is a solution of homogeneous equation. Assuming x(t) = C(t) e t we arrive
at equation

C(t)
= y0 ,
so the general solution for x is
x(t) = (x0 + y0 t) e t .
So, our linear system has only one eigenvalue and only one eigenvector. The only critical
point is again the origin (x, y) = (0, 0). In this case it is called degenerate node. Trajectories in the neighbourhood of degenerate node can be visualised by following Maple code.
# choice of lambda, mu
lambda := -1;
mu := 2;
# parametrization of the solutions
X := (t, x0, y0) -> (x0+mu*y0*t)*exp(lambda*t);
Y := (t, x0, y0) -> y0*exp(lambda*t);
# generating initial points
lst := NULL;
for i to 20 do
x0 := 5*cos((2*Pi*(1/20))*i);
y0 := 5*sin((2*Pi*(1/20))*i);
lst := lst, [evalf(X(t, x0, y0)), evalf(Y(t, x0, y0)), t = 0..5]:
end do;
lst := [lst]:
plot(lst, scaling = constrained);
For given and we obtain gure 6.7.
The last case is when matrix J has form J = diag(, ). Now J has repeated eigenvalue , but two eigenvectors

e1 = (1, 0),

e2 = (0, 1).

In such a case the critical point (origin) is called singular node. Solution of the system

x = x,

y = y,

is
x(t) = x0 e t ,

y(t) = y0 et .

116

CHAPTER 6. DYNAMICAL SYSTEMS

Figure 6.7: Degenerated node.

Figure 6.8: Singular node.

6.3. CLASSIFICATION OF CRITICAL POINTS

117

Figure 6.9: Harmonic oscillator has critical point in the origin and it is a center,
trajectories are ellipses.

At gure 6.8 the trajectories are plotted for = 1.


Here we summarize obtained results for a general case. Consider an arbitrary linear
system with constant coecient

x = a11 x + a12 y,

y = a21 x + a22 y.

Eigenvalues of matrix A = (aij ) are given by secular equation det(A I2 ) = 0. If we


denote the trace and the determinant of matrix A as follows,

T = a11 + a22 ,

D = a11 a22 a12 a21 ,

the secular equation acquires form


2 T + D = 0.
Eigenvalues are therefore given by relation

1,2 =

T +

T2 4D
.
2

Several kinds of critical point can be plotted in D T graph. For T 2 4D = 0 we


have repeated eigenvalue = T /2. Thus, parabola at gure 6.10 represents singular node
or degenerated node depending on the number of eigenvectors. For T > 0 critical point
is unstable, for T < 0 it is stable. Above the parabola the discriminant T 2 4D < 0 so
s are complex:

118

CHAPTER 6. DYNAMICAL SYSTEMS

Figure 6.10: Regions with dierent critical points.

1,2 = i ,

T
,
2

1 2
|T 4D|.
2

Now, if = 0 (D-axis), the critical point is center, if < 0 we have stable focus and
unstable focus corresponds to > 0. Finally, for positive discriminant, T 2 4D > 0, i.e.
below the parabola, we have two distinct real eigenvalues. For T > 0, D > 0 the critical
point is unstable node, for T < 0, D > 0 it is a stable node. Notice that for D > 0 both
eigenvalues have the same sign, but for D < 0 they have opposite signs and we thus have
a saddle point.
Take, for example, harmonic oscillator. If the displacement from equilibrium position
is x and momentum is y, Hamiltons equations are

x =

y
,
m

y = m 2 x.

Our matrix J is therefore


(
J =

0
m 2

1
m

)
.

Its trace is T = 0 and determinant D = 2 . Eigenvalues are therefore = i , i.e. we


have two complex conjugated eigenvalues. According to picture 6.10, critical point with
T = 0 and D > 0 is center. This is correct, since we know that phase trajectories of
harmonic oscillator are ellipses. We can plot a eld of tangent vectors in Maple:
omega := 1;
m := 2;

119

6.4. CHAOTIC PENDULUM

with(plots):
fieldplot( [ y/m, - m*omega^2*x ], x = -3..3, y=-3..3 );
What about the damped harmonic oscillator? Damped harmonic oscillator is governed by equation (4.40)
x
+ x + 2 x = 0.
First we have to convert this equation of second order to the system of rst order equations. It is trivial, however, for if we dene y = x,
we immediately nd system of two
rst order equations

x = y,
y

= 2 x y.

(6.9)

The unknown variables are x = x(t) and y = y(t). Matrix of this system is
(

0
2

J =

)
,

T = ,

D = 2 .

Eigenvalues are

1,2 =

T2 4D

=
2

2 4 2
.
2

Discuss all types of critical points and plot corresponding diagrams in Maple!

6.4

Chaotic pendulum

In section 5.8 we studied mathematical pendulum. Here we consider more complicated


system damped mathematical pendulum with external driving force. On this system
we demonstrate the basic properties of chaotic system.
We start with equation (5.20) and add terms representing periodic external force and
the resisting force proportional to the velocity:
+ q + sin

= f cos t,

(6.10)

where q and f are arbitrary parameters, is the frequency of external force. As we shall
discuss later, chaos can emerge only in systems described by non-linear equations and
systems with at least three degrees of freedom. Equation (6.10) is obviously non-linear,
since appears as argument of sin . But the pendulum has only one degree of freedom,
the angle . On the other hand, our equation is of sceond order, while the dynamical
systems as dened above are described by rst order equations. Thus, we have to rewrite
equation (6.10) as a system of rst order equations. This is feasible by dening
= t.
= ,

120

CHAPTER 6. DYNAMICAL SYSTEMS

Our variables will be , , and governing equations

= sin q + f cos ,
= .

(6.11)

Now we can use Maple to solve this system numerically:


#equations of motion
eqs := D(theta)(t) = omega(t),
D(omega)(t) = -sin(theta(t))-q*omega(t)+f*cos(phi(t)),
D(phi)(t) = Omega;
#numerical values of parameters
vals := {f = 0, q = 1/5, Omega = 1};
#initial conditions
initconds := theta(0) = 1, omega(0) = 0, phi(0) = 0;
#numerical solution
sol := dsolve({eqs, initconds}, numeric, range = 0 .. 30);
#plotting the solution theta=theta(t)
odeplot(sol, [t, theta(t)], refine = 2);
#plotting the phase trajectory (theta, omega)
odeplot(sol, [theta(t), omega(t)], refine = 2);
Here we chose values q = 1/5, = 1 and f = 0 (no driving force). Dependence = (t)
is plotted at gure 6.11. We can see that oscillations are exponentialy damped similarly
to the case of damped harmonic oscillator. The phase trajectory, gure 6.12, is again the
spiral approaching the origin. The origin is a xed or critical point in previously dened
sense. It is also called an attractor, because wherever in the neighbourhood of this point
the trajectory starts, it is being attracted by the origin and spiraling towards it. Soon
we will see other types of attractors.
In fact there are more xed points than the origin. If we choose, for example, (0) = 3,
the attractor will discontinuosly move to coordinates (, ) = (2, 0), see gure 6.13.
Physically this is understandable, because all values = 0, 2, 4, . . . correspond to the

same equilibrium, vertical, position of the pendulum. If the initial velocity (0) = (0)
is big enough, the pendulum will rotate more times, say n, around its hanging point
O before it is damped. The xed point then moves to position (2 n, 0) in the phase
diagram.
Until now we have not seen anything chaotic. All obtained results are in accordance
with our physical intuition. Physical intuition fails when the external driving force is
introduced and we are in position to investigate its eect on the pendulum. We will see

6.4. CHAOTIC PENDULUM

Figure 6.11: Damped oscillations without external driving force.

Figure 6.12: Phase trajectory for (0) = 1, (0) = 0.

121

122

CHAPTER 6. DYNAMICAL SYSTEMS

Figure 6.13: Phase trajectory for (0) = 1, (0) = 3.

that the actual motion is matter of delicate interplay between the external force and selfoscillations of the pendulum and the result crucially depends on the values of parameters
and initial conditions.
First we would like to show how system behaves when the force is relatively strong
(f = 10) and the damping coecient is big (q = 10), so that self-oscillations are suppresed
soon. Moreover we set (0) = (0) = 0. Using previous Maple code with corresponding
changes of parameters we obtain gure 6.14. We can also make an animation by
odeplot(sol, [theta(t), omega(t)], frames = 40),
where parameter frames determines how many pictures the animation will consist of.
The trajectory now changes its character. After short transient phase the trajectory
becomes stabilized periodic curve. This kind of attractor is called limit cycle. If we now
choose the initial angle to be (0) = 1, we get picture 6.15.
Now we analyze the case when the damping is not too strong so that the selfoscillations are not completely suppresed. Resulting motion is then very sensitive to
initial conditions, because the interaction between self-oscillations, damping force and
driving force is very complicated. Let us put

f = 5, q =

1
, = 1,
6

and (0) = 0, (0) = 0, (0) = 0. On the gure 6.16 we can see that there is no limit
cycle, the phase trajectory is an open curve moving to the left. If we now slightly modify
the initial phase of the force by setting (0) = 0.1, the trajoctory is moving to the
right, see gure 6.17. We can see that the solutions for relatively close values of (0) are
completely dierent! On gures 6.186.21 few solutions for dierent values of parameters
and initial conditions are shown.

6.4. CHAOTIC PENDULUM

123

Figure 6.14: Phase trajectory for (0) = (0) = 0, f = q = 10. Trajectory exhibits
transient phase and limit cycle.

Figure 6.15: Phase trajectory for (0) = 1, (0) = 0.

124

CHAPTER 6. DYNAMICAL SYSTEMS

Figure 6.16: Parameters f = 5, q = 16 , = 1. Phase trajectory for (0) = 0, (0) =


0, (0) = 0.

Figure 6.17: Phase trajectory for (0) = 0, (0) = 0, (0) = 0.1.

6.4. CHAOTIC PENDULUM

Figure 6.18: f = 54 , q = 15 , = 21 , (0) = 1, (0) = 0, (0) = 0.

Figure 6.19: f = 45 , q = 15 , = 12 , (0) = 1, (0) = 0, (0) = 0.5.

125

126

CHAPTER 6. DYNAMICAL SYSTEMS

Figure 6.20: f = 73 , q = 15 , = 12 , (0) = 1, (0) = 0.5, (0) = 0.

Figure 6.21: f = 73 , q = 15 , = 21 , (0) = 1, (0) = 0.5, (0) = 0.5.

Chapter 7

Discrete systems and fractals

7.1

Mandelbrot set

Let z = x + iy be a complex variable and c C some xed complex number. Consider


mapping f dened by
f (z) = z 2 + c.
Now dene the sequence zn of complex number dened by reccurence relation
zn+1 = f (zn ) = zn2 + c,

z0 = c,

so that rst members of the sequence read


z0 = c, z1 = z02 + c = c2 + c, z2 = c4 + 2c3 + c2 + c, . . . .
Thus, we obtain the sequence of complex numbers points in the complex plane, see
gure 7.1. This is the model of discrete dynamical system. In previous chapter we studied
dynamical systems, where the motion of the point in the phase space was continuous.
Now the phase trajectory is not a curve but the sequence of points. It is often useful to
study discrete systems as they share many properties with dynamical systems, but they
are usually easier to study.
What is the limit of sequence zn ? Again, points zn can converge to some particular
point, they can diverge to innity, they can exhibit limit cycles, or they have no limit.
Which of these possibilities occurs depends on the mapping f and the initial point z0 = c.
We want to plot a picture similar to phase portrait, showing for which initial points c
the sequence converge and for which not.
The idea is following. We construct Mandelbrot function M , which assigns a number
to each point of the plane according to rule to be explained. Mandelbrot function is
integer-valued function of one complex argument, M = M (c) N, c C. Equivalently,
M can be understood as a real function of two real variables, M = M (x, y), where
c = x + iy. Let N be a xed integer, let R be some xed real number. For given c we
Usually, function f (c) is called Mandelbrot function. Here we use dierent terminology for convenience.

127

128

CHAPTER 7. DISCRETE SYSTEMS AND FRACTALS

y = =(z)
zk+1
zk

z2
z0

z1
x = <(z)

Figure 7.1: Sequence of complex numbers dened by zn+1 = f (zn ), where z0 is


arbitrarily chosen point of complex plane.

can construct the sequence zn . If some zk+1 lies outside the circle with radius R, see
gure 7.1, we set M (c) = k. It can happen that after N iterations zN still lies inside the
circle. In such case we set M (c) = N . In other words, number M (c) gives number of
members zn , n = 1 . . . N lying inside the circle. Maple code implementing this function
is following:
Mandelbrot := proc(x, y)
local k,z,c:
c := evalf(x + I*y): z := c:
for k from 1 to 100
while abs(z^2+c) < 10 do
z := evalf(z^2+c):
end do;
k;
end proc;
Brief description. Procedure Mandelbrot is function of two variables x, y. We dene three
local variables. Variable k is the length of the sequence, c is the initial point of complex
plane. Finally, z is kth member of the sequence. After declaration of variables we set
c = x + iy and z = c. Now, z is zeroth member of the sequence. Next we compute
rst 100 (in our example N = 100) members of the sequence using reccurence relation
zn+1 = z 2 + c. If the module |zk | > 10 (R = 10), procedure stops and returns value k. If
all 100 members lie in the circle of radius 10, procedure returns value k = 100.
Now we want to plot the values of Mandelbrot function. Since M is function of x and
y, the graph is three-dimensional. It is not a continuous surface, however, because the
value of M is integer and the graph is therefore a discrete set of points. Such a graph is
not very useful for studying the behaviour of Mandelbrot function.

7.1. MANDELBROT SET

129

Figure
7.2: Two-dimensional representation of the graph of function f (x, y) =
sin x2 + y 2 .

But there is another possibility. Using Maple function densityplot we can plot function
of two variables on the plane. Points (x, y) with dierent value of function are drawn
with dierent colours. Consider, for example, radial wave propagating from the origin of
coordinate system. This wave can be described by function

f (x, y) = sin x2 + y 2 .
Following command in Maple produces gure 7.2. We can see that points of the same
phase are drawn with the same colour. Two points with dierent but close phases
are drawn with similar colours. Although this representation of function f is not as
illustrative as complete three-dimensional graph, but it gives us good visualisation of the
graph.
with(plots):
densityplot( sin(sqrt(x^2+y^2)), x=-10..10, y=-10..10);
Command densityplot can be used also to plot the representation of Mandelbrot function:
with(plots):
densityplot( Mandelbrot, -2..0.5,-1.2..1.2,
style=patchnogrid,axes=none, grid=[400,400]);
The result is celebrated Mandelbrot set, gure 7.3. Colorful picture 7.4 can be obtained
by
with(plots):
densityplot( Mandelbrot, -2..0.5,-1.2..1.2, colorstyle = hue,
style=patchnogrid,axes=none, grid=[400,400]);

130

CHAPTER 7. DISCRETE SYSTEMS AND FRACTALS

Figure 7.3: Mandelbrot set.

Figure 7.4: Colorful Mandelbrot set.

7.1. MANDELBROT SET

131

Figure 7.5: x (0.4, 0.1), y (0.6, 1.2).

Figure 7.6: x (0.14, 0.08), y (0.9, 0.965).

We can see that Mandelbrot set has very interesting structure. The interior is uniformly lled with red colour, but the boundary is obviously extremely complicated. We
can zoom to smaller part of Mandelbrot set by changing the range of variables x and y.
Figures 7.57.7 show smaller and smaller parts of Mandelbrot set.
For dierent denitions of mapping zn+1 = f (zn ) we obtain dierent pictures, but
not all of them are fractals. On the gures 7.87.16 we show few examples, but reader
is invited to create new own fractals.

132

CHAPTER 7. DISCRETE SYSTEMS AND FRACTALS

Figure 7.7: x (0.13, 0.1135), y (0.922, 0.929).

Figure 7.8: zn+1 = zn10i , (x, y) (0, 6) (0, 6)

7.1. MANDELBROT SET

Figure 7.9: zn+1 = zn10i , (x, y) (0.6, 0.7) (0, 0.1)

Figure 7.10: zn+1 = zn10i , (x, y) (0.6, 0.601) (0, 0.002)

133

134

CHAPTER 7. DISCRETE SYSTEMS AND FRACTALS

Figure 7.11: zn+1 = 1 +

Figure 7.12: zn+1 = 1 +

z p +1
z p1 , p

z p +1
z p1 , p

= 10i

= 5i

135

7.1. MANDELBROT SET

Figure 7.13: zn+1 = 1 +

z p +1
z p1 , p

= 5i

Figure 7.14: zn+1 = znizn , R = 3

136

CHAPTER 7. DISCRETE SYSTEMS AND FRACTALS

Figure 7.15: zn+1 = znc+izn , R = 3

Figure 7.16: zn+1 = znc+izn , R = 3

Chapter 8

Fluid mechanics

Until now we have considered only the point masses or systems of point masses. This
formalism is not, however, adequate for the description of liquids or gases. Liquids and
gases share many common properties and we call both of them uids. This term reects
the fact that liquids and gases can ow. We know that on microscopical level solids and
uids consist of molecules or atoms. Thus, all kinds of matter can be described as a
system of point masses, if we neglect the size of molecules (which seems to be plausible
approximation). One important limitation of such an approach is that interaction between molecules is in fact governed by quantum mechanics and Newtonian description
is not appropriate. But in the framework of classical mechanics, there is another limitation: we simply cannot solve equations of motion for so many particles. Thus, another
description is necessary.
The distance between molecules is typically much smaller than the size of the objects
under consideration. Indeed, assume that typical size of the container with the uid
is about 1 meter. Typical distance between molecules in uid is 1010 m. To distinguish individual molecules and eects of their mutual interactions we need extremely
sophisticated experimental devices. We can therefore imagine that the uid is continuum, a substance continuously lling the space. We introduce the notion of physically
innitesimal volume element. By innitesimal we mean that the size of volume element is negligible with respect to the size of the uid, but it contains very large number
of molecules. So, the properties of the uid are constant inside given element.
In usual applications, the most useful way for describing the ow of the uid is
Eulerian picture. In this picture we describe the velocity of the uid with respect to
observer who is at rest and uid is moving with respect to him. In general, the velocity
of one individual particle of the uid changes in time. Thus, observer will measure
dierent velocities in dierent places of the uid. If the ow is not stationary, velocity
of the uid is function of both position and time. Position vector with respect to xed
origin O is denoted by r. The velocity eld is then function of r and time t:
v = v(t, r).
Graphically we model the velocity eld by ow lines. Flow line is a curve such that
velocity of the uid at given point is tangential to the ow line, see gure 8.1. Density
of ow lines is proportional to the magnitude of velocity.
137

138

CHAPTER 8. FLUID MECHANICS

pipe
v(t, r1)
r1

v(t, r2)

r2

Figure 8.1: Velocity eld is represented by the ow lines. At each point, the velocity
is tangential to the ow line.

Beside the velocity eld, an important property of the uid is mass density. Consider
innitesimally small volume element dV (in the sense dened above). Let the mass of
the element be dm. It is also an innitesimal quantity. Mass density is then dened as
dm
.
dV
General uids are compressible, which mean that the uid of mass m can ocuppy dierent
volume V . It is obvious in the case of gases. Gas stored in the container occupies the
volume of container. But after opening the container, the gas will expand and occupy
whole space of the room. Liquids are usually almost incompressible, but if the velocity
of the uid is comparable to the speed of sound in the uid, compressibility becomes an
important property of the uid. So, in general, the uids are compressible. The mass
density is therefore not constant, but it is again a function of time and position, see:
=

= (t, r).
The total mass of the uid in xed domain V at time t is given by

M (t) =
(t, r) dV.
For complete description of the uid we need also its termodynamical properties, namely
the temperature and the entropy, and equation of state, but these issues will not be
discussed here.

8.1

Continuity equation

Continuity equation is mathematical formulation of law of conservation of the mass for


uids. Consider domain V0 at time t0 = 0. Mass of the uid in this domain is

M0 =
dV.
V0

139

8.1. CONTINUITY EQUATION

dm = dV
dV

Figure 8.2: Total mass of the uid in xed domain is integral of mass density. Mass
of the volume element is dm = (t, r)dV .

Particles of the uid contained in V0 are moving with velocities given by velocity eld
v. At some time t > t0 the same particles form another domain V (t), see gure 8.3.
Because the mass is conserved, mass of the uid contained in this new domain V (t) must
be the same:

dV = M0 .
M (t) =
V (t)

Thus, since the mass is conserved (constant), the time derivative of the mass M (t) must
be zero:

d
dV = 0.
dt
V (t)

This is an integral formulation of conservation of mass. We wish to derive equivalent


dierential equation. Unfortunately, we cannot exchange the order of derivative and
integral, because not only integrand, but also the integration region depends on time. It
is possible, however, to transform integral over region V (t) into an integral over V0 . This
is feasible using theorem about substitution. Let xi = xi (t) be the trajectory of some
volume element dV , with initial value xi0 and initial velocity vi0 :
xi (0) = xi0 ,

x i (0) = vi0 .

Expansion of xi (t) near t = 0 reads


( )
xi (t) = xi0 + t vi0 + O t2 ,
so that
Jij =

( )
xi
vi0
= ij + t
+ O t2 .
xj0
xj0

140

CHAPTER 8. FLUID MECHANICS

Now, substitution theorem states

dV =
J dV,
V (t)

V0

where J is determinant of matrix Jij . This determinant can be computed directly as


( )
J = ijk Ji1 Jj2 Jk3 = 1 + t v0 + O t2 .
(8.1)
Thus, we have to compute

d
J dV
dt
V0

at time t = 0. Integration region is now constant, so we can exchange the order od


derivative and integral. Time derivative of the integrand is
d
d
( J) =
+ v0 + O (t) .
dt
dt
The conservation of mass then implies
)
(
d
+ v0 dV = 0.
dt
V0

where we have set t = 0. Since this equation must hold for arbitrary volume V0 and
arbitrarily chosen initial time t = 0, the integral can be zero only if the integrand is zero
everywhere in the uid:
d
+ v = 0.
dt
This is already continuity equation, but usually it is written in slightly dierent form.
Total derivative of (t, r) with respect to time is
d

=
+
x i =
+ v .
dt
t
xi
t
Using the Leibniz rule dor the derivative of product in the form
( v) = v + v
we can rewrite continuity equation as

+ ( v) = 0.
t
We dene a new quantity called ux density or current density by
j = v
Final form the continuity equation, using current density, is

+ j
t

= 0.

(8.2)

141

8.2. EULERS EQUATION OF HYDRODYNAMICS

M
M

V (t)
V0

Figure 8.3: Original domain V0 of mass M moves and deforms. By conservation of


mass, however, domain V (t) at time t must contain the same mass M .

Once more, continuity equation is dierential equation expressing conservation of mass


during the ow. It holds for compressible or incompressible uids. In the case of incompressible uids, however, mass density does not depend neither on time nor on spatial
coordinates, so that the continuity equation reduces to
v

0.

(8.3)

Let us now briey discuss the physical and geometrical meaning of the continuity
equation. First, what does current density describe? Consider volume element dV of
mass dm. Its (innitesimal) momentum is
dp = v dm = v dV = j dV.
We can therefore see thath j is the momentum density,
j =

dp
.
dV

On the other hand, dimension of j is


[j] = [ v] =

M L
M
= 2 ,
3
L T
L T

where M , L and T stand for the units of mass, length and time. In standard SI units
[j] =

kg
.
m2 s

Current density is the mass ow through unit area per unit of time.

8.2

Eulers equation of hydrodynamics

In this section we derive the equation of motion for ideal non-viscous uid. Let us rst
explain what an ideal uid is. It is a general property of uids (both ideal and real)
that if they are at rest, there are no shear forces. This must be, as the uid could not be

142

CHAPTER 8. FLUID MECHANICS

at rest otherwise. When the real uid is in motion, dierent parts of the uid are moving
with dierent velocities. Two close layers with dierent velocities chafe on each other.
If the uid has non-zero viscosity, this friction will cause the shear forces. In ideal uid
the friction is by denition zero, so no shear forces appear. Thus, in ideal uid there
are no shear forces, whether the uid is in motion or at rest, and in this section we are
interested only in ideal uids.
Consider ideal uid described by velocity eld v(t, r). Imagine virtual surface of area
S with normal vector n. We introduce vector S by
S = S n,
see gure 8.4. The uid acts on surface S by some force F . In ideal uid, the force is
always orthogonal to the surface, so it has direction of vector n:
F = F n.
We dene tension caused by force F as quantity
=

F
.
S

Notice that vector n points out from the surface. If the tension is negative, the force
points into the surface and we dene the pressure P as
P = .
Pressure is familiar characteristics of the uid. Its meaning can be summarized as follows.
Consider innitesimal surface dS = n dS. The uid acts on this surface by innitesimal
force
dF

= P dS.

(8.4)

Consider now nite region V of the uid, bounded by surface S, see gure 8.5. Consider next an area element dS on the surface S, so that the force acting on this element
is
dF = P dS.
We want to calculate the net force acting on the region V , so we have to integrate the
force dF through the whole surface S:
I
I
FS =
dF = P dS.
S

The circle in the integral sign emphasizes the fact that the surface S is closed. On the
other hand, we would like to know the force acting on volume element dV instead of
surface element dS. Here we can use Gauss theorem to convert the surface integral into
the volume integral. According to this theorem we can write
I

P dS =
P dV,
S

143

8.2. EULERS EQUATION OF HYDRODYNAMICS

S = Sn
n

S
Figure 8.4: Surface with area S, which is a scalar quantity, can be represented
by vector S = S n, where n is vector orthogonal to the surface. Vector S thus
encapsulates both the area of surface and its orientation in the space.

dF = P dS

Figure 8.5: Net force acting on the uid contained in domain V is given as a surface
integral of the force.

so that the net force is equal to

FS

P dV.

(8.5)

No we can derive the equation of motion of an ideal fuid. Newtons law of force must
hold for arbitrarily chosen volume V . Total momentum of the uid contained in domain
V is

p =
v dV,
V

so that the total force is


F =

dp
.
dt

144

CHAPTER 8. FLUID MECHANICS

On the other hand, we know that the total force caused by pressure is given by (8.4) or,
equivalently, by (8.5). Thus, Newtons law in integral form reads

I
d
v dV = P dS.
(8.6)
dt
V

Now, integral on the right hand side can be evaluated at arbitrary time, but in order
to exchange the derivative and integral operator on the left hand side we need to use
transform the volume at time t into volume at time t0 = 0 and use Jacobian (8.1). Then
the left hand side becomes (nally evaluated at t = 0)
]

[
d
d v
d
v dV =
[ v (1 + t v)] dV =
+ v ( v) .
dt
dt
dt
V

Because the velocity is a function of time and position, and by continuity equation, we
have
d
dt
dv
dt

= v,
=

v
+ (v )v.
t

For the total derivative of momentum we therefore obtain

dv
dp
=

dV.
dt
dt

(8.7)

We insert this expression into (8.6) and nd

dv

dV =
P dV,
dt
V

where we switched from surface to volume integral on the right hand side. Since the last
equation must hold for arbitrary volume V and in arbitrary time t, the integrand must
vanish. Thus, we arrive at Eulers equation of hydrodynamics

dv
dt

= P.

(8.8)

It is equation of motion of ideal, non-viscous uid. Usual form of Eulers equation can
be obtained rewriting the total derivative of velocity as
dv
v
=
+ v v.
dt
t
Then we have
v
+ v v
t

1
P,

or, in index notation,


vi
1
+ vj j vi = i P.
t

(8.9)

8.2. EULERS EQUATION OF HYDRODYNAMICS

145

If the uid is at rest, velocity eld v and its derivatives vanish, so that Eulers equation
reduces to
P = 0.
It is a mathematical formulation of well-known Pascals law : the pressure in uid at rest
is everywhere constant.
Finally, if the uid is under inuence of external force, e.g. gravitation, we have to
add corresponding term into Eulers equation. Assuming that the force has potential ,
force acting on volume V is

FV = dV,
V

where the subscript V emphasizes that the force is volume force, i.e. it acts in every
point of the domain V . It is a contrast to surface forces. Eulers equation with external
force reads
v
+ v v
t

1
P .

(8.10)

Chapter 9

Two dimensional potential ow

Sometimes it is useful to treat the ow of the uid as two dimensional. In such case
we imagine that the uid is contained between two parallel planes and the velocity is
constant along the line perpendicular to those planes, see gure 9.1. This approximation
is valid if we can neglect the eects connected to interaction of the uid with its boundary.
In this chapter we will be interested in two-dimensional ow of incompressible ideal uid.
In addition, we assume that the ow is stationary, so the velocity eld does not depend
on time.

9.1

Potential and stream function

According to previous assumptions, motion of the uid is described by two-component


velocity eld depending only on two (Cartesian) coordinates:
v = (v1 , v2 , 0),

v1 = v1 (x, y), v2 = v2 (x, y).

Figure 9.1: Fluid is contained between two parallel planes A and B. Red lines represent the ow lines of the uid in some planar section C of the uid. These ow
lines are assumed to be same in every plane, i.e. the velocity eld is constant along
dashed line.

147

148

CHAPTER 9. TWO DIMENSIONAL POTENTIAL FLOW

We also adopt notation


v1 = vx ,

v2 = vy .

The ow is called potential ow, if there exists single scalar function


= (x, y)
such that the velocity is gradient of ,
v = ,

vi = i ,

or explicitly
vx =

,
x

vy =

.
y

(9.1)

Then is called potential of the velocity eld v. To nd geometrical meaning of ,


consider equipotential lines, i.e. lines C , on which is constant:
C : (x, y) = C,

C R;

Since the potential is constant along C , its total dierential must be zero:
d = 0.
On the other hand, general expression for the dierential combined with the denition
of potential yields
d = (i )dxi = vi dxi = v dr = 0.
Here dr is an innitesimal displacement along the curve C . Previous equation actually
tells us that velocity v is orthogonal to displacement dr (their scalar product vanishes),
so it is orthogonal to the equipotential line, see gure 9.2.
We can easily derive the equation satised by . Continuity equation for icompressible
uid is
v = 0.
Inserting v = we get
v = = ,
where is usual Laplace operator in two dimensions:
=

2
2
+
.
2
x
y 2

So, potential of velocity eld must satisfy Laplace equation

= 0.

(9.2)

Because v is a gradient, its curl must vanish identically. Such velocity eld is called
irrotational and its ow lines cannot be closed curves. By continuity equation, however,
also the divergence of velocity eld must be zero. Such eld is called solenoidal and its

9.1. POTENTIAL AND STREAM FUNCTION

149

=C
v

Figure 9.2: Velocity eld is everywhere orthogonal to equipotential lines.

ow lines do not have neither starting nor ending points (there are no sources of ow
lines).
v = 0,

v = 0.

Alternatively we can describe potential ow by stream function . By denition,


is constant along the ow lines:
d = dr =

dx +
dy = 0,
x
y

where displacement dr = (dx, dy) is along the ow line, see gure 9.3. According to this
picture, displacements dx and dy must satisfy dierential equation
dy
vy
=
,
dx
vx
or, written in dierent form,
vy dx + vx dy = 0.
Since d = 0 along the ow line, we can make following identication:
d = vy dx + vx dy = 0.
From this equation we immediately nd
vx =

, = vy =
.
y
x

(9.3)

Stream function is function satisfying relations (9.3). These relations can be written
in more vector form. Dene vector eld
= (0, 0, ).

150

CHAPTER 9. TWO DIMENSIONAL POTENTIAL FLOW

=constant

vy
v
dy
dx

vx

Figure 9.3: Stream function is constant along the ow line.

Then its curl has components


= (2 3 3 2 , 3 1 1 3 , 1 2 2 1 ) = (

,
, 0),
y
x

since 1 = 2 = 0, 3 = and nothing depends on zcoordinate (ow is two-dimensional). Relations (9.3) are thus equivalent to
v = .
From the last equation we can again see that divergence of velocity is equal to zero,
because the divergence of curl vanishes identically.
Stream function also satises Laplace equation. To see this, we apply curl to the
velocity v and use vector identity
( ) = ( ) .
Since the velocity eld is irotational, we get
v = ( ) = 0.
Divergence of is zero,
= i i =

= 0,
z

because has only one non-zero component , which, however, does not depend on z.
Therefore,
= 0.
The last equation is non-trivial only for the third component of , so we have
= 0.

9.2

Complex potential

Potential and stream function can be combined into single complex function
F (x, y) = (x, y) + i (x, y).

151

9.2. COMPLEX POTENTIAL

We can regard F as complex-valued function of two real coordinates x and y, or as a


complex function of complex variables
z = x + i y,

z = x i y.

It is known from the complex analysis that complex function has well dened derivative
(i.e. direction independent), if it is holomorphic. Function F is holomoprhic, if its real
and imaginary parts satisfy the Cauchy-Riemann conditions

=
,
x
y

=
.
y
x

(9.4)

As it is obvious from relations (9.3) and (9.1), functions and indeed satisfy CauchyRiemann conditions. Function F is therefore holomorphic and we can use the machinery
of complex analysis to investigate its properties.
Notice that if F is holomorphic, it does not actually depend on z. Inverse transformation from (z, z) to (x, y) reads
x =

1
(z + z),
2

so that
1

=
z
2

i
y = (z z),
2

i
x
y

)
,

1
=
z
2

+ i
x
y

)
.

Applying z to function F we nd
F
= (x y ) + i (y + x ) = 0,
z
where we used Cauchy-Riemann conditions in the last step. Thus, F is independent of
z and we can write
F = F (z)
instead of F = F (z, z).
Velocity v is three dimensional vector, but if we investigate ow in the plane, the
third component is equal to zero, and we can treat v as vector in two dimensions. Such
a vector can be conveniently represented as a complex number in the complex plane. We
dene complex velocity and its complex conjugate as
v = vx + i vy ,

v = vx i vy .

Velocity can be then obtained from the complex potential F by simple dierentiation:
dF

=
=
=

F
F
dx +
dy
x
y

dx + i
dx +
dy + i
dy
x
x
y
y
(vx i vy )dx + (vy + i vx )dy

= v dx + i(vx i vy )dy
= v (dx + i dy)
= v dz.

152

CHAPTER 9. TWO DIMENSIONAL POTENTIAL FLOW

We derived an important formula


dF

= v dz.

(9.5)

Derivative of complex potential with respect to complex variable z is complex conjugated


velocity. To calculate actual velocity we must complex conjugate v, i.e. change the sign
of the imaginary part.
In subsequent sections we analyze basic types of irrotational ow. General ow can
be obtained by superposition of basic types called elementary irrotational ows.

9.3

Uniform ow

The simplest type of the ow is uniform ow. In this regime, the velocity of the uid is
constant, the uid is moving at uniform velocity in the whole plane. Let
v = (vx , vy ) = constant
be the velocity of the uid in each point. Then we can dene complex velocity
v = vx + i vy .
What is the complex potential of such ow? Derivative of potential F must be complex
conjugation of velocity v:
dF
= v.
dz
Since v is constant, we can integrate the last equation to nd
F = v z + C,
where C is complex constant which can be set to zero without loss of generality (only
derivatives of potential matter). Thus, uniform ow is described by potential
F

= v z,

(9.6)

where v is constant complex conjugated velocity and z = x + iy is complex position


vector.
Uniform ow is rather trivial. We can, however, use this simple example to show how
the velocity eld with potential F can be visualised in Maple. Suppose that the uid is
moving with unit velocity in the direction of xaxis. Vector v is therefore
v = (1, 0), vx = 1, vy = 0.
So, rst we dene vector V by
V := [1,0]:
Complex potential F = vz can be dened by
F := z -> ( V[1] - I*V[2] )*z:

9.3. UNIFORM FLOW

153

Figure 9.4: Velocity eld of uniform ow. The velocity is v = (1, 0).

Here, V[1]-I*V[2] is complex conjugated initial velocity. At this stage Maple does not
distinguish between complex or real z. Since F is holomorphic, we can dierentiate it
with respect to z just like it was real variable. We can thus use Maple operator D, but
after dierentiation, we have to substitute x + iy for z. This can be done by
D(F)(x+I*y)
Now we can dene vector eld v by
v := (x,y) -> [ Re( D(F)(x+I*y) ), - Im( D(F)(x+I*y)) ];
By this command we dened vector eld v depending on two real coordinates x and
y. The rst component of v is real part of dF/dz, the second component is imaginary
part, but with opposite sign (because of complex conjugation). Finally we can plot the
velocity eld by command eldplot. Complete code is
V := [1,0];
F := z -> (V[1] - I*V[2])*z:
v := (x,y) -> [ Re( D(F)(x+I*y) ), - Im( D(F)(x+I*y)) ];
with(plots):
fieldplot( v(x,y), x=-10..10, y=-10..10, axes=none );
and it produces picture 9.4. If we need dierent velocity of the ow, we merely change
initial velocity. For example, ow for velocity
V := [-2, 1]:
is plotted in gure 9.5.

154

CHAPTER 9. TWO DIMENSIONAL POTENTIAL FLOW

Figure 9.5: Velocity eld of uniform ow. The velocity is v = (2, 1).

9.4

Line source and line sink

Second type elementary irrotational ows are source and sink. Imagine that the source
of the ow is located in the origin of Cartesian coordinate system. It means that the
uid is emerging from the point in the origin and then it is owing symmetricaly to all
directions away from the origin, see gure 9.6. The velocity is always radial, i.e. it can
be written as
v = vr er ,
where er is the unit vector associated with coordinate r, see section 3.2.2. Angular
coordinate v is assumed to vanish.
By the symmetry of the conguration, it seems plausible to introduce polar coordinates instead of Cartesian. We start by rewriting the stream function in terms of polar
coordinates. Recall that the total dierential of must vanish along the ow line:
d = vy dx + vx dy = 0.
As follows from denition of polar coordinates, dierential of can be rewritten as
d

= vy (cos dr r sin d) + vx (sin dr + r cos d)


= (vx sin vy cos ) dr + r (vx cos + vy sin )
= v dr + r vr d,

(9.7)

where we used relations (3.17). We thus have


d

= v dr + r vr d.

(9.8)

Radial and angular components of velocity in polar coordinates can be therefore obtained
from relations
1

vr =
,
v =
.
(9.9)
r
r

155

9.4. LINE SOURCE AND LINE SINK

= constant

e
er

= constant

Figure 9.6: Irrotational ow with the source in the origin. Flow lines are lines
emerging from the origin, equipotential lines are circles. Velocity v is orthogonal to
equipotential line and parallel to ow line.

To nd a stream function and potential, we have to nd the components of velocity.


As mentioned, since the velocity eld is assumed to be radial, angular component of
velocity vanishes:
v = 0.
What about the radial component vr ? If we assume that the only source of the uid is
located in the origin, then the mass is not conserved at the origin, but must be conserved
elsewhere. The ux Q of the uid through curve is dened as
I
Q =
v dS,

see gure 9.7. This ux must be same for any curve and equal to total amount of uid
incoming to the system through origin per unit time. Especially, when we choose to
be circle of radius r centered at origin, vr is constant on and we can write
I
Qr =
vr ds = 2 r vr .

Since Qr must be same for arbitrary radius r > 0, we can set Qr = Q = constant.
Constant Q characterizes the source and is proportional to mass of the uid injected into
the system per unit time. The velocity of the uid is then
vr =

Q
.
2r

We have derived the polar components of the velocity eld under consideration:
vr =

Q
,
2r

v = 0.

(9.10)

156

CHAPTER 9. TWO DIMENSIONAL POTENTIAL FLOW

dS

vr

ds
r

Figure 9.7: Flux of the velocity eld through curve . Here, vr is radial component
of velocity at given point lying on curve , ds is line element of the curve, and dS
is vector normal to the curve.

Flow with these properties is called ow with source in the origin, if Q > 0, so that the
uid is incoming into the system. If Q < 0, amount of the uid is decreasing and the
origin is called sink.
Stream function for this velocity eld can be found by trivial integration of equations
(9.9):

Q
.
2

(9.11)

Potential is dened by condition v = . Gradient in polar coordinates is given by


equation (3.18), so that potential must satisfy
= er

Q
+ e
=
er ,
r
r

2r

and is therefore determined by equation

Q
=
,
r
2r
which integrates to

Q
log r.
2

(9.12)

Let us now turn to the complex potential of given ow. First, any complex number
z = x + iy can be written in polar coordinates as
z = r ei ,

where r = x2 + y 2 is the modul of z. Complex potential is by denition


F = + i =

Q
Q
(log r + i ) =
log z,
2
2

9.4. LINE SOURCE AND LINE SINK

157

since
(
)
log z = log r ei = log r + log ei = log r + i .
Final remark. Until now we have ignored the fact that potential ow has always zero
divergence, i.e. it cannot have sources. In this section, however, we considered potential
ow with source and even derived the expression of the potential. What is wrong? The
answer is understandable also in terms of real potential, but the full appreciation comes
from theory of complex variables. The crucial point is that potential we derived is not
dened at the origin: it diverges there and so does the velocity eld vr because r = 0.
Everywhere else the velocity and potential are nite and Laplace equation is satised.
The only place where the eld fails to be potential is origin. It is thus more appropriate
to say that our ow is potential with the exception of point (0, 0). A source of the ow
is located at the origin, but the ow does not have potential there.

Appendix A

Maple: An introduction

A.1

First steps

In order to get familiar with Maple we start from the most basic operations. Type
3+5
and press enter. Maple will produce a new line, in the center of which it displays the
result:
8.
If Maple is running in a document mode (not in worksheet mode), pressing ctrl+= yields
the result displayed in the same line:
3+5=8.
For the sake of simplicity, we assume that this second style is being used. So, whenever
a line
(some expression) = (some other expression)
appears, it means that some expression was typed by the user, then ctrl+= has been
pressed, and some other expression has been calculated by Maple.
The fractions can be inserted using usual symbol / and they are processed automatically. For example,
2/3 + 3/7 = 23/21
or simply
2/4 = 1/2.
Maple is trying to work in the symbolic form as long as possible. To obtain a numerical
value of some expression we can use command evalf which has one or two arguments. The
rst one is the expression itself, the second, optional, argument is the precision (number
of digits) of the result:
159

160

APPENDIX A. MAPLE: AN INTRODUCTION

evalf(2/3 + 3/7) = 1.095238095


evalf(2/3 + 3/7,4) = 1.095
evalf(Pi, 40) = 3.141592653589793238462643383279502884197.
Notice that Ludolf number is represented by Pi, while the symbol pi stands for Greek
letter without any special meaning, e.g. it can be used as the name for a variable.
Expression xy can be inserted using symbol :
2^2 = 4
3^4 = 81.

The same symbol can be used for nding roots like 3 125 = 1251/3 . The numerical value
of such operation can be, of course, obtained by evalf, but then we loose the symbolic form
of the expression. However, Maple is able to simplify expressions also in the symbolic
form, even if the actual values of the variables involved are not known:
simplify(125^(1/3)) = 5
simplify((x^3)^5) = x^15
Command simplify has a lot of options and properties, only some of them will be
mentioned here. Consider, for example, an identity sin2 x + cos2 x = 1. If we apply
simplify to the left hand side of this identity, nothing happens:
simplify(sin(x)^2 + cos(x)^2) = sin(x)^2 + cos(x)^2.
This is because Maple does not know which form of the result we prefer . We can, however, dene the rules which are to be used to simplify expressions by following command:
rules := { sin(x)^2 + cos(x)^2 = 1 }.
Notice that assignments are denoted by familiar symbol :=. Now we can apply the rule:
simplify( sin(x)^2 + cos(x)^2, rules) = 1.
Dening rules for simplications, of course, makes sense only for more complicated expressions, when dened rules can be applied successively and not always in straightforward
way:
simplify( (2*sin(x)^2+cos(x)^2)^2, rules ) = cos(x)^4 - 4 cos(x)^2 + 4.
We meet such examples in the book during solving the real problems.
Functions of two or three variables can be easily visualised. The command
plot( sin(x), x=0..2*Pi )
will produce gure A.1. We can also plot more functions in one graph, for example,
gure A.2 can be obtained by command
plot( { sin(x), sin(x) + sin(10*x)/5 }, x = 0..2*Pi )
This

diculty is not present in competing software Mathematica by Stephen Wolfram.

161

A.1. FIRST STEPS

3D-plots of functions of two variables can be produced in similar way:


plot3d( x * cos(2*y), x = -3..3, y = -3..3 ).
The result is gure A.3. Consider now the function e(x +y )/5 cos(x2 + y 2 ). This functions describes two-dimensional transverse wave with exponential decay at one instance
of time. Before plotting it, it is useful to dene this function separately by
2

f := (x,y) -> cos(x^2+y^2) * exp( - (x^2+y^2)/5 ).


Then we can plot it in usual way, say,
plot3d( f(x,y), x = -4..4, y = -4..4 ),
which gives us not very nice picture A.4. Much better result, drawn on gure A.5, can
be obtained by following, slightly more complicated, command (insert it as one line, not
two):
plot3d( f(x, y), x = -4..4, y = -4..4, grid = [60, 60],
style = patchnogrid, shading = zgrayscale, lightmodel = light2 )
The meaning of individual parameters is intuitively clear. An option grid denes the
precision of a plot in x and y direction. In our case, both axes will be divided to 60
pieces, i.e. the continuous xyplane will be approximated by 60 60 grid. Parameter
style determines the way how 2D-surfaces are drawn. Value patchnogrid means that only
the surface will be drawn, but not the lines connecting the nodes of grid. Other possible
values are:
point, patch, patchnogrid, patchcontour, line, surface, wireframe, ...
and the reader is invited to try how these options dier and to consult Maple help to nd
other possibilities. Parameter shading can have values
none, xy, xyz, z, zgrayscale, zgreyscale, zhue.
The value of lightmodel can be one of light1,. . . light4 or user can dene his own, but we
will not discuss this here.
We can easily make an animation. Without detailed explanation, which can be found
in Maple documentation, we present following simple, but impressive, example:
f := (x, y, phi) -> cos( (x^2+y^2)/3 - phi ) * exp( - (x^2 + y^2)/3 );
with plots:
animate( plot3d, [ f(x,y,phi), x = -6..6, y = -6..6, grid = [60, 60],
style = patchnogrid, shading = zgrayscale, lighmodel = light2],
phi = 0..6*Pi, frames = 100 );
The command animate is again only one line in Maple (i.e. do not press enter unless
there is colon or semicolon). Typing commands above will generate a gure with the
rst frame of animation. Click on it and press play-button, which will appear in the
toolbox on the top of the window.
Finally, Maple knows several 3D-objects like spheres, tori, polyhedra, etc. As an
simple example, type

162

APPENDIX A. MAPLE: AN INTRODUCTION

Figure A.1: Graph of function sin x for x (0, 2) produced by command plot(sin(x),
x=0..2*Pi.

Figure A.2: Graph of functions sin x and sin x +

1
5

sin(10x) for x (0, 2).

with(plottools):
with(plots):
display(torus([1, 1, 1], 1, 2), style = surface,
scaling = constrained, lightmodel = light1, shading = zhue);
The result is on gure A.6.

163

A.1. FIRST STEPS

Figure A.3: Graph of function x cos 2y for (x, y) 3, 32 .

Figure A.4: Ugly graph of the wave.

164

APPENDIX A. MAPLE: AN INTRODUCTION

Figure A.5: Nice graph of the wave.

Figure A.6: 3D torus.

A.1. FIRST STEPS

165

Let us now turn to more serious matters. Maplecan solve algebraic equations or
systems of such equations both numerically and symbolically. Symbolical solution can
be found by solve: command
solve( sin(x)^2 + 2 sin(x) = 0 )
will nd a solution
0, arcsin 2.
System of equations can be solved in a following way:
solve( {2*x+3*y = 0, 3*x-y^2 = 2}, [x,y] );
This system of equations has two solutions which are represented like
[
[
]]
3
1
[x = 6, y = 4] , x = , y =
.
4
2
Since Maple is trying to evaluate everything symbolically, it can treat also with equations
with parameters. Command
solve( a*x^2 = 3, x )
will nd solution

3
3
, .
a
a
Implicitly, Maple uses complex numbers and nds also complex solutions of equations.
Equation x4 = 1 thus has four solutions, 1, 1, i, i. If we want to restrict to the complex
solutions, we have to type
use RealDomain in solve(x^4 = 1) end use
which then nds only 1.
If the equation contains parameters, solution may depend on their values. In such
case, Maple tries to nd the most general solution. For example, solution of x2 = a is
real, if a > 0, but is purely imaginary when a < 0. This can be made manifest by using
an option assuming. Then
solve( x^2 = a, x ) assuming a::negative
leads to manifestly imaginary solution:

I a, I a.
Notice here, that Maple uses capital I to represent imaginary unit i.
Sometimes Maple represents solution of equation of one variable by placeholder
RootOf. Consider the system

166

APPENDIX A. MAPLE: AN INTRODUCTION

solve( {x^2 - 2*x + 3 = y, y^2 + x = 0}, [x,y] );


Solution is represented in the form
[[
]]
x = RootOf(Z 4 + 2Z 2 + 3 Z, label = L20)2 , y = RootOf(Z 4 + 2Z 2 + 3 Z, label = L20) .
This representation is suitable for symbolic calculations, but we cannot see what the
values of x and y are. One way of extracting some numbers from such representation is
the following:
sol := solve( {x^2 - 2*x + 3 = y, y^2 + x = 0}, [x,y] ):
evalf( sol );
This results in numerical values of the unknowns:

[[x = 0.5991232379 1.239785918I, y = 0.6236330554 + 0.9940027292I]] .


At the end of this section, let us see, how Maple can solve dierential equations.
The simplest type of equation is ordinary dierential equation with one variable. As an
example we take the equation of harmonic oscillator,
d2 y
+ 2 y 2 (x) = 0.
dx2
Now we are to solve this equation in Maple. Dene an auxiliary variable
lho := y(t) + omega^2 y(t) = 0;
Variable lho (linear harmonic oscillator) now represents the dierential equation we want
to solve. Solution can be found using command dsolve:
dsolve( lho )
We know that the solution is linear combination of sin and cos, and indeed, Maple nds

y(x) =

C1 sin t + C2 cos t.

C1 and C2 are integration constants and depend on the initial conditions. Imagine that
at the time t = 0 our oscillator was at rest (zero velocity, y (0) = 0) and its distance from
the equilibrium position was maximal (y(0) = A, where A is amplitude). These initial
conditions can be taken into account by dening new auxiliary variable cond containing
equations determining initial conditions, and using dsolve again:
cond := y(0) = 0, y(0) = A;
dsolve( {lho, cond} );
This gives correct answer y(x) = A cos t.

A.2. OVERVIEW

A.2

167

Overview

In this section we list some general properties of Maple in a more systematical way.
Maple is divided into three dierent software parts: the kernel, libraries and user interface. The kernel contains Maples programming language and functions for performing
basic mathematical operations. These functions will be called built-in functions. The
most of useful functions are stored in the library. Library contains routines performing
specialized mathematical tasks, e.g. from linear algebra, analysis, statistics. Finally, the
user interface is the place where user can insert the code and where the results appear.
Expressions entered by user are called statements. Statements can be terminated by the
semicolon ;, when the result is computed and displayed, or by colon :, when the result is
computed but not displayed.
There is a lot of types of statements. The most simple are numbers and arithmetic
operations with numbers. Basic arithmetic operations are
+, -, *, /, ^
meaning addition, subtraction, multiplication, division and exponentiation. Parenthesis () can be used to changed the priority of individual operations in a standard way.
Example: the statement
2*(3+2^5);
computes 2(3 + 25 ) = 70 and displays

70.
Computed results can be stored in variables. To assign a value to the variable
Maple uses operator :=, for example, the input
x := 27 / 3;
y := 3;
x^2 + y^2;
calculates 27/3 = 9 and assigns the value 9 to a variable x. Similarly, it assigns the value
3 to a variable y, and nally computes x2 + y 2 = 90. The output of this code is

x := 9,
y := 3,
90.
If you do not want to display intermediate results, use colon to terminate the rst two
statements:
x := 27/3:
y := 3:
x^2 + y^2;

168

APPENDIX A. MAPLE: AN INTRODUCTION

Then only result 90 is displayed. If we want to clear the value assigned to a variable,
say, x, we us the command
x := x:
After this assignment the variable x has no value and it serves as an abstract symbol.
Once we assign a value to a variable, it remains constant until some other assignment
is made. In mathematics we need, however, also the functions. Function of one variable
is dened by, for example,
f := x -> a*x + b;
This statement says that f is a function of variable x, i.e. f maps the value of x into an
expression ax + b. If the variables a and b have some values assigned, then these values
are used to dene the function f . If they do not, Maple works with a and b symbolically.
Examples:
f := x -> a*x + b;
f(0);
f(1);
f(t);
f(x^2);
a := 2: b := 3:
f(x);
a := a: b := b:
f(x);
These commands produce following output:

f := x a x + b,
b,
a + b,
a t + b,
a x2 + b,
2 x + 3,
a x + b.
Functions of more variables are dened in a similar way:
f := (x, y) -> (x^2 + y^2)^(1/2);

Now, f = x2 + y 2 is a function of two variables x and y. This function calculates the


distance of point with coordinates (x, y) from the origin of the coordinate system with
coordinates (0, 0) according to Pythagorean theorem. Examples:
f(2, 2);
f(0, a);

169

A.2. OVERVIEW

Notice that the rst line displays result 2 2. Maple thus simplies the
result automatically to the usual form. The second line, however, gives the result x2 . The reason is
that x can be in general complex number, and thus x2 can be positive or negative and
the square root
can involve also the imaginary unit. Because of this the result is not
simplied to x2 = x.
If the code gets more complicated, it is often useful to add the comments into it. This
can be done by using the symbol # and Maple ignores everything behind it:
f := (x,y)->(x^2+y^2)^(1/2); # distance of (x,y) from (0,0)
Maple has several built-in constants. The most important for us are Ludolfs number
and Eulers number e. Number is represented by the symbol Pi. Eulers number
is not represented by the special symbol, but it can be written using the exponential
function ex evaluated at point x = 1, i.e. exp(1).
Beside the basic mathematical operations Maple has built-in elementary functions.
They are listed in following table:
sqrt(x)
exp(x)
ln(x)
log10(x)
log[b](x)
sin(x), cos(x), tan(x)
sec(x), csc(x), cot(x)
sinh(x), cosh(x), tanh(x)
sech(x), csch(x), coth(x)
arcsin(x), arccos(x), arctan(x)
arcsec(x), arccsc(x), arccot(x)
arcsinh(x), arccosh(x), arctanh(x)
arcsech(x), arccsch(x), arccoth(x)

A.2.1

square root, x
exponential function
natural logarithm
common (decadic) logarithm
logarithm of x with the base b
basic trigonometric functions
1/ cos x, 1/ sin x, 1/ tan x
hyperbolic functions
1/ cosh x, 1/ sinh x, 1/ tanh x
inverse functions of sin x, cos x, tan x
inverse functions of sec x, csc x, cot x
inverse functions of sinh x, cosh x, tanh x
inverse functions of sechx, cschx, coth x

Types

Sequences
Sequences are expressions of type
a1, a2, ... an
Members ai of the sequence can be numbers, symbols, expressions, equations, or anything
else. Example:
s1 := 1, 2, 3:
s2 := 4, 5, 6:
s3 := s2, s1;
The output is

s3 := 4, 5, 6, 1, 2, 3

(A.1)

170

APPENDIX A. MAPLE: AN INTRODUCTION

Variable s3 is now a new sequence. Expression s3[i] represents ith member of sequence
s3. For example, command
s3[4];
displays

(A.2)

The sequence can be created by enumerating all its members. If we want to generate
a sequence of rst ten even numbers, i.e. sequence

10

A = {an }n=1 , an = 2n,


we can simply type
A := 2, 4, 6, 8, 10, 12, 14, 16, 18, 20;
If we want to generate the sequence of rst hundred even numbers, this approach appears
to be non-ecient. In such cases we can use function seq():
A := seq( 2*i, i=1..100 );
Now, A is desired sequence as we can immediately verify in Maple. Function seq() has
two arguments,
seq( ai, i = imin..imax );
Here, ai is a function of i and represents ith member of the sequence, imin and imax
determine the range of index i. Consider following example:
fs := seq( sin(i*x), i=1..3);
plot( [fs], x=0..2*Pi, color=black);
First command generates the sequence

sin x, sin 2x, sin 3x.

(A.3)

Command plot then plots three functions sin ix into one graph, see gure A.7.
Sometimes we need i to acquire only every nth value from interval imin . . . imax .
Then we can call seq() with three arguments, where the third argument is the step
between two desired values of i. The sequence of even numbers can be generated also by
calling
seq(i+1, i=1..10, 2);

171

A.2. OVERVIEW

Figure A.7: Plotting the sequence of functions.

The result is

2, 4, 6, 8, 10.

(A.4)

More generally, index i does not have to be an integer, but it can acquire values
from a given set. Example. We want to generate the sequence of values sin xn , where
xn = 2n/10. In other words, we divide the full angle into ten parts

0, 2/10, 2 2/10, 3 2/10, . . .


and evaluate the sine in these points. One way of doing this is to write
seq( sin(2*Pi*n/10), n=0..9 );
The result is

0, sin

2
2

2
2

, sin
, sin
, sin , 0, sin , sin
, sin
, sin .
5
5
5
5
5
5
5
5

The same can be obtained by


s := seq( 2*Pi*n/10, n = 0..9 );
vals := seq( sin(x), x in s );
This is an equivalent of what we write in mathematical language as

172

APPENDIX A. MAPLE: AN INTRODUCTION

s
vals

2n
=
| n = 0, . . .
10
= {sin x | x s} .

}
,
(A.5)

The sequences can be generated also by operator $. For example, command


i^2$i=1..4;
is equivalent of
seq(i^2, i=1..4);
and produces a sequence

1, 4, 9, 16.

A.2.2

Procedures in Maple

Procedures are independent blocks of code designated to perform some particular task
or calculation. We start with an example:
Greeting := proc()
"Hello! I am Maple.";
end proc:
This creates the procedure Greeting. Empty parenthesis behind the word proc mean that
this procedure has no external parameters, no arguments. Next line will simply write the
text between quotation marks. Finally, the last line ends the denition of the procedure.
Procedure is called by typing its name and inserting arguments (in our case there are no
arguments):
Greeting();
Calling the procedure Greeting() yields the output

Hello! I am Maple.
Practical use of the last example is of course questionable. Let us write simple
procedure with two arguments x and y, which calculates the average of x and y:
average := proc(x, y)
simplify( (x+y)/2 );
end proc
Now we can call the new procedure:
average(1, 3);
a := average( x+y, x-y );

A.3. VECTOR CALCULUS

173

As it stands, procedure average does not dier from the function dened by
average := (x, y) -> (x+y)/2;
The purpose of using procedures is that they can contain more commands, dene their
local variables and use all features of the Maple programming language.
Local variables are variables dened inside the body of procedure which serve as auxiliary variables necessary for performing the desired task. Local variables are completely
independent of variables outside the body of procedure (global variables, even if the name
of local variable coincides with the name of some local one.

A.3

Vector Calculus

Maple has several libraries designated for implementing operations of vector calculus. We
start with brief description of the package VectorCalculus. This package can be loaded
by usual command
with(VectorCalculus):
If we replace the colon by semi-colon, Maple will show available commands and operations
dened in the package. All commands are well documented in the Help system of Maple.
First we dene the coordinate system. Suppose we work in three-dimensional Euclidean space with Cartesian coordinates (x, y, z). Then we have to use command
SetCoordinates(cartesian[x,y,z]);
Sometimes, especially in more dimensional spaces, it is useful to dene
SetCoordinates(cartesian[x[1],x[2],x[3]);
From now we assume that the coordinates (x, y, z) are being used. Beside the Cartesian
coordinate system we can use a lot of curvilinear systems which can be found in the
documentation for SetCoordinates. For the purposes of this textbook the following are of
special interest:
polar, cylindrical, spherical.

A.3.1

Basic operations with vectors

Vectors can be dened using the command Vector, for example,


r := Vector( <x, y, z> );
Omega := Vector( <0, 0, omega> );
This denes two vectors with indicated components with respect to basis vectors:

r := (x)ex + (y)ey + (z)ez ,


:= ()ez .

174

APPENDIX A. MAPLE: AN INTRODUCTION

Here, the rst vector r is a position vector of the point with coordinates (x, y, z), is
the vector of angular velocity in the direction of zaxis. The scalar product (also dot
product, inner product) of two vectors can be typed by using the function DotP roduct
or simply by using a dot between two vectors:
DotProduct( Omega, r );
Omega.r;
Both commands lead to the same result

z.
The vector product (also cross product) can be entered by following two ways:
v := CrossProduct( Omega, r );
v := Omega &x r;
The velocity is in both cases

v := y ex + x ey .
As dened, r and are constant vectors. In the physics and vector analysis we,
however, work with vector elds rather than vectors. Vector elds as vector functions of
variables (x, y, z) are dened by the command VectorField. Scalar elds are dened as
functions of three variables, for example,
f := (x,y,z) -> x^2 + y^2 + z^2;
r := VectorField( <x, y, z> );
Omega := VectorField( <0, 0, omega> );
v := Omega &x r;
The variable v is a cross product of two vector elds and therefore is itself a vector eld.
Now we can apply the basic dierential operators (gradient, divergence, curl) to these
scalar and vector elds. Each of dierential operations are realized by specic functions,
but can be performed also by using the symbolic vector operator which is represented
by symbol Del.

Mathematical

notation

grad f
curl v
div v

f
v
v

Maple notation
Gradient(f)
Curl(v)
Divergence(v)

Del(f)
Del &x v
Del.v

As an example, we can check equation (4.26). We have dened the velocity as v = r.


To calculate the curl we simply type
Del &x v;

A.3. VECTOR CALCULUS

175

which yields

2 ez .
This expression is exactly the double of angular velocity , in accordance with (4.26). It
is clear that this relation must hold in general, although we have used the special form
of . For we can always choose zaxis to be parallel to the angular velocity, and the
result must be independent of coordinates, equation (4.26) is proven. We can, however,
choose an arbitrary and repeat the procedure.
r := VectorField( <x, y, z> );
Omega := VectorField( <omega[x], omega[y], omega[z]> );
v := Omega &x r;
(1/2)*Del &x v;
The output should look like this:

r := (x) ex + (y) ey + (z) ez ,


:= (x ) ex + (y ) ey + (z ) ez ,
v := (y z z y) ex + (z x x z) ey + (x y y y ) ez ,
(x ) ex + (y ) ey + (z ) ez .
So we have proved the validity of equation (4.26) in an arbitrary Cartesian coordinate
system.

Appendix B

Eigenvalues and eigenvectors

Let A be n n matrix. Real or complex number is called an eigenvalue of matrix A,


if there exists vector (called eigenvector ) v such that

Av

v.

(B.1)

In words, if matrix acts on its eigenvector, it does not change it, except for multiplying
it with the eigenvalue. We often need to nd the eigenvalues of given matrix. This can
be done without calculating the eigenvectors. Equation (B.1) can be rewritten with the
help of unit n n matrix In :
(A In ) v = 0.
This is homogeneous system of linear equations with respect to . Homogeneous system
has non-trivial solution only if its determinant is equal to zero:
det (A In ) = 0.
This is polynomial equation, called secular equation, of degree n for and thus has in
general n complex solutions eigenvalues of matrix A.

177

Appendix C

Numerical methods for solving


dierential equations

179

Appendix D

Laplace transform

Laplace transform of function f = f (t) is dened as

L[f ](s) =

dt f (t) e s t ,

where s is complex parameter. First we nd Laplace transforms of elementary functions.


Consider the Laplace transform of constant function f (t) = 1. Then

L[1](s) =

est dt =

)
1(
1
1 [ st ]
e
= e e0 = .
0
s
s
s

Obviously, for an arbitrary constant c we obtain

L[c](s) =

c
.
s

Now, put f (t) = t. Using method per partes based on the relation
we nd

L[t](s) =
0

u v = u v u v

[
]

]
t st
1
1 [
1
t |{z}
dt = e
+
est dt = 2 est 0 = 2 .
e
|{z}
s
s
s
s
u
v
|
{z 0}
0
|
{z
}
uv

st

u v

Laplace transform of function f (t) = tn can be found by method per partes, where we
rst nd the reccurence relation between L[tn ] and L[tn1 ]:

L[t ](s) =

tn est dt =

1 [ n st ]
n
+
t e
0
s
s

181

tn1 est dt =

n
L[tn1 ].
s

182

APPENDIX D. LAPLACE TRANSFORM

Thus, we have
L[1] = L[t0 ] =

1
1
21
321
, L[t1 ] = 2 , L[t2 ] = 3 , L[t3 ] =
,....
s
s
s
s4

Obviously, the Laplace transform of tn is

L[tn ](s) =

n!
sn+1

To nd Laplace transform of f (t) = sin(t) we use dierent technique. Since under


dierentiation the function et does not change, and sin t transforms to cos t and vice vers,

we guess that integral sin t est is of the form

sin t est dt = (a sin t + b cos t) est =: P (t).

Coecients a and b are to be found by dierentiating P (t) and comparing it to sin t est :
P (t) = [(a bs) cos t (b + as) sin t] est = sin t est ,
from which we have
a =

s
1
, b =
,
2
1+s
1 + s2

so that

sin t est dt =

1
(s sin t + cos t) est .
1 + s2

Now we can compute the Laplace transform of sin t:

L[sin](s) =

sin t est dt =

]
1 [
1
(s sin t + cos t) est 0 =
.
2
1+s
1 + s2

By the same procedure we nd

L[cos](s) =

s
.
1 + s2

Functions sine and cosine in physics usually appear with argument t rather than
only t. It is therefore interesting how Laplace transforms behaves when the argument t
is changed to t, i.e. what is the relation between L[f (t)] and L[f (t)]. Straightforward
calculation gives

L[f (t)](s) =

st

f (t) e
0

{
dt =

z = t
dt = dz/

1
=

f (z) e z dz =
s

(s)
1
L[f ]
.

183

D.1. INVERSE LAPLACE TRANSFORM

In other words, Laplace transform of f (t) is the Laplace transform of f evaluated at


s/ and divided by . For sine and cosine this means

L[cos t] =

, L[sin t] = 2
.
2
+s
+ s2

Now we can easily nd also the Laplace transform of cos(t + ) and sin(t + ). Using
identities
cos(t+) = cos t cos sin t sin ,

sin(t+) = sin t cos + cos t sin ,

we immediately nd

L[cos(t + )] =

D.1

s cos sin
,
s2 + 2

L[sin(t + )] =

cos + s sin
.5
s2 + 2

Inverse Laplace transform

We dened the Laplace transform of function f (t) as a function of complex parameter s


by

F (s) = L[f ](s) =

dt f (t) est .

The question is: knowing the image of Laplace transform F (s), can we nd its preimage
f (t)? Let us examine the integral
i
f( ) =

F (s) es ds.
i

Using the substitution s = i, ds = id and substituting for F (s) this integral becomes

f( ) = i

dt

d f (t) ei( t) .

Recall that the Dirac delta-function is dened by

1
(x y) =
2

dk eik(xy) .

Basic property of Diracs function is


b
f (x) (x x0 ) dx = f (x0 ),
a

184

APPENDIX D. LAPLACE TRANSFORM

if x0 (a, b), and is zero otherwise. Therefore, if > 0, we have

f( ) = 2i

f (t) ( t) dt = 2i f (t).
0

We have thus found the preimage of function F (s) with respect to the Laplace transform:

1
f (t) =
2i

i
F (s) es d.
i

We use the notation F (s) = L[f ](s) and f (t) = L1 [F ](t).


In the previous section we have shown that the Laplace transform of function f (t) = t
is L[f ](s) = 1/s2 . According to general proof given above we expect that inverse Laplace
transform transforms 1/s2 into t. Now we would like to see how the inverse Laplace
transform works, i.e. we want to show

1
[F ](t) =
2i

i
i

1 st
e ds = t
s2

by direct calculation. As in the proof, we rst impose the substitution s = i, ds = id.


Then

1
[F ](t) =
2

1 it
e d.
2

The integrand has second-order pole at = 0. Recall that residue of nth order of
function f at point c is given by

Res(f, c) =

1
dn1
lim n1 (( c)n f ()) .
(n 1)! c d

In our case n = 2, c = 0 and f = eit / 2 , so that


)
(
)
d ( 2
d ( it )
f () = lim
e
= lim i t eit = i t.
c d
c d
0

Res(f, c) = lim

Now we use Cauchy integral formula in the form

f () d = 2 i Res(f (), c).

Finally we arrive at

D.2. LAPLACE TRANSFORM AND DIFFERENTIAL EQUATIONS

L1 [F ](t) =

185

eit
1
Res( 2 , 0) = t.
2

We have shown that

L[t](s) =

1
,
s2

L1 [

1
](t) = t,
s2

so mapping L1 is indeed an inverse of Laplace transform.

D.2

Laplace transform and dierential equations

Laplace transform is a powerful tool for solving dierential equations of certain type.
The idea is to apply the Laplace transform to the equation we want to solve. This
transformation turns the dierential equation into an algebraic one, which can be solved
using ordinary algebra. Then we apply the inverse Laplace transform to the solution and
obtain a solution of original equation.
It is trivial to check that Laplace transform is linear in the sense

L[f + g] = L[f ] + L[g],


where f and g are functions and is a constant. Thus, if we have linear ordinary
dierential equation with constant coecients,
0 f (t) + 1 f (t) + 2 f (t) + + n f (n) (t) = 0,
its Laplace transform reads
0 L[f ] + 1 L[f ] + + n L[f (n) ] = 0.
Let us nd the relation between the Laplace transform L[f ] of function f and the Laplace
transform of its derivative L[f ]. Integrating per partes we nd

L[f ](s) =

st

f (t) e

[
]
dt = f (t) est 0

)
d st
f (t)
e
dt = s L[f ] f (0).
dt
| {z }
sest

In general, we can derive the reccurence relation


L[f (n) ] = s L[f (n1) ] f (n1) (0),
from which
L[f (n) ] = sn L[f ] sn1 f (0) sn2 f (1) (0) f (n1) (0).

186

APPENDIX D. LAPLACE TRANSFORM

Let us see how these formulae can be used to solve the equation of harmonic oscillator

x
+ 2 x = 0.
Apply the Laplace transform on both sides of the equation:
L[
x] + 2 L[x] = 0.
By the rule for Laplace transform of derivative we have
s2 L[x] x(0)

s x(0) + 2 L[x] = 0.
This is an algebraic equation for the unknown L[x], which can be easily expressed as

L[x] =

x(0)

+ s x(0)
x(0)

s x(0)
= 2
+ 2
.
2
2
2
+ s
+s
+ s2

In the rst section we have shown that the frist term is image of cosine and the second
term is the image of sine under Laplace transform. The solution therefore is

x(t) = L1 [L[x]] = x(0)

cos t +

x(0)
sin t.

This is familiar solution for harmonic oscillator.

You might also like