Lagrangian mechanics is a way to simplify complicated dynamical problems. This note gives a brief overview. For details and practical examples you will need to consult a good book on mechanics.
As a trivial example of how Lagrangian mechanics works, consider a simple molecular dynamics simulation. Assume that the forces on the particles are given by a potential that only depends on the positions of the particles.
The difference between the net kinetic energy and the net potential
energy is called the “Lagrangian.” For a system of particles as considered here it
takes the form
It is important to note that in Lagrangian dynamics, the Lagrangian must mathematically be treated as a function of the velocities and positions of the particles. While for a given motion, the positions and velocities are in turn a function of time, time derivatives must be implemented through the chain rule, i.e. by means of total derivatives of the Lagrangian.
The “canonical momentum”
of particle
in the
direction, (with
1, 2, or 3 for the
,
,
components respectively), is defined as
The Lagrangian equations of motion are
One place where Lagrangian dynamics is very helpful is for macroscopic objects. Consider for example the dynamics of a Frisbee. Nobody is going to do a molecular dynamics computation of a Frisbee. What you do is approximate the thing as a “solid body,” (or more accurately, a rigid body). The position of every part of a solid body can be fully determined using only six parameters, instead of the countless position coordinates of the individual atoms. For example, knowing the three position coordinates of the center of gravity of the Frisbee and three angles is enough to fully fix it. Or you could just choose three reference points on the Frisbee: giving three position coordinates for the first point, two for the second, and one for the third is another possible way to fix its position.
Such parameters that fix a system are called “generalized coordinates.” The word generalized indicates that they do not need to be Cartesian coordinates; often they are angles or distances, or relative coordinates or angles. The number of generalized coordinates is called the number of degrees of freedom. It varies with the system. A bunch of solid bodies moving around freely will have six per solid body; but if there are linkages between them, like the bars in your car’s suspension system, it reduces the number of degrees of freedom. A rigid wheel spinning around a fixed axis has only one degree of freedom, and so does a solid pendulum swinging around a fixed axis. Attach a second pendulum to its end, maybe not in the same plane, and the resulting compound pendulum has two degrees of freedom.
If you try to describe such systems using plain old Newtonian mechanics, it can get ugly. For each solid body you can apply that the sum of the forces must equal mass times acceleration of the center of gravity, and that the net moment around the center of gravity must equal the rate of change of angular momentum, which you then presumably deduce using the principal axis system.
Instead of messing with all that complex vector algebra, Lagrangian dynamics allows you to deal with just a single scalar, the Lagrangian. If you can merely figure out the net kinetic and potential energy of your system in terms of your generalized coordinates and their time derivatives, you are in business.
If there are linkages between the members of the system, the benefits magnify. A brute-force Newtonian solution of the three-dimensional compound pendulum would involve six linear momentum equations and six angular ones. Yet the thing has only two degrees of freedom; the angular orientations of the individual pendulums around their axes of rotation. The reason that there are twelve equations in the Newtonian approach is that the support forces and moments exerted by the two axes add another 10 unknowns. A Lagrangian approach allows you to just write two equations for your two degrees of freedom; the support forces do not appear in the story. That provides a great simplification.
This section describes the Lagrangian approach to dynamics in general.
Assume that you have chosen suitable generalized coordinates that
fully determine the state of your system. Call these generalized
coordinates
,
,
,
,
is the number of degrees of freedom in
the system. A generic canonical coordinate will be indicated as
.
Now find the kinetic energy
and the potential energy
of your
system in terms of these generalized coordinates and their time
derivatives. The difference is the Lagrangian:

The canonical momenta are defined as
The
terms are called generalized forces, and are only needed if
there are forces that cannot be modeled by the potential
.
at a given time, imagine that the system is
displaced slightly at that time by changing the corresponding
generalized coordinate
by an infinitesimal amount
.
produces a small
amount of “virtual work.” The net virtual work divided by
gives the generalized force
.
The bottom line is that normally the
are zero if you ignore
friction. However, any collisions against rigid constraints have to
be modeled separately, just like in normal Newtonian mechanics. For
an infinitely rigid constraint to absorb the kinetic energy of an
impact requires infinite force, and
would have to be an infinite
spike if described normally. Of course, you could instead consider
describing the constraint as somewhat flexible, with a very high
potential energy penalty for violating it. Then make sure to use an
adaptive time step in any numerical integration.
It may be noted that in relativistic mechanics, the Lagrangian is not the difference between potential and kinetic energy. However, the Lagrangian equations of motion (A.1) and (A.2) still apply.
The general concept that applies both nonrelativistically and
relativistically is that of “action.” The action
is defined as the time integral of
the Lagrangian:
![]() |
(A.3) |
See {D.3.1} for a derivation of the above claims.
For a system with
generalized coordinates the Lagrangian approach
provides one equation for each generalized coordinate
.
equations involve second order time derivatives of the
unknown generalized coordinates
.
as
additional unknowns, you get
first order equations for these
unknowns. An
additional
equations are:
However, there is a much neater way to get
first order equations
in
unknowns, and it is particularly close to concepts in quantum
mechanics. Define the “Hamiltonian” as
![]() |
(A.4) |
In terms of the Hamiltonian, the equations of motion are
If the Hamiltonian does not explicitly depend on time and the generalized forces are zero, these evolution equations imply that the Hamiltonian does not change with time at all. For such systems, the Hamiltonian is the conserved total energy of the system. In particular for a nonrelativistic system, the Hamiltonian is the sum of the kinetic and potential energies, provided that the position of the system only depends on the generalized coordinates and not also explicitly on time.
See {D.3.2} for a derivation of the above claims.
The previous subsections discussed discrete mechanical objects like molecules, Frisbees, and pendulums. However, the Lagrangian and Hamiltonian formalisms can be generalized to fields like the electromagnetic field. That is mainly important for advanced physics like quantum field theories; these are not really covered in this book. But since it does appear in one advanced addendum, {A.22}, this subsection will summarize the main points.
The simplest classical field is the electrostatic potential
.
,
indicates what
particular potential it is. A single potential
is
still characterized by infinitely many variables: there is a value of
the potential at each position.
In addition there may be discrete variables. Electromagnetics would
be pretty boring if you would not have some charged particles around.
A generic coordinate of such a particle will be indicated as
.
,
,
could represent the
,
,
components of the position of the particle. If
there are more particles, just keep increasing
.
Under the above conditions, the Lagrangian will involve an integral:
The first part
is as before. It will depend on the discrete
variables and their time derivatives:
The Lagrangian density
will depend on both the fields and the
discrete coordinates:
This brings up one practical point. Consider a contribution such as
the potential energy of a particle called
with charge
in an electrostatic field
.
where
is the
potential evaluated at the position
of the particle.
But potentials evaluated at a point are problematic. You would really
want the potentials to always appear inside integrals. To achieve
that, you can assume that the particle is not really a point charge.
That its charge is spread out just a little bit around the nominal
position
.
The Lagrangian equations for the discrete parameters are exactly the
same as before, but of course now the Lagrangian includes the
integral, {D.3.3}:
![]() |
(A.6) |
The Lagrangian equations for the field are based on the Lagrangian
density instead of the Lagrangian itself. That is why you really want
to have the terms involving the field as integrals. The equations are
![]() |
(A.7) |
The canonical momenta are now
![]() |
(A.8) |
The Hamiltonian is
![]() |
(A.9) |
Hamilton’s equations for discrete variables are as before:
![]() |
(A.10) |
The equations for the fields are a bit tricky. If there are no
discrete variables, there is no problem. Then the Hamiltonian can be
written in terms of a Hamiltonian density
as
Unfortunately, if there are discrete parameters, products of integrals
will appear. Then there is no Hamiltonian density. So the only thing
you can do do is differentiate the full Hamiltonian
instead of a
Hamiltonian density
.
and a
.
until you have to start
differentiating inside an integral, like, say,
See {D.3.3} for a justification of this procedure and the other claims in this subsection.