Hamiltonian mechanics
Deriving Hamilton's equations

Hamilton's equations can be derived by a calculation with the Lagrangian L {\displaystyle {\mathcal {L}}}, generalized positions q, and generalized velocities, where i = 1, …, n {\displaystyle i=1,\ldots,n}. Here we work off-shell, meaning q i {\displaystyle q^{i}}, q ˙ i {\displaystyle {\dot {q}}^{i}}, t {\displaystyle t} are independent coordinates in phase space, not constrained to follow any equations of motion (in particular, q ˙ i {\displaystyle {\dot {q}}^{i}} is not a derivative of q i {\displaystyle q^{i}}). The total differential of the Lagrangian is: d L = ∑ i (∂ L ∂ q i d q i + ∂ L ∂ q ˙ i d q ˙ i) + ∂ L ∂ t d t. {\displaystyle \mathrm {d} {\mathcal {L}}=\sum _{i}\left({\frac {\partial {\mathcal {L}}}{\partial q^{i}}}\mathrm {d} q^{i}+{\frac {\partial {\mathcal {L}}}{\partial {\dot {q}}^{i}}}\,\mathrm {d} {\dot {q}}^{i}\right)+{\frac {\partial {\mathcal {L}}}{\partial t}}\,\mathrm {d} t\.} The generalized momentum coordinates were defined as p i = ∂ L / ∂ q ˙ i {\displaystyle p_{i}=\partial {\mathcal {L}}/\partial {\dot {q}}^{i}}, so we may rewrite the equation as: d L = ∑ i (∂ L ∂ q i d q i + p i d q ˙ i) + ∂ L ∂ t d t = ∑ i (∂ L ∂ q i d q i + d (p i q ˙ i) − q ˙ i d p i) + ∂ L ∂ t d t. {\displaystyle {\begin{aligned}\mathrm {d} {\mathcal {L}}=&\sum _{i}\left({\frac {\partial {\mathcal {L}}}{\partial q^{i}}}\,\mathrm {d} q^{i}+p_{i}\mathrm {d} {\dot {q}}^{i}\right)+{\frac {\partial {\mathcal {L}}}{\partial t}}\mathrm {d} t\\=&\sum _{i}\left({\frac {\partial {\mathcal {L}}}{\partial q^{i}}}\,\mathrm {d} q^{i}+\mathrm {d} (p_{i}{\dot {q}}^{i})-{\dot {q}}^{i}\,\mathrm {d} p_{i}\right)+{\frac {\partial {\mathcal {L}}}{\partial t}}\,\mathrm {d} t\,.\end{aligned}}}

After rearranging, one obtains: d (∑ i p i q ˙ i − L) = ∑ i (− ∂ L ∂ q i d q i + q ˙ i d p i) − ∂ L ∂ t d t. {\displaystyle \mathrm {d} \!\left(\sum _{i}p_{i}{\dot {q}}^{i}-{\mathcal {L}}\right)=\sum _{i}\left(-{\frac {\partial {\mathcal {L}}}{\partial q^{i}}}\,\mathrm {d} q^{i}+{\dot {q}}^{i}\mathrm {d} p_{i}\right)-{\frac {\partial {\mathcal {L}}}{\partial t}}\,\mathrm {d} t\.}

The term in parentheses on the left-hand side is just the Hamiltonian H = ∑ p i q ˙ i − L {\textstyle {\mathcal {H}}=\sum p_{i}{\dot {q}}^{i}-{\mathcal {L}}} defined previously, therefore: d H = ∑ i (− ∂ L ∂ q i d q i + q ˙ i d p i) − ∂ L ∂ t d t. {\displaystyle \mathrm {d} {\mathcal {H}}=\sum _{i}\left(-{\frac {\partial {\mathcal {L}}}{\partial q^{i}}}\,\mathrm {d} q^{i}+{\dot {q}}^{i}\,\mathrm {d} p_{i}\right)-{\frac {\partial {\mathcal {L}}}{\partial t}}\,\mathrm {d} t\.}

One may also calculate the total differential of the Hamiltonian H {\displaystyle {\mathcal {H}}} with respect to coordinates q i {\displaystyle q^{i}}, p i {\displaystyle p_{i}}, t {\displaystyle t} instead of q i {\displaystyle q^{i}}, q ˙ i {\displaystyle {\dot {q}}^{i}}, t {\displaystyle t}, yielding: d H = ∑ i (∂ H ∂ q i d q i + ∂ H ∂ p i d p i) + ∂ H ∂ t d t. {\displaystyle \mathrm {d} {\mathcal {H}}=\sum _{i}\left({\frac {\partial {\mathcal {H}}}{\partial q^{i}}}\mathrm {d} q^{i}+{\frac {\partial {\mathcal {H}}}{\partial p_{i}}}\mathrm {d} p_{i}\right)+{\frac {\partial {\mathcal {H}}}{\partial t}}\,\mathrm {d} t\.}

One may now equate these two expressions for d H {\displaystyle d{\mathcal {H}}}, one in terms of L {\displaystyle {\mathcal {L}}}, the other in terms of H {\displaystyle {\mathcal {H}}}: ∑ i (− ∂ L ∂ q i d q i + q ˙ i d p i) − ∂ L ∂ t d t = ∑ i (∂ H ∂ q i d q i + ∂ H ∂ p i d p i) + ∂ H ∂ t d t. {\displaystyle \sum _{i}\left(-{\frac {\partial {\mathcal {L}}}{\partial q^{i}}}\mathrm {d} q^{i}+{\dot {q}}^{i}\mathrm {d} p_{i}\right)-{\frac {\partial {\mathcal {L}}}{\partial t}}\,\mathrm {d} t\ =\ \sum _{i}\left({\frac {\partial {\mathcal {H}}}{\partial q^{i}}}\mathrm {d} q^{i}+{\frac {\partial {\mathcal {H}}}{\partial p_{i}}}\mathrm {d} p_{i}\right)+{\frac {\partial {\mathcal {H}}}{\partial t}}\,\mathrm {d} t\.}

Since these calculations are off-shell, one can equate the respective coefficients of d q i {\displaystyle \mathrm {d} q^{i}}, d p i {\displaystyle \mathrm {d} p_{i}}, d t {\displaystyle \mathrm {d} t} on the two sides: ∂ H ∂ q i = − ∂ L ∂ q i, ∂ H ∂ p i = q ˙ i, ∂ H ∂ t = − ∂ L ∂ t. {\displaystyle {\frac {\partial {\mathcal {H}}}{\partial q^{i}}}=-{\frac {\partial {\mathcal {L}}}{\partial q^{i}}}\quad,\quad {\frac {\partial {\mathcal {H}}}{\partial p_{i}}}={\dot {q}}^{i}\quad,\quad {\frac {\partial {\mathcal {H}}}{\partial t}}=-{\partial {\mathcal {L}} \over \partial t}\.}

On-shell, one substitutes parametric functions q i = q i (t) {\displaystyle q^{i}=q^{i}(t)} which define a trajectory in phase space with velocities q ˙ i = d d t q i (t) {\displaystyle {\dot {q}}^{i}={\tfrac {d}{dt}}q^{i}(t)}, obeying Lagrange's equations: d d t ∂ L ∂ q ˙ i − ∂ L ∂ q i = 0. {\displaystyle {\frac {\mathrm {d} }{\mathrm {d} t}}{\frac {\partial {\mathcal {L}}}{\partial {\dot {q}}^{i}}}-{\frac {\partial {\mathcal {L}}}{\partial q^{i}}}=0\.}

Rearranging and writing in terms of the on-shell p i = p i (t) {\displaystyle p_{i}=p_{i}(t)} gives: ∂ L ∂ q i = p ˙ i. {\displaystyle {\frac {\partial {\mathcal {L}}}{\partial q^{i}}}={\dot {p}}_{i}\.}

Thus Lagrange's equations are equivalent to Hamilton's equations: ∂ H ∂ q i = − p ˙ i, ∂ H ∂ p i = q ˙ i, ∂ H ∂ t = − ∂ L ∂ t. {\displaystyle {\frac {\partial {\mathcal {H}}}{\partial q^{i}}}=-{\dot {p}}_{i}\quad,\quad {\frac {\partial {\mathcal {H}}}{\partial p_{i}}}={\dot {q}}^{i}\quad,\quad {\frac {\partial {\mathcal {H}}}{\partial t}}=-{\frac {\partial {\mathcal {L}}}{\partial t}}\,.}

In the case of time-independent H {\displaystyle {\mathcal {H}}} and L {\displaystyle {\mathcal {L}}}, i.e. ∂ H / ∂ t = − ∂ L / ∂ t = 0 {\displaystyle \partial {\mathcal {H}}/\partial t=-\partial {\mathcal {L}}/\partial t=0}, Hamilton's equations consist of 2 n first-order differential equations, while Lagrange's equations consist of n second-order equations. Hamilton's equations usually do not reduce the difficulty of finding explicit solutions, but important theoretical results can be derived from them, because coordinates and momenta are independent variables with nearly symmetric roles.

Hamilton's equations have another advantage over Lagrange's equations: if a system has a symmetry, so that some coordinate q i {\displaystyle q_{i}} does not occur in the Hamiltonian (i.e. a cyclic coordinate), the corresponding momentum coordinate p i {\displaystyle p_{i}} is conserved along each trajectory, and that coordinate can be reduced to a constant in the other equations of the set. This effectively reduces the problem from n coordinates to (n − 1) coordinates: this is the basis of symplectic reduction in geometry. In the Lagrangian framework, the conservation of momentum also follows immediately, however all the generalized velocities q ˙ i {\displaystyle {\dot {q}}_{i}} still occur in the Lagrangian, and a system of equations in n coordinates still has to be solved.

The Lagrangian and Hamiltonian approaches provide the groundwork for deeper results in classical mechanics, and suggest analogous formulations in quantum mechanics: the path integral formulation and the Schrödinger equation.
language:response_language[Spanish], change_case:english_lowercase