In the Lagrangian formalism the equations of motion are given by
initial values are required for a full solution, with an \(n\)-dimensional configuration space. The Hamiltonian approach is to recast the equations of motion as first-order equations, with a configuration space of \(2n\) independent variables, describing the position of a point is spacetime, and the conjugate momenta. Now \((p, q)\) are the canonical variables.
In order to switch from the parameters of the Lagrangian formalism, \((q, \dot{q}, t)\) to those of the Hamiltonian, \((q, p, t)\) we introduce a transformation.
Consider a function of the form
We want to change from using \(x\) and \(y\) in the description to using \(u\) and \(y\), so let
\(y\):
[Legendre transforms in thermodynamics] Consider the first law of thermodynamics,
For a gas undergoing a reversible process this can be re-expressed as
the pressure are given
The Hamiltonian function is generated from the Lagrangian using a Legendre transform, starting with the differential of \(L\),
with differential
Thus we have \(2n +1\) relations,
with equations ([eq:89] – [eq:90]) the canonical equations of Hamilton, which are the \(2n\) first-order equations which replace the \(n\) second-order Lagrange equations.
If the forces involved in the Lagrangian are the result of a conservative potential, and if the equations with generalised coordinates don’t depend explicitly on time then the Hamiltonian is equal to the total energy.
From the definition of \(H\) in equation ([eq:85]), and in the manner of equation ([eq:94]),
depend on time, \(L_2 \dot{q}_k \dot{q}_m = T\), and if the forces can be derived from a conservative potential, \(L_0 = -V\), and thus
The procedure for constructing the Hamiltonian is
Construct \(L\) in a given set of \(q_i\),
Define the \(p_i\)
Form the Hamiltonian using equation ([eq:85])
Invert the conjugate momenta to gain the \(\dot{q}_i\)s
These are used to eliminate all \(\dot{q}_i\) from \(H\)