PHYS-344 · Lesson 1 of 12 · 29 min

Why analytical mechanics: from forces to principles

In PHYS-244 you solved mechanics problems the way Newton did: draw every force, add the vectors, and integrate \(m\ddot{\mathbf r} = \mathbf F\). That approach is direct and always correct, but it becomes clumsy quickly. A bead sliding on a spinning hoop, a double pendulum, a top precessing on a table or a molecule with three vibrating atoms all involve forces you do not know in advance, such as the push of the hoop on the bead or the tension in each rod. Those constraint forces have to be found along with the motion. Coordinates that suit the problem, such as angles, fit awkwardly into a vector equation written in Cartesian components.

This course develops a different way of doing mechanics, built on two ideas. The first is that a mechanical system can be described by any set of numbers that pins down its configuration, called generalized coordinates, and that the equations of motion can be written directly in those coordinates. The second is that the actual motion is singled out by a principle: among all the ways the system could get from one configuration to another in a given time, it takes the one for which a single number, the action, is stationary. From that principle, worked out by Euler, Lagrange and Hamilton between 1744 and 1835, come the Lagrangian and Hamiltonian forms of mechanics, a direct link between symmetries and conservation laws, and the language in which quantum mechanics, statistical mechanics and field theory are written.

What PHYS-244 gave us, and what is missing

PHYS-244 covered drag, rockets, potential energy curves, nonlinear oscillators, central forces and Kepler orbits, rotating frames and rigid bodies, ending with chaos. Several of those topics required effort that the methods of this course remove. The Foucault pendulum needed the Coriolis force worked out in a rotating frame; here it comes out of a short calculation with angles. Euler's equations for a rigid body were derived from the vector form of angular momentum; here we will derive the motion of a heavy symmetric top from a single scalar function. The effective potential for orbits was introduced by hand; in lesson 7 it falls out of the Lagrangian once we notice that one coordinate does not appear in it.

The new methods do not contain new physics. For the systems we study, Lagrange's equations are Newton's second law, rearranged. Their value is practical and conceptual. Practically, they let you write down equations of motion for complicated systems almost mechanically, without ever finding the constraint forces. Conceptually, they show why the laws of mechanics have the form they do, and they reveal structure, such as conserved quantities and the geometry of motion in phase space, that the force picture hides.

Generalized coordinates

The configuration of a system is the set of positions of all its parts. A particle moving freely in space needs three numbers, a pendulum swinging in a plane needs one (the angle), and a double pendulum needs two. The number of independent quantities needed is the number of degrees of freedom. For \(N\) particles subject to \(k\) independent constraint equations there are \(n = 3N - k\) degrees of freedom. Any set of \(n\) numbers \(q_1, \dots, q_n\) that fixes the configuration uniquely is a set of generalized coordinates. They need not be lengths: angles, arc lengths, or the amplitudes of vibration modes all qualify.

For a plane pendulum of length \(\ell\), the bob's Cartesian position \((x, y)\) obeys the constraint \(x^2 + y^2 = \ell^2\). Instead of carrying two coordinates and a constraint, we use one angle \(\theta\) with \(x = \ell\sin\theta\), \(y = -\ell\cos\theta\). The constraint is now built in: every value of \(\theta\) gives a permitted position. This is the essential trick of analytical mechanics, and lessons 4 and 5 treat it in detail.

The action

Consider a single particle of mass \(m\) moving along a line in a potential \(V(x)\). Define the Lagrangian as kinetic minus potential energy,

\[L(x, \dot x) = \tfrac12 m\dot x^2 - V(x),\]

and the action of a path \(x(t)\) that starts at \(x_1\) at time \(t_1\) and ends at \(x_2\) at time \(t_2\) as

\[S[x] = \int_{t_1}^{t_2} L\big(x(t), \dot x(t)\big)\,dt.\]

The square brackets are a reminder that \(S\) is not a function of a number but of a whole path; it assigns a number to each possible way of getting from the start to the finish. Such an object is called a functional. The action has the units of energy times time, joule seconds, the same units as Planck's constant.

Hamilton's principle states that the path the particle actually follows is the one for which \(S\) is stationary: if the path is changed by a small amount \(\delta x(t)\) that vanishes at both ends, the change in \(S\) is zero to first order. In lesson 2 we show that this condition is equivalent to the Euler–Lagrange equation

\[\frac{d}{dt}\frac{\partial L}{\partial \dot x} - \frac{\partial L}{\partial x} = 0.\]

For \(L = \tfrac12 m\dot x^2 - V(x)\), the first term is \(\frac{d}{dt}(m\dot x) = m\ddot x\) and the second is \(-V'(x)\), so the equation reads \(m\ddot x = -V'(x)\): Newton's second law for a conservative force. The principle of stationary action contains Newtonian mechanics.

A numerical experiment

Before proving anything, it is worth seeing the principle work. Divide the time interval into small steps, represent a path by its positions at those times, and approximate the action by a sum. Then start from a wrong guess and move the intermediate points downhill in \(S\) until it stops changing. If the principle is right, the path we arrive at is the one Newton's law predicts.

Two panels. On the left, height against time from 0 to 2 seconds: a solid green parabola peaking at about 4.9 metres is labelled true path, and dashed gold, blue and purple curves start and end at the same points but rise higher or lower. On the right, the action against a parameter epsilon from minus 0.5 to 0.5: a parabola with its lowest point at epsilon equal to zero, with data points marked on both sides.
Left: the true path of a ball thrown up and caught 2 s later, with three varied paths sharing its end points. Right: the action of the varied paths. The curve is flat at \(\varepsilon = 0\), so first-order changes in the path do not change the action.
Finding a path by minimizing the discretized action, and testing whether the true path is a minimum
import math

# Discretized action S = sum over steps of (m/2) v^2 dt - V dt, with both ends fixed.
def action(x, dt, m, V):
    S = 0.0
    for i in range(len(x) - 1):
        v = (x[i + 1] - x[i]) / dt
        xm = 0.5 * (x[i] + x[i + 1])
        S += (0.5 * m * v * v - V(xm)) * dt
    return S

def relax(x, dt, m, dV, sweeps=20000, rate=0.45):
    # gradient descent on the interior points; dS/dx_i = -m(x_{i+1} - 2x_i + x_{i-1})/dt - V'(x_i) dt
    x = list(x)
    for _ in range(sweeps):
        for i in range(1, len(x) - 1):
            grad = -m * (x[i + 1] - 2 * x[i] + x[i - 1]) / dt - dV(x[i]) * dt
            x[i] -= rate * grad * dt / m
    return x

# 1. Free fall: a ball thrown up and caught 2 s later at the same height
m, g, T, N = 1.0, 9.81, 2.0, 40
dt = T / N
V = lambda y: m * g * y; dV = lambda y: m * g
guess = [0.0] * (N + 1)                      # start from "the ball just sits there"
best = relax(guess, dt, m, dV)
exact = [0.5 * g * (i * dt) * (T - i * dt) for i in range(N + 1)]
print("free fall, top of path from minimizing S:", round(max(best), 4), "m; exact", round(max(exact), 4), "m")
print("largest deviation from the exact parabola:", f"{max(abs(a - b) for a, b in zip(best, exact)):.2e} m")

# 2. Varying the true path by eps*sin(pi t/T): S changes only at second order in eps
for eps in (0.0, 0.1, 0.2, 0.4):
    path = [y + eps * math.sin(math.pi * i / N) for i, y in enumerate(exact)]
    print(f"eps = {eps:.1f}: S = {action(path, dt, m, V):.5f} J s")

# 3. Harmonic oscillator: the true path minimizes S only if T < pi/omega
k = 1.0; omega = 1.0
Vh = lambda x: 0.5 * k * x * x
for T in (0.8 * math.pi, 1.2 * math.pi):
    dt = T / N
    true = [math.sin(omega * i * dt) / math.sin(omega * T) * 0.5 for i in range(N + 1)]  # x(0)=0, x(T)=0.5
    S0 = action(true, dt, m, Vh)
    bump = [x + 0.05 * math.sin(math.pi * i / N) for i, x in enumerate(true)]
    print(f"T = {T / math.pi:.1f} pi: S(true) = {S0:.5f}, S(true + bump) = {action(bump, dt, m, Vh):.5f}",
          "-> minimum" if action(bump, dt, m, Vh) > S0 else "-> saddle, not a minimum")
Output
free fall, top of path from minimizing S: 4.905 m; exact 4.905 m
largest deviation from the exact parabola: 5.86e-14 m
eps = 0.0: S = -32.05865 J s
eps = 0.1: S = -32.04632 J s
eps = 0.2: S = -32.00933 J s
eps = 0.4: S = -31.86136 J s
T = 0.8 pi: S(true) = -0.17175, S(true + bump) = -0.17083 -> minimum
T = 1.2 pi: S(true) = 0.17306, S(true + bump) = 0.17224 -> saddle, not a minimum

Three things come out of this program. First, starting from a ball that just sits on the ground, gradient descent on the action finds the parabola of a ball thrown up and caught 2 s later, peaking at \(gT^2/8 = 4.905\ \mathrm m\), and agrees with it to rounding error. No force was ever computed: the program only knew the kinetic and potential energy. Second, when the true path is changed by \(\varepsilon\sin(\pi t/T)\), the action rises by an amount proportional to \(\varepsilon^2\): 0.012 for \(\varepsilon = 0.1\), 0.049 for 0.2 and 0.197 for 0.4, a ratio of very nearly four each time \(\varepsilon\) doubles. A first-order change in the path produces only a second-order change in \(S\). That is what stationary means.

Third, stationary does not always mean minimum. For the harmonic oscillator the true path is a minimum of the action only if the time interval is shorter than half a period, \(T < \pi/\omega\). For a longer interval the program finds a variation that lowers the action, so the true path is a saddle point: a minimum along some directions in the space of paths and a maximum along others. That is why the precise statement is the principle of stationary action, not least action. The name least action survives from history, and for short enough time intervals it is accurate.

Why a principle?

It can seem strange that a particle should know about a whole path, including its end point, before it gets there. It does not. The Euler–Lagrange equation is a local differential equation: the acceleration at each instant depends only on the position and velocity at that instant. The variational principle is an equivalent global way of stating the same law, just as the statement that light takes the quickest route between two points (Fermat's principle, which we meet in lesson 2) is equivalent to the local law of refraction at each surface.

The deeper reason the action matters came in 1948, when Richard Feynman showed that quantum mechanics can be built from it. In Feynman's path integral a quantum particle explores every path, each contributing a complex number of size one and phase \(S/\hbar\). For everyday objects the action of a typical path is around \(10^{30}\) or more times \(\hbar\), so the phases of neighbouring paths swing wildly and cancel, except near a path where \(S\) is stationary: there neighbouring paths have nearly the same phase and add up. Classical mechanics is the stationary-phase limit of quantum mechanics. We return to this in lesson 12.

A short history

Pierre de Fermat proposed in 1662 that light travels between two points along the path of least time. Johann Bernoulli posed the brachistochrone problem in 1696, asking for the curve of quickest descent; its solution by several mathematicians, including Newton, launched the calculus of variations. Pierre-Louis Moreau de Maupertuis proposed a principle of least action for mechanics in 1744, and in the same year Leonhard Euler gave it a correct mathematical form for a particle moving in a plane. Joseph-Louis Lagrange developed Euler's methods into the general calculus of variations in a letter to Euler in 1755 and then rewrote all of mechanics in his Mécanique analytique of 1788, a book that famously contained no diagrams.

William Rowan Hamilton, working in Dublin, stated the principle in its modern form in 1834 and 1835 and introduced the equations that bear his name, which treat position and momentum on an equal footing. Carl Jacobi refined Hamilton's work in the 1830s and 1840s, producing the Hamilton–Jacobi equation. Siméon Denis Poisson introduced the bracket that now carries his name in 1809, and Joseph Liouville proved his theorem on phase-space volume in 1838. In 1918 Emmy Noether proved that every continuous symmetry of the action gives a conserved quantity, and at the end of the nineteenth century Henri Poincaré, followed in the twentieth by Kolmogorov, Arnold and Moser, used the Hamiltonian framework to understand when orbits are regular and when they are chaotic.

The plan of the course

Lessons 2 and 3 develop the calculus of variations, the mathematics of finding a function that makes an integral stationary, and apply it to classic problems: the brachistochrone, the hanging chain and the shortest path on a surface. Lessons 4 to 8 build Lagrangian mechanics: generalized coordinates, constraints and the forces that enforce them, Noether's theorem, central forces and the symmetric top, and small oscillations about equilibrium solved as an eigenvalue problem. Lessons 9 to 11 develop Hamiltonian mechanics: Hamilton's equations, phase space and Liouville's theorem, Poisson brackets, canonical transformations, action-angle variables and the Hamilton–Jacobi equation. Lesson 12 draws the threads together and shows how they lead into chaos, quantum mechanics and field theory.

Every lesson has a short program, written with only the Python standard library, that checks the mathematics numerically. Several of them integrate equations of motion with the fourth-order Runge–Kutta method from PHYS-244; from lesson 9 on we will also use the leapfrog method, which respects the geometric structure of Hamiltonian mechanics and so keeps energy errors bounded over very long runs.

Worked problem

The action of free fall

A ball of mass \(m\) is thrown up at \(t = 0\) from height 0 and caught at height 0 at time \(T\). Compute the action of the true path and of the path \(x(t) = 0\) (the ball never moves), and show which is smaller.

Show solution
  1. The true path is \(x = \tfrac12 g t(T - t)\), so \(\dot x = \tfrac12 g(T - 2t)\).
  2. Kinetic energy integral: \(\int_0^T \tfrac12 m \cdot \tfrac14 g^2 (T - 2t)^2 dt = \tfrac18 m g^2 \cdot \tfrac{T^3}{3} = \tfrac{m g^2 T^3}{24}\).
  3. Potential energy integral: \(\int_0^T m g \cdot \tfrac12 g t(T - t)\,dt = \tfrac12 m g^2 \cdot \tfrac{T^3}{6} = \tfrac{m g^2 T^3}{12}\).
  4. So \(S_{\text{true}} = \tfrac{m g^2 T^3}{24} - \tfrac{m g^2 T^3}{12} = -\tfrac{m g^2 T^3}{24}\). For the path that sits at height 0 both terms vanish, so \(S = 0\).
  5. With \(m = 1\ \mathrm{kg}\), \(g = 9.81\ \mathrm{m/s^2}\), \(T = 2\ \mathrm s\): \(S_{\text{true}} = -96.24/24 \times 8 = -32.08\ \mathrm{J\,s}\).

Answer: \(S_{\text{true}} = -mg^2T^3/24 \approx -32.1\ \mathrm{J\,s}\), lower than the 0 of the motionless path. The program's discretized value, \(-32.059\ \mathrm{J\,s}\), differs slightly because the sum evaluates the potential at the middle of each step.

Worked problem

Counting degrees of freedom

How many degrees of freedom do these systems have, and what generalized coordinates would you choose? (a) A bead on a fixed circular wire. (b) A double pendulum in a plane. (c) A rigid rod moving freely in space. (d) A coin rolling without slipping on a table.

Show solution
  1. (a) One: the angle of the bead around the wire.
  2. (b) Two particles in a plane have 4 coordinates; two fixed rod lengths remove 2, leaving the two angles \(\theta_1, \theta_2\).
  3. (c) Two particles in space (6 coordinates) with one fixed distance: 5. Use the centre of mass position and two angles giving the rod's direction (rotation about its own axis is not a degree of freedom for an ideal thin rod).
  4. (d) A coin's configuration needs the contact point \((x, y)\) and three angles: 5 coordinates. Rolling without slipping restricts the velocities, not the positions, so all 5 are still independent. This is a nonholonomic constraint, treated in lesson 5.

Answer: (a) 1, (b) 2, (c) 5, (d) 5 coordinates but only 3 independent velocities. The last case shows that counting degrees of freedom needs care when constraints involve velocities.

Using the methods well

Lagrangian mechanics is most useful when constraints are present and when natural coordinates are not Cartesian. For a single particle in a simple force field, Newton's law is just as quick. Its power appears in problems such as a pendulum hanging from a moving support, a bead on a rotating wire, coupled oscillators, or a top. In each case you write down the kinetic and potential energies in whatever coordinates are convenient, form \(L = T - V\), and the equations of motion follow by differentiation. Because \(T\) and \(V\) are scalars, there is no need to resolve vectors or to keep track of the direction of every force.

A second strength is that energies are often easy to write even when forces are not. The kinetic energy of a rigid body, of a fluid element, or of an electromagnetic field has a compact expression. The Lagrangian approach carries over unchanged to these systems, which is one reason it became the standard language of theoretical physics.

Common mistakes

  • MistakeWriting the Lagrangian as \(T + V\).

    InsteadIt is \(T - V\). With the wrong sign, the Euler–Lagrange equation gives \(m\ddot x = +V'(x)\), the force reversed.

  • MistakeThinking the action is always a minimum on the true path.

    InsteadIt is stationary. For long enough time intervals the true path is a saddle point, as the oscillator example shows.

  • MistakeBelieving that the variational principle requires the particle to know its future.

    InsteadThe principle is equivalent to a local differential equation; the end-point condition is part of how the question is posed, not part of the dynamics.

  • MistakeCounting constraint equations that restrict only velocities as removing degrees of freedom.

    InsteadRolling constraints that cannot be integrated restrict velocities but leave all configuration coordinates independent.

  • MistakeTreating generalized coordinates as if they must have units of length.

    InsteadAngles, arc lengths and mode amplitudes are all valid; the corresponding momenta and forces then have different units.

Summary and key terms

  • Generalized coordinates are any set of independent numbers that fix a system's configuration; their count is the number of degrees of freedom.
  • The Lagrangian is \(L = T - V\), and the action is its time integral along a path between fixed end points.
  • Hamilton's principle: the true path makes the action stationary; this is equivalent to the Euler–Lagrange equation and, for conservative forces, to Newton's second law.
  • Stationary means a first-order change in the path gives only a second-order change in the action; the true path may be a minimum or a saddle.
  • Feynman's path integral explains the principle: classical paths are those where the quantum phases \(S/\hbar\) add constructively.
generalized coordinates
Independent quantities, not necessarily lengths, that specify the configuration of a system.
degrees of freedom
The number of independent generalized coordinates.
Lagrangian
Kinetic energy minus potential energy, written as a function of coordinates, velocities and time.
action
The time integral of the Lagrangian along a path; it has units of joule seconds.
functional
A rule assigning a number to a whole function, such as a path.
Hamilton's principle
The actual motion makes the action stationary among all paths with the same end points and duration.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Write the Lagrangian of a mass \(m\) on a spring of stiffness \(k\) and derive its equation of motion.

    Show answer

    \(L = \tfrac12 m\dot x^2 - \tfrac12 k x^2\); \(\partial L/\partial\dot x = m\dot x\), \(\partial L/\partial x = -kx\), so \(m\ddot x + kx = 0\).

  2. Write the Lagrangian of a plane pendulum in terms of \(\theta\) and derive its equation of motion.

    Show answer

    \(T = \tfrac12 m\ell^2\dot\theta^2\), \(V = -mg\ell\cos\theta\), so \(L = \tfrac12 m\ell^2\dot\theta^2 + mg\ell\cos\theta\) and \(m\ell^2\ddot\theta = -mg\ell\sin\theta\).

  3. How many degrees of freedom has a rigid body rotating about a fixed point?

    Show answer

    Three, for example the three Euler angles.

  4. A path is varied by \(\varepsilon\eta(t)\) and the action changes from \(S_0\) to \(S_0 + 0.05\) when \(\varepsilon = 0.1\). Estimate the change for \(\varepsilon = 0.3\) if the path is the true one.

    Show answer

    The change is quadratic: \(0.05 \times 9 = 0.45\).

  5. For the oscillator with \(\omega = 2\ \mathrm{rad/s}\), up to what time interval is the true path a minimum of the action?

    Show answer

    \(T < \pi/\omega = 1.57\ \mathrm s\).

  6. Show that adding a constant to the Lagrangian does not change the equations of motion.

    Show answer

    A constant has zero derivatives with respect to \(x\) and \(\dot x\), so both terms of the Euler–Lagrange equation are unchanged.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz