Calculus of Variations: Hamilton’s Principle and Classical Mechanics - Exercises and Worked
Solutions
CV14 introduced Hamilton’s principle as the mechanical specialization of the calculus of
variations:
The central message was that the physical trajectory is a stationary trajectory of the action, not
automatically a minimizing trajectory. This exercise set develops that statement computationally.
The problems begin with the free particle and uniform gravity, then move through the harmonic
oscillator, pendulum, generalized coordinates, cyclic coordinates, conserved energy, total-derivative
changes of the Lagrangian, and natural endpoint conditions. These are standard themes in
analytical mechanics [1, 2, 3, 4] and they connect directly to the variational machinery developed
earlier in this series [5].
Figure. A practical workflow for Hamilton-principle exercises. The coordinates and energy
model define L; the Euler–Lagrange equations determine stationary trajectories;
symmetries supply first integrals; and CV11–CV13 determine whether a stationary path is
actually minimizing.
1 Exercises
Exercise 1: free particle with fixed endpoints
A particle of mass m moves in one dimension with
The endpoint conditions are
- Derive the Euler–Lagrange equation.
- Solve the boundary-value problem for the stationary path q∗(t).
- Evaluate the stationary action S[q∗].
- Let q = q∗ + η with η(0) = η(T) = 0. Show directly that
- Conclude that q∗ is the unique global minimizer of the action for these fixed endpoints.
Figure. The straight worldline in the (t,q) plane is stationary. For the free-particle
quadratic action, every nonzero fixed-endpoint perturbation adds the positive amount
m∫
2
dt.
Exercise 2: a projectile between prescribed spacetime endpoints
A particle moves in the vertical plane under uniform gravity. Use
The particle must travel from
to
- Derive the two Euler–Lagrange equations.
- Solve the fixed-endpoint boundary-value problem.
- Determine the required initial velocity components.
- Verify that the resulting curve is a parabola in the x-y plane when X≠0.
- Explain why the varied paths in Hamilton’s principle need not themselves satisfy the
projectile equations.
Figure. Uniform gravity with fixed spacetime endpoints. The endpoint conditions
determine the initial velocity required for the stationary projectile trajectory.
Exercise 3: harmonic oscillator boundary-value problem and critical time
For
impose
- Derive the Euler–Lagrange equation.
- For sin(ωT)≠0, find the unique stationary trajectory.
- What happens if Q≠0 but sin(ωT) = 0?
- Now set Q = 0. Show that at
there are nonzero stationary trajectories satisfying both endpoint conditions.
- For the stationary path q∗ = 0, compute the second variation and use the trial
direction
to identify the first critical time.
- Classify the three regimes T < π∕ω, T = π∕ω, and T > π∕ω in the language of
CV11–CV12.
Figure. The first harmonic-oscillator conjugate time is π∕ω. The same stationary equation
persists on longer intervals, but the minimizing character changes.
Exercise 4: the simple pendulum
A pendulum of mass m and length ℓ is described by the angle 𝜃 from the downward
vertical.
- Compute the kinetic energy and gravitational potential energy using
- Form the Lagrangian.
- Derive the exact pendulum equation.
- Because the Lagrangian is autonomous, compute the conserved energy function
- Linearize the equation for |𝜃|≪ 1 and identify the small-angle frequency.
- Explain why the linearized equation is an approximation to the dynamics, whereas the
variational derivation of the exact pendulum equation is not.
Exercise 5: a central force and a cyclic angle
For planar motion in polar coordinates, take
- Show that 𝜃 is cyclic.
- Derive the conserved generalized momentum p𝜃.
- Derive the radial Euler–Lagrange equation.
- Eliminate
in favor of the constant angular momentum ℓ.
- Show that the radial motion can be written using the effective potential
- Explain physically why the ℓ2∕(2mr2) term acts as a centrifugal barrier.
Figure. Rotational symmetry makes 𝜃 cyclic. Conservation of p𝜃 = mr2
reduces the
two-coordinate problem to one radial equation with an effective potential.
Exercise 6: deriving the energy identity for an arbitrary Lagrangian
Let
and define
- Differentiate HL with respect to time.
- Use the Euler–Lagrange equation to show
- State the conservation law when Lt = 0.
- For
show that HL = T + V .
- Explain why this derivation is a first integral of the Euler–Lagrange equation rather than an
independent postulate of energy conservation.
Exercise 7: a generalized coordinate with coordinate-dependent inertia
Consider
- Compute the generalized momentum p.
- Derive the Euler–Lagrange equation and show that it can be written
- Compute HL and show that it equals
- Explain why p = M(q)
is generally not conserved even though energy is conserved.
- Identify the special condition under which p would be conserved.
Exercise 8: adding a total time derivative to the Lagrangian
Let
- Expand dF∕dt using the chain rule.
- Show directly that L and L produce the same Euler–Lagrange equation.
- Show that their actions differ by the endpoint quantity
- Explain why the two actions therefore have the same stationary paths when the endpoints
are fixed.
- Show that the canonical momentum changes according to
- Explain why this example is an early warning that canonical momentum is
representation-dependent even when the physical trajectory is unchanged.
Exercise 9: free terminal position and the momentum boundary term
Consider
with fixed initial position q(t1), fixed endpoint times, but free terminal position q(t2).
- Repeat the first-variation calculation without imposing η(t2) = 0.
- Show that stationarity requires the Euler–Lagrange equation in the interior and the natural
terminal condition
- Now add a terminal cost
to the action. Derive the modified terminal condition
- Explain how this connects the endpoint theory of CV05 with generalized momentum in
mechanics.
2 Worked solutions
Solution 1: free particle with fixed endpoints
The action is
The Euler–Lagrange equation is
so
Hence
The boundary conditions give B = 0 and AT = a, so
The stationary action is
Now write
Then
Expanding the square gives
Because
∗ = a∕T is constant,
Therefore
Equality requires
= 0, so η is constant. The endpoint conditions then force η ≡ 0. Thus the
straight worldline is the unique global minimizer.
Solution 2: a projectile between prescribed spacetime endpoints
For x,
so
For y,
so
Integrating,
because x(0) = 0. Since x(T) = X,
Similarly,
The terminal condition gives
hence
and
When X≠0,
so
which is a parabola.
The varied paths used in the action comparison are not required to obey
= 0 and
= −g. Those equations are precisely what stationarity is used to derive. Requiring
every varied path to satisfy them would remove the freedom needed by the variational
argument.
Solution 3: harmonic oscillator boundary-value problem and critical time
The Euler–Lagrange equation is
or
The general solution is
Since q(0) = 0, B = 0. Therefore
If sin ωT≠0,
If Q≠0 and sin ωT = 0, the equation Q = A sin ωT cannot be satisfied. There is no
classical stationary trajectory with those fixed endpoint data and that prescribed travel
time.
If Q = 0 and
then
satisfies both endpoints for every real A. The boundary-value problem is therefore degenerate.
Along q∗ = 0, the action is quadratic, so the second variation is
Take
Using
we obtain
The first sign change occurs at
Thus:
This is exactly the CV11–CV12 distinction between stationarity and conjugate-point loss of
minimizing character.
Solution 4: the simple pendulum
The bob speed is
so
With the downward vertical as zero potential,
Hence
Now
Therefore
or
The generalized momentum is
Because L has no explicit time dependence,
Substituting the pendulum Lagrangian,
so
For small angles,
and the equation becomes
Therefore
Hamilton’s principle produced the exact nonlinear equation. The approximation enters only
afterward when sin 𝜃 is replaced by 𝜃.
Solution 5: a central force and a cyclic angle
Since L contains 𝜃 only through
,
Therefore
But
so
For r,
and
Hence
Using
we obtain
Define
Then
and the radial equation becomes
For ℓ≠0, the effective term
diverges as r → 0. It therefore produces an angular-momentum barrier against reaching the origin
unless the original potential is sufficiently singular to overcome it.
Solution 6: deriving the energy identity for an arbitrary Lagrangian
Start from
Differentiate:
The total derivative of L is
Substitution gives
Along an Euler–Lagrange trajectory, the parenthesis vanishes. Therefore
If Lt = 0,
For
we have
so
Thus ordinary mechanical energy appears as a first integral of the Euler–Lagrange equation when
the Lagrangian is autonomous.
Solution 7: a generalized coordinate with coordinate-dependent inertia
The generalized momentum is
Next,
Also,
The Euler–Lagrange equation therefore gives
hence
The energy function is
Because M and V can depend on q, the coordinate q is not generally cyclic. Therefore p = M
is
not generally conserved. It would be conserved only if
that is, if q were cyclic.
Solution 8: adding a total time derivative to the Lagrangian
By the chain rule,
Therefore
Compute
Then
Also,
Since mixed partial derivatives agree,
we get
Thus L and L produce exactly the same Euler–Lagrange equation.
At the action level,
For fixed endpoint data this is a fixed number, so the two actions have the same stationary
paths.
However,
Thus a total derivative leaves the motion unchanged while shifting the canonical momentum. This
is one reason canonical quantities must be interpreted with care.
Solution 9: free terminal position and the momentum boundary term
Let
with
but no restriction on η(t2).
The first variation is
Integrate by parts:
The initial boundary contribution vanishes because η(t1) = 0. Stationarity for arbitrary
interior variations gives the Euler–Lagrange equation. The remaining terminal term
is
Because the terminal position is free, η(t2) is arbitrary. Hence
Now consider
The endpoint cost varies as
Therefore the total terminal contribution is
Stationarity for arbitrary η(t2) gives
This is the mechanics form of the natural boundary-condition logic developed in CV05: generalized
momentum is literally the coefficient multiplying the free endpoint displacement in the first
variation.
3 What these exercises add to CV14
The examples above expose several structural facts that are easy to miss if Hamilton’s principle is
treated only as a formal recipe.
- A stationary path can sometimes be proved globally minimizing. The
free-particle action is a convex quadratic functional, so the exact difference formula
proves global minimality.
- Stationarity can survive after minimality is lost. The harmonic oscillator remains
governed by the same Euler–Lagrange equation beyond its first conjugate time.
- Symmetry becomes a first integral. Cyclic coordinates produce conserved
generalized momenta.
- Autonomy produces energy conservation. The identity
L = −Lt makes this
precise.
- Generalized coordinates change the formulas, not the variational logic.
Coordinate-dependent inertia produces extra terms automatically.
- Equivalent Lagrangians need not have identical canonical momenta. Total
time derivatives preserve trajectories but shift p.
- Momentum is a boundary coefficient. Free endpoint positions immediately
produce natural momentum conditions.
These points are standard in analytical mechanics treatments [1, 2, 4]. They also prepare the
next main lesson, CV15, where constraints and generalized coordinates are developed
systematically.
Summary
Hamilton’s principle starts with
and demands stationarity under admissible path variations. The resulting Euler–Lagrange
equation
contains Newtonian dynamics, but its variational origin also reveals more structure: generalized
momentum, cyclic-coordinate conservation, energy conservation, natural endpoint conditions, and
the distinction between stationary and minimizing trajectories.
The exercises show that the same framework handles straight-line free motion, projectile
trajectories, oscillations, pendulum dynamics, central forces, coordinate-dependent kinetic energy,
equivalent Lagrangians, and terminal boundary conditions. The calculations therefore
provide a practical bridge from the formal calculus of variations to classical analytical
mechanics.
References
[1] Cornelius Lanczos, The Variational Principles of Mechanics, 4th ed., Dover
Publications, 1986.
[2] Herbert Goldstein, Charles Poole, and John Safko, Classical Mechanics, 3rd ed.,
Addison-Wesley, 2002.
[3] L. D. Landau and E. M. Lifshitz, Mechanics, 3rd ed., Butterworth-Heinemann, 1976.
[4] V. I. Arnold, Mathematical Methods of Classical Mechanics, 2nd ed., Springer, 1989.
[5] I. M. Gelfand and S. V. Fomin, Calculus of Variations, Dover Publications, 2000.