Last Updated May 28, 2026
Lagrangian and Hamiltonian mechanics reformulate classical physics around action, energy, constraints, symmetry, generalized coordinates, and phase space. Newtonian mechanics asks how forces determine acceleration. Lagrangian mechanics asks which path makes the action stationary. Hamiltonian mechanics asks how a system evolves through phase space according to energy-like structure. These are not merely alternative notations. They are deeper frameworks that reveal why conservation laws arise, why constraints can be handled elegantly, why symmetries matter, and why classical mechanics becomes a gateway to quantum mechanics, statistical physics, field theory, and modern computational dynamics.
The importance of analytical mechanics is that it changes the object of explanation. Instead of beginning with individual force components in Cartesian coordinates, one can choose generalized coordinates adapted to the system, construct a Lagrangian from kinetic and potential energy, derive equations of motion through variational reasoning, and then transform into Hamiltonian form using generalized momenta. The result is a mechanics of structure: coordinates, constraints, action, conjugate momentum, phase space, canonical transformations, Poisson brackets, and conserved quantities.
This article develops Lagrangian and Hamiltonian Mechanics as a foundational topic within the Physics knowledge series. It explains generalized coordinates, degrees of freedom, constraints, the principle of stationary action, the Euler–Lagrange equations, canonical momentum, cyclic coordinates, conservation laws, Hamiltonians, Hamilton’s equations, phase space, Poisson brackets, canonical transformations, symplectic structure, small oscillations, constrained systems, and computational integration. Selected R and Python workflows appear here, while the full GitHub repository contains research-grade computational workflows for variational mechanics, pendulum dynamics, phase-space diagnostics, Hamiltonian integration, symplectic Euler methods, Poisson brackets, canonical maps, SQL metadata, C/C++/Fortran/Rust examples, and reproducible analytical-mechanics research.
Main Library
Publications
Article Map
Physics
Related Topic
Mathematics
Related Topic
Data Systems & Analytics
Related Topic
Astronomy

Why Analytical Mechanics Matters
Analytical mechanics matters because it reveals the architecture behind classical dynamics. Newton’s laws are powerful and foundational, but many physical systems are difficult to analyze by resolving all constraint forces directly. A bead sliding on a wire, a pendulum constrained to a circular arc, a double pendulum, a rolling disk, a rigid body, a coupled oscillator, or a particle moving in curvilinear coordinates may be awkward in Cartesian force components. Lagrangian mechanics handles such systems by choosing coordinates suited to the constraints and deriving motion from energy and action.
Hamiltonian mechanics then deepens the structure further. Instead of describing motion through positions and velocities, it describes motion through generalized coordinates and conjugate momenta. The system becomes a flow in phase space. This phase-space perspective is central to statistical mechanics, chaos theory, canonical transformations, quantum mechanics, and modern dynamical systems.
Analytical mechanics also makes conservation laws intelligible. Conservation of energy, momentum, and angular momentum are not merely empirical patterns. They arise from symmetries: time-translation symmetry, spatial-translation symmetry, and rotational symmetry. Noether’s theorem gives this connection a precise mathematical form in variational systems. This transforms conservation laws from useful facts into structural consequences of invariance.
For modern physics, Lagrangian and Hamiltonian mechanics are indispensable. The Lagrangian approach extends naturally into field theory, relativity, electromagnetism, quantum field theory, and gauge theory. The Hamiltonian approach extends naturally into phase-space methods, canonical quantization, statistical ensembles, symplectic geometry, and computational integration. Analytical mechanics therefore serves as the hinge between classical physics and the conceptual language of twentieth- and twenty-first-century physics.
From Newtonian Forces to Analytical Structure
Newtonian mechanics begins with the relation:
\mathbf{F} = m\mathbf{a}
\]
Interpretation: Newton’s second law relates net force to mass and acceleration.
This form is direct and physically transparent. If the forces are known, acceleration follows. Yet the method can become complicated when constraint forces are present. A pendulum bob is constrained by a string. A bead may be constrained to move on a wire. A rolling body has contact constraints. A rigid body contains many internal constraints. Newton’s laws remain true, but directly accounting for every constraint force can obscure the underlying motion.
Lagrangian mechanics reorganizes the problem. Instead of asking for all forces, it asks for a set of generalized coordinates \(q_i\) that describe the allowed motion. It then constructs a scalar function, the Lagrangian:
L = T – V
\]
Interpretation: For many conservative mechanical systems, the Lagrangian is kinetic energy minus potential energy.
where \(T\) is kinetic energy and \(V\) is potential energy. The equations of motion follow from the Euler–Lagrange equations:
\frac{d}{dt}
\left(
\frac{\partial L}{\partial \dot{q}_i}
\right)
–
\frac{\partial L}{\partial q_i}
= 0
\]
Interpretation: The Euler–Lagrange equations derive motion from the Lagrangian in generalized coordinates.
This is not merely a shortcut. It changes the grammar of mechanics. Forces become less central than energy, coordinates, constraints, and variation. In many systems, especially those with constraints or curvilinear coordinates, the Lagrangian method produces the equations of motion more cleanly than a direct force balance.
Hamiltonian mechanics reorganizes the problem again. It defines generalized momenta:
p_i = \frac{\partial L}{\partial \dot{q}_i}
\]
Interpretation: Canonical momentum is conjugate to a generalized coordinate.
and constructs the Hamiltonian:
H(q,p,t) = \sum_i p_i\dot{q}_i – L
\]
Interpretation: The Hamiltonian is constructed from the Lagrangian through a Legendre transform.
The equations of motion become first-order equations in phase space. This gives mechanics a geometric structure that becomes essential in advanced physics.
Generalized Coordinates and Degrees of Freedom
Generalized coordinates are variables that specify the configuration of a system. They need not be Cartesian positions. They may be angles, distances, arc lengths, normal-mode amplitudes, rotation parameters, or other coordinates suited to the constraints and geometry of the problem.
A simple pendulum can be described by one coordinate, the angle \(\theta\), rather than two Cartesian coordinates \(x\) and \(y\). A double pendulum can be described by two angles. A bead constrained to a circular hoop can be described by one angular coordinate. A rigid body may require coordinates specifying translation and orientation. The number of independent generalized coordinates is the number of degrees of freedom.
The value of generalized coordinates is not merely convenience. Good coordinates encode constraints directly. If a pendulum length is fixed, using the angle automatically respects the length constraint. If a particle moves on a surface, coordinates on that surface avoid unnecessary constraint equations. Analytical mechanics therefore rewards coordinate choices that reflect the structure of the system.
For a system with generalized coordinates:
q_1, q_2, \ldots, q_n
\]
Interpretation: Generalized coordinates specify the independent configuration variables of a system.
the generalized velocities are:
\dot{q}_1, \dot{q}_2, \ldots, \dot{q}_n
\]
Interpretation: Generalized velocities describe rates of change of the generalized coordinates.
The Lagrangian is a function of coordinates, velocities, and time:
L = L(q_i,\dot{q}_i,t)
\]
Interpretation: The Lagrangian encodes the dynamics of a system in generalized-coordinate form.
This formulation allows the same variational machinery to treat systems with very different geometries.
Constraints and Virtual Displacement
Constraints restrict the allowed motion of a system. A holonomic constraint can be written as an equation among coordinates and time:
f(q_1,q_2,\ldots,q_n,t)=0
\]
Interpretation: A holonomic constraint restricts the allowed configurations through an equation.
A pendulum of fixed length provides a simple example. In Cartesian coordinates, the constraint is:
x^2 + y^2 = \ell^2
\]
Interpretation: A fixed-length pendulum bob is constrained to move on a circle.
Using the angle \(\theta\) as the generalized coordinate builds this constraint into the description. The motion becomes one-dimensional in configuration space even though the pendulum moves in a plane.
Virtual displacement is an infinitesimal change in configuration consistent with constraints at a fixed time. The principle of virtual work and d’Alembert’s principle help motivate the Lagrangian formalism by showing how constraint forces can often be eliminated from the equations of motion when they do no virtual work.
Not all constraints are simple. Nonholonomic constraints, rolling constraints, time-dependent constraints, and inequality constraints require more care. Some can be handled with Lagrange multipliers. Others require specialized methods. Analytical mechanics does not make constraints disappear; it provides a systematic language for treating them.
The Lagrangian
The Lagrangian is the central object of Lagrangian mechanics. For many classical systems with conservative forces, it is:
L = T – V
\]
Interpretation: The Lagrangian is a scalar function whose variational structure generates the equations of motion.
where \(T\) is kinetic energy and \(V\) is potential energy. The Lagrangian is not itself the total energy. It is a function whose variational properties generate the equations of motion.
For a particle of mass \(m\) moving in one dimension under potential \(V(x)\), the Lagrangian is:
L(x,\dot{x}) = \frac{1}{2}m\dot{x}^2 – V(x)
\]
Interpretation: A one-dimensional particle Lagrangian combines kinetic energy and potential energy.
The Euler–Lagrange equation gives:
\frac{d}{dt}(m\dot{x}) + \frac{dV}{dx} = 0
\]
Interpretation: Applying the Euler–Lagrange equation recovers force from the gradient of potential energy.
or:
m\ddot{x} = -\frac{dV}{dx}
\]
Interpretation: Newton’s second law is recovered for conservative one-dimensional motion.
This reproduces Newton’s second law for conservative forces. But the Lagrangian approach also generalizes beyond simple Cartesian motion. The kinetic energy can be expressed in generalized coordinates, the potential can reflect geometry and interactions, and constraints can be incorporated through coordinate choice or multipliers.
The Lagrangian is also not unique in a trivial algebraic sense. Adding a total time derivative of a function to the Lagrangian does not change the equations of motion:
L’ = L + \frac{dF(q,t)}{dt}
\]
Interpretation: Adding a total time derivative changes the Lagrangian but not the resulting equations of motion.
This fact becomes important in advanced mechanics and field theory, where gauge-like freedoms and boundary terms play significant roles.
Stationary Action and the Euler–Lagrange Equations
The action is the time integral of the Lagrangian:
S[q(t)] = \int_{t_1}^{t_2} L(q,\dot{q},t)\,dt
\]
Interpretation: The action assigns a scalar value to an entire path through configuration space.
Hamilton’s principle states that the physical path makes the action stationary under small variations of the path that keep endpoints fixed:
\delta S = 0
\]
Interpretation: The physical path is a stationary point of the action functional.
This does not necessarily mean the action is a minimum. It may be a maximum or saddle point. “Stationary action” is therefore more precise than “least action,” although the older phrase remains common.
The calculus of variations leads from stationary action to the Euler–Lagrange equations:
\frac{d}{dt}
\left(
\frac{\partial L}{\partial \dot{q}_i}
\right)
–
\frac{\partial L}{\partial q_i}
= 0
\]
Interpretation: Stationary action yields the Euler–Lagrange differential equations for each generalized coordinate.
These equations are the heart of Lagrangian mechanics. They convert a scalar variational principle into differential equations of motion. The power of the result is that it applies to any appropriate generalized coordinate system.
Stationary action also changes the philosophical feel of mechanics. Instead of describing motion as a sequence of local force responses alone, it describes the whole path through a variational condition. This does not mean future events cause past motion. It means the differential equations of local motion can be derived from a global mathematical principle.
Canonical Momentum and Cyclic Coordinates
Canonical momentum is defined by:
p_i = \frac{\partial L}{\partial \dot{q}_i}
\]
Interpretation: Canonical momentum is the momentum conjugate to a generalized coordinate.
For simple Cartesian motion, canonical momentum often equals ordinary linear momentum. But in generalized coordinates, rotating systems, electromagnetic systems, and constrained systems, canonical momentum may differ from mechanical momentum. This distinction becomes essential in Hamiltonian mechanics and quantum mechanics.
A coordinate \(q_i\) is called cyclic, or ignorable, if the Lagrangian does not depend explicitly on it:
\frac{\partial L}{\partial q_i} = 0
\]
Interpretation: A cyclic coordinate does not appear explicitly in the Lagrangian.
The Euler–Lagrange equation then gives:
\frac{d}{dt}
\left(
\frac{\partial L}{\partial \dot{q}_i}
\right)
= 0
\]
Interpretation: If a coordinate is cyclic, its conjugate momentum is conserved.
so the corresponding canonical momentum is conserved:
p_i = \mathrm{constant}
\]
Interpretation: Cyclic coordinates reveal conserved canonical momenta.
This is one of the simplest and most useful conservation results in analytical mechanics. If an angle is cyclic, angular momentum may be conserved. If a coordinate associated with translation is cyclic, linear momentum may be conserved. The structure of the Lagrangian reveals conserved quantities through absence: what the Lagrangian does not depend on can matter as much as what it does.
Symmetry and Conservation
Analytical mechanics makes the relationship between symmetry and conservation explicit. If the Lagrangian is invariant under time translation, energy is conserved. If it is invariant under spatial translation, linear momentum is conserved. If it is invariant under rotation, angular momentum is conserved.
Noether’s theorem gives the general form of this relationship for continuous symmetries of the action. In broad terms, every continuous differentiable symmetry of the action corresponds to a conservation law. This is one of the deepest results in theoretical physics because it connects geometry, invariance, and dynamics.
The result can be summarized schematically:
| Symmetry | Invariance | Conserved Quantity |
|---|---|---|
| Time translation | Laws unchanged when time origin shifts | Energy |
| Spatial translation | Laws unchanged when position origin shifts | Linear momentum |
| Rotation | Laws unchanged under orientation change | Angular momentum |
This is why analytical mechanics is more than a method for solving problems. It is a language for identifying what the laws of motion preserve. It provides the conceptual route from classical conservation laws to modern symmetry principles in field theory, particle physics, and relativity.
The Hamiltonian
The Hamiltonian is constructed from the Lagrangian through a Legendre transform. Given canonical momenta:
p_i = \frac{\partial L}{\partial \dot{q}_i}
\]
Interpretation: Canonical momenta provide the variables needed to transform from Lagrangian to Hamiltonian form.
the Hamiltonian is:
H(q,p,t) = \sum_i p_i\dot{q}_i – L(q,\dot{q},t)
\]
Interpretation: The Hamiltonian is the Legendre transform of the Lagrangian with respect to generalized velocities.
when the velocities can be expressed in terms of \(q\), \(p\), and \(t\). For many classical conservative systems, the Hamiltonian equals the total mechanical energy:
H = T + V
\]
Interpretation: In many conservative systems, the Hamiltonian equals total mechanical energy.
But this equality is not universal. Time-dependent coordinate transformations, velocity-dependent potentials, constraints, and nonstandard systems can complicate the relation between Hamiltonian and energy. The Hamiltonian should therefore be understood first as the generator of time evolution in phase space, not merely as a synonym for energy.
For a one-dimensional particle with:
L = \frac{1}{2}m\dot{x}^2 – V(x)
\]
Interpretation: A one-dimensional conservative particle has kinetic minus potential energy as its Lagrangian.
the canonical momentum is:
p = m\dot{x}
\]
Interpretation: For simple Cartesian motion, canonical momentum equals ordinary linear momentum.
and the Hamiltonian is:
H(x,p) = \frac{p^2}{2m} + V(x)
\]
Interpretation: The Hamiltonian represents kinetic plus potential energy in phase-space variables.
This form is central because it places position and momentum on equal footing as independent coordinates in phase space.
Hamilton’s Equations
Hamilton’s equations are:
\dot{q}_i = \frac{\partial H}{\partial p_i}
\]
\[
\dot{p}_i = -\frac{\partial H}{\partial q_i}
\]
Interpretation: Hamilton’s equations give first-order phase-space evolution for coordinates and conjugate momenta.
These first-order equations replace the second-order Euler–Lagrange equations. Instead of solving directly for coordinates and accelerations, one solves for coordinates and momenta as coupled first-order dynamics.
For the one-dimensional Hamiltonian:
H(x,p) = \frac{p^2}{2m} + V(x)
\]
Interpretation: A one-dimensional Hamiltonian expresses energy in terms of position and momentum.
Hamilton’s equations give:
\dot{x} = \frac{p}{m}
\]
\[
\dot{p} = -\frac{dV}{dx}
\]
Interpretation: Hamilton’s equations recover velocity and force from phase-space derivatives of the Hamiltonian.
which reproduce Newton’s law. Yet the Hamiltonian form gives additional structure. It defines a flow in phase space. It preserves phase-space volume under Hamiltonian evolution. It supports canonical transformations. It leads naturally to Poisson brackets. It provides the conceptual template for quantization.
Phase Space and Geometric Mechanics
Phase space is the space of generalized coordinates and conjugate momenta:
(q_1,\ldots,q_n,p_1,\ldots,p_n)
\]
Interpretation: Phase space contains both configuration variables and their conjugate momenta.
A system with \(n\) degrees of freedom has a \(2n\)-dimensional phase space. Each point in phase space represents a complete instantaneous state of the system. The Hamiltonian determines how that point moves through phase space over time.
This perspective is especially powerful for oscillators, orbital motion, nonlinear dynamics, chaos, statistical mechanics, and computational integration. A harmonic oscillator traces closed curves in phase space. A damped system, which is not Hamiltonian in the simple conservative sense, spirals inward. A chaotic Hamiltonian system may show complex phase-space structure while still obeying deterministic equations.
Hamiltonian flow also has geometric properties. It preserves a symplectic structure, and under appropriate conditions it preserves phase-space volume. These properties are not merely abstract. They affect numerical simulation. Ordinary numerical integrators may slowly distort energy or phase-space geometry, while symplectic integrators are designed to respect Hamiltonian structure more faithfully over long times.
Poisson Brackets and Canonical Transformations
The Poisson bracket of two phase-space functions \(A(q,p,t)\) and \(B(q,p,t)\) is:
\{A,B\}
=
\sum_i
\left(
\frac{\partial A}{\partial q_i}
\frac{\partial B}{\partial p_i}
–
\frac{\partial A}{\partial p_i}
\frac{\partial B}{\partial q_i}
\right)
\]
Interpretation: The Poisson bracket encodes the algebraic structure of Hamiltonian phase-space dynamics.
Using the Poisson bracket, time evolution can be written as:
\frac{dA}{dt}
=
\{A,H\}
+
\frac{\partial A}{\partial t}
\]
Interpretation: The Hamiltonian generates time evolution through the Poisson bracket.
This compact expression reveals the Hamiltonian as the generator of time evolution. If \(A\) has no explicit time dependence and \(\{A,H\}=0\), then \(A\) is conserved.
Canonical transformations are changes of phase-space coordinates that preserve Hamilton’s equations. They are not arbitrary coordinate transformations. They preserve the symplectic structure of phase space. This makes them central to advanced mechanics, perturbation theory, action-angle variables, celestial mechanics, and the transition toward quantum theory.
Poisson brackets also foreshadow quantum mechanics. In canonical quantization, classical Poisson brackets are related to quantum commutators. The structural similarity is not accidental: Hamiltonian mechanics supplies part of the mathematical bridge from classical observables to quantum operators.
Small Oscillations and Normal Modes
Lagrangian mechanics is especially powerful for systems with many coupled degrees of freedom. Near stable equilibrium, a system can often be approximated by quadratic kinetic and potential energy:
T = \frac{1}{2}\sum_{ij} M_{ij}\dot{q}_i\dot{q}_j
\]
\[
V = \frac{1}{2}\sum_{ij} K_{ij}q_iq_j
\]
Interpretation: Near equilibrium, coupled systems can often be represented using quadratic kinetic and potential energy forms.
The equations of motion become:
\mathbf{M}\ddot{\mathbf{q}} + \mathbf{K}\mathbf{q} = \mathbf{0}
\]
Interpretation: Coupled small oscillations reduce to a mass-matrix and stiffness-matrix equation.
Normal modes are solutions in which all coordinates oscillate with a common frequency:
\mathbf{q}(t) = \mathbf{a}\cos(\omega t + \phi)
\]
Interpretation: A normal mode oscillates with a fixed shape and a single angular frequency.
Substitution gives the generalized eigenvalue problem:
(\mathbf{K} – \omega^2\mathbf{M})\mathbf{a} = \mathbf{0}
\]
Interpretation: Normal-mode frequencies and shapes are found through a generalized eigenvalue problem.
This connects analytical mechanics directly to wave physics, molecular vibrations, structural mechanics, coupled oscillators, condensed matter, and quantum systems. The normal-mode method is one of the most powerful examples of how choosing the right variables can simplify complex motion.
Measurement, Units, and SI Interpretation
Lagrangian and Hamiltonian mechanics use familiar mechanical units in a more abstract framework. The Lagrangian \(L=T-V\) has units of energy:
[L] = \mathrm{J}
\]
Interpretation: The Lagrangian has the dimensions of energy.
The action is the time integral of the Lagrangian:
S = \int L\,dt
\]
Interpretation: Action accumulates the Lagrangian over time.
so action has units:
[S] = \mathrm{J\,s} = \mathrm{kg\,m^2\,s^{-1}}
\]
Interpretation: Action has the same dimensional form as angular momentum.
This is the same SI unit dimension as angular momentum. This connection becomes especially important in quantum mechanics, where Planck’s constant has units of action.
Canonical momentum has units that depend on the generalized coordinate. If \(q\) is a length, then \(p\) has units of linear momentum:
\mathrm{kg\,m\,s^{-1}}
\]
Interpretation: A length coordinate has a conjugate momentum with ordinary linear momentum units.
If \(q\) is an angle, the corresponding canonical momentum has units of angular momentum:
\mathrm{kg\,m^2\,s^{-1}}
\]
Interpretation: An angular coordinate has a conjugate momentum with angular momentum units.
The Hamiltonian usually has units of energy:
[H] = \mathrm{J}
\]
Interpretation: The Hamiltonian usually carries energy units, even when it should not be treated simplistically as energy in every case.
Poisson brackets have units determined by the functions being bracketed and the coordinate–momentum pair. Because generalized coordinates may have different dimensions, unit checking is essential in analytical mechanics. The formalism is abstract, but the quantities remain physical.
Mathematical Lens
A mathematics-first treatment of analytical mechanics begins with configuration space. A system’s generalized coordinates define a point in configuration space:
\mathbf{q} = (q_1,\ldots,q_n)
\]
Interpretation: The generalized-coordinate vector identifies a point in configuration space.
The Lagrangian is:
L(q,\dot{q},t)
\]
Interpretation: The Lagrangian depends on generalized coordinates, generalized velocities, and time.
The action functional is:
S[q] = \int_{t_1}^{t_2} L(q,\dot{q},t)\,dt
\]
Interpretation: The action is a functional of the path \(q(t)\).
Stationary action gives:
\delta S = 0
\]
Interpretation: Physical paths are stationary points of the action.
and therefore:
\frac{d}{dt}
\left(
\frac{\partial L}{\partial \dot{q}_i}
\right)
–
\frac{\partial L}{\partial q_i}
= 0
\]
Interpretation: The Euler–Lagrange equations follow from stationary action.
Canonical momentum is:
p_i = \frac{\partial L}{\partial \dot{q}_i}
\]
Interpretation: Canonical momentum is conjugate to each generalized coordinate.
The Hamiltonian is the Legendre transform:
H(q,p,t) = \sum_i p_i\dot{q}_i – L(q,\dot{q},t)
\]
Interpretation: The Legendre transform moves the theory from velocity variables to momentum variables.
Hamilton’s equations are:
\dot{q}_i = \frac{\partial H}{\partial p_i},
\qquad
\dot{p}_i = -\frac{\partial H}{\partial q_i}
\]
Interpretation: Hamiltonian mechanics expresses dynamics as first-order flow in phase space.
The Poisson bracket is:
\{A,B\}
=
\sum_i
\left(
\frac{\partial A}{\partial q_i}
\frac{\partial B}{\partial p_i}
–
\frac{\partial A}{\partial p_i}
\frac{\partial B}{\partial q_i}
\right)
\]
Interpretation: Poisson brackets encode Hamiltonian dynamics and conservation algebraically.
and time evolution is:
\frac{dA}{dt}
=
\{A,H\}
+
\frac{\partial A}{\partial t}
\]
Interpretation: A phase-space function evolves through its Poisson bracket with the Hamiltonian, plus explicit time dependence.
This sequence shows the architecture of analytical mechanics: configuration space leads to action, action leads to Euler–Lagrange equations, Legendre transformation leads to phase space, phase space leads to Hamiltonian flow, and Poisson brackets express dynamics algebraically.
Variables, Units, and Physical Interpretation
Analytical mechanics depends on variables that connect coordinates, velocities, momenta, energy, action, and phase-space structure. The table below summarizes several central quantities.
| Symbol or Term | Meaning | Typical Unit | Physical Interpretation |
|---|---|---|---|
| \(q_i\) | Generalized coordinate | depends on coordinate | Independent variable describing system configuration |
| \(\dot{q}_i\) | Generalized velocity | coordinate unit/s | Rate of change of generalized coordinate |
| \(L\) | Lagrangian | J | Scalar function whose stationary action gives equations of motion |
| \(S\) | Action | J·s | Time integral of the Lagrangian along a path |
| \(p_i\) | Canonical momentum | depends on \(q_i\) | Momentum conjugate to a generalized coordinate |
| \(H\) | Hamiltonian | J | Generator of time evolution in phase space; often total energy |
| \(\{A,B\}\) | Poisson bracket | depends on \(A,B\) | Algebraic operation encoding Hamiltonian flow |
| \(\omega\) | Angular frequency | rad/s | Frequency of oscillatory motion or normal modes |
| \(\mathbf{M}\) | Mass matrix | varies by coordinates | Quadratic kinetic-energy structure for coupled systems |
| \(\mathbf{K}\) | Stiffness matrix | varies by coordinates | Quadratic potential-energy structure near equilibrium |
The table shows why analytical mechanics requires careful interpretation. Generalized coordinates are not always lengths. Generalized momenta are not always ordinary linear momenta. The formalism is powerful precisely because it adapts to the geometry of the system.
Worked Example: Simple Pendulum
Consider a simple pendulum of mass \(m\), length \(\ell\), and angle \(\theta\) measured from the downward vertical. The generalized coordinate is:
q = \theta
\]
Interpretation: The pendulum’s configuration can be described by a single angular coordinate.
The speed of the bob is:
v = \ell\dot{\theta}
\]
Interpretation: Pendulum bob speed is arc radius times angular speed.
so the kinetic energy is:
T = \frac{1}{2}m\ell^2\dot{\theta}^2
\]
Interpretation: Pendulum kinetic energy is expressed in terms of angular velocity.
Choosing zero potential energy at the lowest point, the potential energy is:
V = mg\ell(1-\cos\theta)
\]
Interpretation: Pendulum potential energy increases with angular displacement from the lowest point.
The Lagrangian is:
L = \frac{1}{2}m\ell^2\dot{\theta}^2 – mg\ell(1-\cos\theta)
\]
Interpretation: The pendulum Lagrangian is kinetic energy minus gravitational potential energy.
The Euler–Lagrange equation is:
\frac{d}{dt}
\left(
\frac{\partial L}{\partial \dot{\theta}}
\right)
–
\frac{\partial L}{\partial \theta}
=0
\]
Interpretation: Applying the Euler–Lagrange equation gives the pendulum equation of motion.
Compute the derivatives:
\frac{\partial L}{\partial \dot{\theta}}
=
m\ell^2\dot{\theta}
\]
\[
\frac{d}{dt}
\left(
m\ell^2\dot{\theta}
\right)
=
m\ell^2\ddot{\theta}
\]
\[
\frac{\partial L}{\partial \theta}
=
-mg\ell\sin\theta
\]
Interpretation: These derivatives convert the pendulum Lagrangian into its nonlinear equation of motion.
Therefore:
m\ell^2\ddot{\theta} + mg\ell\sin\theta = 0
\]
Interpretation: The nonlinear pendulum equation follows from the Lagrangian.
or:
\ddot{\theta} + \frac{g}{\ell}\sin\theta = 0
\]
Interpretation: The pendulum acceleration depends nonlinearly on angular displacement.
For small angles, \(\sin\theta \approx \theta\), giving:
\ddot{\theta} + \frac{g}{\ell}\theta = 0
\]
Interpretation: The small-angle approximation turns the pendulum into a harmonic oscillator.
The small-angle angular frequency is:
\omega_0 = \sqrt{\frac{g}{\ell}}
\]
Interpretation: Small-angle pendulum frequency depends on gravitational acceleration and length.
The Hamiltonian form begins with canonical momentum:
p_{\theta} = \frac{\partial L}{\partial \dot{\theta}}
=
m\ell^2\dot{\theta}
\]
Interpretation: The pendulum’s conjugate momentum is angular momentum about the pivot in this idealized model.
The Hamiltonian is:
H(\theta,p_{\theta})
=
\frac{p_{\theta}^2}{2m\ell^2}
+
mg\ell(1-\cos\theta)
\]
Interpretation: The pendulum Hamiltonian expresses total energy in angular phase-space variables.
Hamilton’s equations are:
\dot{\theta}
=
\frac{\partial H}{\partial p_{\theta}}
=
\frac{p_{\theta}}{m\ell^2}
\]
\[
\dot{p}_{\theta}
=
-\frac{\partial H}{\partial \theta}
=
-mg\ell\sin\theta
\]
Interpretation: Hamilton’s equations describe pendulum motion as phase-space flow in \((\theta,p_\theta)\).
This example shows the relationship among Newtonian, Lagrangian, and Hamiltonian forms. The physical motion is the same, but the mathematical representation changes from force and acceleration to action and then to phase-space flow.
Computational Modeling
Computational modeling helps make analytical mechanics operational. Lagrangian equations can be generated symbolically. Hamiltonian systems can be integrated in phase space. Energy drift can be compared across numerical methods. Symplectic integrators can preserve long-term qualitative structure better than ordinary methods in conservative systems. Phase-space trajectories can be plotted and classified. Poisson brackets can be computed for symbolic observables. Normal-mode eigenvalue problems can be solved from mass and stiffness matrices. Metadata can preserve coordinate choices, units, constraints, model assumptions, and numerical methods.
The selected examples below focus on pendulum phase-space diagnostics and Hamiltonian integration because they are foundational and readable. The GitHub repository extends the same logic into richer computational workflows: R phase-space summaries, Python symplectic integration, energy-drift diagnostics, Lagrangian and Hamiltonian pendulum models, normal-mode eigenproblems, Poisson-bracket utilities, Julia Hamiltonian systems, C++ symplectic maps, Fortran oscillator tables, SQL analytical-mechanics metadata, Rust command-line utilities, C examples, documentation, and reproducible sample data.
R Workflow: Pendulum Energy and Phase-Space Summary
R is especially useful for analyzing trajectories, summarizing phase-space data, and comparing energy diagnostics across parameter choices. The following workflow creates a synthetic pendulum phase-space table and computes Hamiltonian energy from angle and canonical momentum.
# Pendulum Energy and Phase-Space Summary
#
# This workflow computes the Hamiltonian for a simple pendulum:
#
# H(theta, p_theta) =
# p_theta^2 / (2 m l^2) + m g l (1 - cos(theta))
#
# where:
# theta = angular coordinate in radians
# p_theta = canonical angular momentum
# m = mass
# l = pendulum length
#
# The workflow summarizes energy across a phase-space grid.
library(tibble)
library(dplyr)
mass_kg <- 1.0
length_m <- 1.0
gravity_m_per_s2 <- 9.80665
phase_space_grid <- tidyr::crossing(
theta_rad = seq(-pi, pi, length.out = 121),
p_theta_kg_m2_per_s = seq(-6, 6, length.out = 121)
) %>%
mutate(
kinetic_energy_j =
p_theta_kg_m2_per_s^2 /
(2 * mass_kg * length_m^2),
potential_energy_j =
mass_kg * gravity_m_per_s2 * length_m *
(1 - cos(theta_rad)),
hamiltonian_j =
kinetic_energy_j + potential_energy_j,
energy_region = case_when(
hamiltonian_j < 2 * mass_kg * gravity_m_per_s2 * length_m ~
"oscillatory",
TRUE ~ "rotational_or_separatrix_region"
)
)
phase_summary <- phase_space_grid %>%
group_by(energy_region) %>%
summarise(
count = n(),
min_energy_j = min(hamiltonian_j),
mean_energy_j = mean(hamiltonian_j),
max_energy_j = max(hamiltonian_j),
.groups = "drop"
)
print(head(phase_space_grid, 12))
print(phase_summary)
This workflow shows the Hamiltonian as a phase-space surface rather than merely a scalar energy value. Regions of phase space correspond to qualitatively different pendulum behavior: oscillation around the stable equilibrium, separatrix-like transition, and full rotation.
Python Workflow: Hamiltonian Integration with Symplectic Euler
Python is especially useful for numerical integration, phase-space diagnostics, and energy-conservation comparisons. The following workflow integrates the Hamiltonian equations for a simple pendulum using a symplectic Euler method.
"""
Hamiltonian Integration with Symplectic Euler
This workflow integrates the simple pendulum Hamiltonian:
H(theta, p) = p^2 / (2 m l^2) + m g l (1 - cos(theta))
Hamilton's equations:
theta_dot = p / (m l^2)
p_dot = -m g l sin(theta)
The symplectic Euler method updates momentum first and then position.
This method is simple but useful because it respects Hamiltonian structure
better than many ordinary explicit schemes over long integrations.
"""
import numpy as np
import pandas as pd
MASS_KG = 1.0
LENGTH_M = 1.0
GRAVITY_M_PER_S2 = 9.80665
TIME_STEP_S = 0.01
N_STEPS = 5000
def hamiltonian(theta_rad: float, p_theta: float) -> float:
"""
Compute pendulum Hamiltonian energy in joules.
"""
kinetic = p_theta**2 / (2.0 * MASS_KG * LENGTH_M**2)
potential = (
MASS_KG * GRAVITY_M_PER_S2 * LENGTH_M *
(1.0 - np.cos(theta_rad))
)
return kinetic + potential
def symplectic_euler_step(theta_rad: float, p_theta: float) -> tuple[float, float]:
"""
Advance one step using symplectic Euler.
Momentum update:
p_{n+1} = p_n - dt * dH/dtheta
Coordinate update:
theta_{n+1} = theta_n + dt * dH/dp evaluated with p_{n+1}
"""
p_next = (
p_theta
- TIME_STEP_S *
MASS_KG *
GRAVITY_M_PER_S2 *
LENGTH_M *
np.sin(theta_rad)
)
theta_next = theta_rad + TIME_STEP_S * (
p_next / (MASS_KG * LENGTH_M**2)
)
# Wrap angle to [-pi, pi] for readable phase-space diagnostics.
theta_next = (theta_next + np.pi) % (2.0 * np.pi) - np.pi
return theta_next, p_next
def main() -> None:
"""
Integrate pendulum motion and summarize energy drift.
"""
theta = 1.0
p_theta = 0.0
rows = []
initial_energy = hamiltonian(theta, p_theta)
for step in range(N_STEPS + 1):
time_s = step * TIME_STEP_S
energy = hamiltonian(theta, p_theta)
rows.append(
{
"step": step,
"time_s": time_s,
"theta_rad": theta,
"p_theta_kg_m2_per_s": p_theta,
"hamiltonian_j": energy,
"energy_error_j": energy - initial_energy,
"relative_energy_error": (energy - initial_energy) / initial_energy,
}
)
theta, p_theta = symplectic_euler_step(theta, p_theta)
trajectory = pd.DataFrame(rows)
summary = pd.DataFrame(
[
{
"initial_energy_j": initial_energy,
"final_energy_j": trajectory["hamiltonian_j"].iloc[-1],
"max_abs_energy_error_j":
trajectory["energy_error_j"].abs().max(),
"max_abs_relative_energy_error":
trajectory["relative_energy_error"].abs().max(),
"final_theta_rad": trajectory["theta_rad"].iloc[-1],
"final_p_theta_kg_m2_per_s":
trajectory["p_theta_kg_m2_per_s"].iloc[-1],
}
]
)
print("Hamiltonian trajectory sample:")
print(trajectory.head(12).round(8).to_string(index=False))
print("\nEnergy diagnostic summary:")
print(summary.round(10).to_string(index=False))
if __name__ == "__main__":
main()
This workflow shows why Hamiltonian structure matters computationally. Numerical methods are not neutral. A method that respects phase-space geometry can preserve the qualitative behavior of conservative systems more faithfully over long time intervals.
GitHub Repository
The article body includes only selected computational examples so the conceptual and mathematical argument remains readable. The full repository contains the expanded computational infrastructure: R phase-space and energy workflows, Python Hamiltonian integration and symplectic diagnostics, Lagrangian pendulum examples, normal-mode eigenproblems, Poisson-bracket utilities, Julia Hamiltonian-system calculations, C++ symplectic maps, Fortran oscillator tables, SQL analytical-mechanics metadata, Rust command-line utilities, C examples, documentation, and reproducible sample data.
Complete Code Repository
The full code distribution for this article, including selected article examples and advanced research-grade computational workflows for Lagrangian equations, Hamiltonian systems, phase-space diagnostics, symplectic integration, action principles, Poisson brackets, normal modes, analytical-mechanics metadata, reproducibility documentation, and performance-oriented scientific computing, is available on GitHub.
From Analytical Mechanics to Modern Physics
Lagrangian and Hamiltonian mechanics are among the most important bridges from classical mechanics to modern physics. The Lagrangian formulation leads naturally to relativistic mechanics, field theory, gauge symmetry, and quantum field theory. The Hamiltonian formulation leads naturally to phase-space dynamics, canonical quantization, statistical mechanics, chaos theory, and symplectic computation.
Within the Physics knowledge series, this article belongs after the core mechanics sequence and before nonlinear dynamics, computational physics, quantum mechanics, field theory, and statistical physics. It shows how force-based mechanics becomes structure-based mechanics: action replaces direct force accounting, generalized coordinates replace fixed coordinate systems, phase space replaces configuration alone, and symmetry becomes the source of conservation.
The next conceptual steps are natural. Nonlinear Dynamics, Chaos, and the Physics of Complex Systems extends Hamiltonian phase-space thinking into sensitive dependence and complex trajectories. Quantum Mechanics and the Limits of Classical Intuition inherits the importance of action, Hamiltonians, operators, and state evolution. Statistical Physics and the Emergence of Macroscopic Order uses phase-space reasoning to connect microscopic dynamics to macroscopic thermodynamic behavior.
Related Articles
- What Is Physics?
- Measurement, Mathematics, and the Structure of Physical Inquiry
- Motion, Force, and the Foundations of Classical Mechanics
- Energy, Work, and Conservation in Physical Systems
- Rotational Dynamics, Torque, and Angular Momentum
- Gravitation, Orbits, and Celestial Mechanics
- Waves, Oscillations, and Resonance
- Symmetry, Law, and the Search for Physical Order
- Quantum Mechanics and the Limits of Classical Intuition
- Statistical Physics and the Emergence of Macroscopic Order
- Systems Modeling
- Calculus for Systems Modeling
Further Reading
- Arnold, V.I. (1989) Mathematical Methods of Classical Mechanics, 2nd edn. New York: Springer. Available at: https://link.springer.com/book/10.1007/978-1-4757-2063-1 (Accessed: 25 April 2026).
- Bureau International des Poids et Mesures (2025) The International System of Units: SI Brochure, 9th edition, version 3.02. Available at: https://www.bipm.org/en/si-brochure-9 (Accessed: 25 April 2026).
- Goldstein, H., Poole, C. and Safko, J. (2001) Classical Mechanics, 3rd edn. San Francisco: Addison Wesley. Publisher page available at: https://www.pearson.com/en-us/subject-catalog/p/classical-mechanics/P200000006815 (Accessed: 25 April 2026).
- Hamilton, W.R. (1834) ‘On a General Method in Dynamics’, Philosophical Transactions of the Royal Society of London, 124, pp. 247–308. Available at: https://royalsocietypublishing.org/doi/10.1098/rstl.1834.0017 (Accessed: 25 April 2026).
- Hamilton, W.R. (1835) ‘Second Essay on a General Method in Dynamics’, Philosophical Transactions of the Royal Society of London, 125, pp. 95–144. Available at: https://royalsocietypublishing.org/doi/10.1098/rstl.1835.0009 (Accessed: 25 April 2026).
- Lagrange, J.L. (1811) Mécanique analytique. Paris: Courcier. Available at: https://archive.org/details/mcaniqueanalyt01lagr (Accessed: 25 April 2026).
- MIT OpenCourseWare (2011) Lecture 15: Introduction to Lagrange With Examples. Available at: https://ocw.mit.edu/courses/2-003sc-engineering-dynamics-fall-2011/resources/lecture-15-introduction-to-lagrange-with-examples/ (Accessed: 25 April 2026).
- MIT OpenCourseWare (2017) Classical Mechanics II. Available at: https://ocw.mit.edu/courses/8-223-classical-mechanics-ii-january-iap-2017/ (Accessed: 25 April 2026).
- MIT OpenCourseWare (2017) Lecture Notes: Classical Mechanics II. Available at: https://ocw.mit.edu/courses/8-223-classical-mechanics-ii-january-iap-2017/pages/lecture-notes/ (Accessed: 25 April 2026).
- MIT OpenCourseWare (2017) Classical Mechanics II, Lecture 15: Introduction to Hamiltonian Mechanics. Available at: https://ocw.mit.edu/courses/8-223-classical-mechanics-ii-january-iap-2017/resources/mit8_223iap17_lec15/ (Accessed: 25 April 2026).
- Noether, E. (1918/2005) Invariant Variation Problems. English translation by M.A. Tavel. Available at: https://arxiv.org/abs/physics/0503066 (Accessed: 25 April 2026).
- National Institute of Standards and Technology (2008) Guide for the Use of the International System of Units (SI), NIST Special Publication 811. Available at: https://physics.nist.gov/cuu/pdf/sp811.pdf (Accessed: 25 April 2026).
References
- Bureau International des Poids et Mesures (2025) The International System of Units: SI Brochure, 9th edition, version 3.02. Available at: https://www.bipm.org/en/si-brochure-9 (Accessed: 25 April 2026).
- Hamilton, W.R. (1834) ‘On a General Method in Dynamics’, Philosophical Transactions of the Royal Society of London, 124, pp. 247–308. Available at: https://royalsocietypublishing.org/doi/10.1098/rstl.1834.0017 (Accessed: 25 April 2026).
- Hamilton, W.R. (1835) ‘Second Essay on a General Method in Dynamics’, Philosophical Transactions of the Royal Society of London, 125, pp. 95–144. Available at: https://royalsocietypublishing.org/doi/10.1098/rstl.1835.0009 (Accessed: 25 April 2026).
- Lagrange, J.L. (1811) Mécanique analytique. Paris: Courcier. Available at: https://archive.org/details/mcaniqueanalyt01lagr (Accessed: 25 April 2026).
- MIT OpenCourseWare (2011) Lecture 15: Introduction to Lagrange With Examples. Available at: https://ocw.mit.edu/courses/2-003sc-engineering-dynamics-fall-2011/resources/lecture-15-introduction-to-lagrange-with-examples/ (Accessed: 25 April 2026).
- MIT OpenCourseWare (2017) Classical Mechanics II. Available at: https://ocw.mit.edu/courses/8-223-classical-mechanics-ii-january-iap-2017/ (Accessed: 25 April 2026).
- MIT OpenCourseWare (2017) Lecture Notes: Classical Mechanics II. Available at: https://ocw.mit.edu/courses/8-223-classical-mechanics-ii-january-iap-2017/pages/lecture-notes/ (Accessed: 25 April 2026).
- MIT OpenCourseWare (2017) Classical Mechanics II, Lecture 15: Introduction to Hamiltonian Mechanics. Available at: https://ocw.mit.edu/courses/8-223-classical-mechanics-ii-january-iap-2017/resources/mit8_223iap17_lec15/ (Accessed: 25 April 2026).
- Noether, E. (1918/2005) Invariant Variation Problems. English translation by M.A. Tavel. Available at: https://arxiv.org/abs/physics/0503066 (Accessed: 25 April 2026).
- National Institute of Standards and Technology (2008) Guide for the Use of the International System of Units (SI), NIST Special Publication 811. Available at: https://physics.nist.gov/cuu/pdf/sp811.pdf (Accessed: 25 April 2026).
