# Hamiltonian formalism The Hamiltonian formalism of mechanics is based on the definitions posed by [Lagrangian mechanics](/en/physics/mechanics/lagrangian-mechanics/lagrangian-formalism) and the axioms, postulates and principles posed in the [Newtonian formalism](/en/physics/mechanics/newtonian-mechanics/newtonian-formalism/). Where the Lagrangian formalism used the [principle of virtual work](/en/physics/mechanics/lagrangian-mechanics/lagrange-equations/#principle-of-virtual-work) to derive the Lagrangian equations of motion, the Hamiltonian formalism will derive the Lagrangian equations with the stationary action principle. A derivative of Fermat's principle of least time. In Hamilton's formulation the principle is referred to as Hamilton's principle. ## Hamilton's principle > *Principle 1*: of all the kinematically possible motions that take a mechanical system from one given configuration to another within a time interval $T \subset \mathbb{R}$, the actual motion is the stationary point of the time integral of the Lagrangian $\mathcal{L}$ of the system. Let $S$ be the functional of the trajectories of the system, then > > $$ > S = \int_T \mathcal{L} dt, > $$ > > has stationary points. The functional $S$ is often referred to as the action of the system. With this principle the equations of Lagrange can be derived. > *Theorem 1*: let $\mathcal{L}: (\mathbf{q}, \mathbf{q'}) \mapsto \mathcal{L}(\mathbf{q}, \mathbf{q'})$ be the Lagrangian, the equations of Lagrange are given by > > $$ > \partial_{q_j} \mathcal{L}(\mathbf{q}, \mathbf{q'}) - d_t \Big(\partial_{q_j'} \mathcal{L}(\mathbf{q}, \mathbf{q'}) \Big) = 0, > $$ > > for all $t \in \mathbb{R}$. ??? note "*Proof*:" Let the redefined generalized coordinates $\mathbf{q}: (t,a) \mapsto \mathbf{q}(t,a)$ be given by $$ \mathbf{q}(t,a) = \mathbf{\hat q}(t) + a \varepsilon(t), $$ with $\mathbf{\hat q}: t \mapsto \mathbf{\hat q}(t)$ the generalized coordinates of the system and $\varepsilon: t \mapsto \varepsilon(t)$ a smooth differentiable function. Let $S: a \mapsto S(a)$ be the action of the system and let $\mathcal{L}: (\mathbf{q}, \mathbf{q'}) \mapsto \mathcal{L}(\mathbf{q}, \mathbf{q'})$ be the Lagrangian of the system, according to Hamilton's principle $$ S(a) = \int_T \mathcal{L}(\mathbf{q}, \mathbf{q'})dt, $$ for all $a \in \mathbb{R}$. To determine the stationary points we must have that $S'(0) = 0$. We have that $S'$ is given by $$ \begin{align*} S'(a) &= \int_T \partial_a \mathcal{L}(\mathbf{q}, \mathbf{q'})dt, \\ &= \int_T \sum_{j=1}^f \bigg(\partial_{q_j} \mathcal{L} \partial_a q_j + \partial_{q_j'} \mathcal{L} \partial_a q_j'\bigg)dt, \\ &= \int_T \sum_{j=1}^f \bigg(\partial_{q_j} \mathcal{L} \varepsilon_j(t) + \partial_{q_j'} \mathcal{L} \partial_a \partial_t q_j\bigg)dt. \\ \end{align*} $$ Partial integration may be used for the second part: $$ \begin{align*} \int_T \partial_{q_j'} \mathcal{L} \partial_a \partial_t q_j dt &= \Big[\partial_{q_j'} \mathcal{L} \partial_a q_j \Big]_T - \int_T \partial_a q_j d_t (\partial_{q_j'} \mathcal{L})dt, \\ &= \Big[\partial_{q_j'} \mathcal{L} \varepsilon_j(t) \Big]_T - \int_T \partial_a q_j d_t (\partial_{q_j'} \mathcal{L})dt. \end{align*} $$ Choose $\varepsilon_j$ such that $$ \Big[\partial_{q_j'} \mathcal{L} \varepsilon_j(t) \Big]_T = 0. $$ Obtains $$ \int_T \partial_{q_j'} \mathcal{L} \partial_a \partial_t q_j dt = - \int_T \partial_a q_j d_t (\partial_{q_j'} \mathcal{L})dt. $$ The general expression of $S'$ may now be given by $$ \begin{align*} S'(a) &= \int_T \sum_{j=1}^f \bigg(\partial_{q_j} \mathcal{L} \varepsilon_j(t) - \partial_a q_j d_t (\partial_{q_j'} \mathcal{L})\bigg)dt, \\ &= \int_T \sum_{j=1}^f \bigg(\partial_{q_j} \mathcal{L} \varepsilon_j(t) - \varepsilon_j(t) d_t (\partial_{q_j'} \mathcal{L})\bigg)dt, \\ &= \sum_{j=1}^f \int_T \varepsilon_j(t) \Big(\partial_{q_j} \mathcal{L} - d_t (\partial_{q_j'} \mathcal{L})\Big)dt. \end{align*} $$ Then $$ S'(0) = \sum_{j=1}^f \int_T \varepsilon_j(t) \Big(\partial_{q_j} \mathcal{L} - d_t (\partial_{q_j'} \mathcal{L})\Big)dt = 0, $$ since $\varepsilon_j$ can be chosen arbitrary this implies that $$ \partial_{q_j} \mathcal{L} - d_t (\partial_{q_j'} \mathcal{L}) = 0. $$