With d’Alembert’s principle we leave the realm of statics and enter the realm of dynamics.”
To discuss about Hamiltonian mechanics, one should first introduce Legendre transformation. The derivation in this section is heavily based on Lanczos [2]. Consider a convex function \(\mathbf{f}(\cdot):\mathbb{R}^{n}\rightarrow \mathbb{R}\) with \(n\) variables, \(\mathbf{f}(x_1, x_2, \cdots, x_n)\). We define a new set of variables, \(y_1, y_2, \cdots, y_n\) as follows: \[ y_1 \equiv \frac{\partial \mathbf{f}}{\partial x_1}, ~~ y_2 \equiv \frac{\partial \mathbf{f}}{\partial x_2}, ~~ \cdots, ~~ y_n \equiv \frac{\partial \mathbf{f}}{\partial x_n} \] We now define a new function \(\mathbf{g}(\cdot):\mathbb{R}^{n}\rightarrow \mathbb{R}\) with \(n\) variables, \(\mathbf{g}(y_1, y_2, \cdots, y_n)\): \[ \mathbf{g}(y_1, y_2, \cdots, y_n) = \sum_{i=1}^{n} x_iy_i - \mathbf{f}(x_1, x_2, \cdots, x_n) \tag{1} \] Note that \(x_1, x_2, \cdots, x_n\) are expressed with respect to \(y_1, y_2, \cdots, y_n\), which is possible due to the convexity of \(\mathbf{f}(\cdot)\).
Since \(\mathbf{g}(\cdot)\) is a function of \(y_1, y_2, \cdots, y_n\), a small deviation of \(\mathbf{g}\) results in (Eq. 1): \[ \delta \mathbf{g} = \sum_{i=1}^{n}y_i \delta x_i + \sum_{i=1}^{n}x_i \delta y_i - \sum_{i=1}^{n}\frac{\partial \mathbf{f}}{\partial x_i}\delta x_i = \sum_{i=1}^{n}x_i \delta y_i + \underbrace{\sum_{i=1}^{n}\Big( y_i - \frac{\partial \mathbf{f}}{\partial x_i} \Big)}_{=0}\delta x_i = \sum_{i=1}^{n}x_i \delta y_i \] From this result, we show that: \[ x_1 \equiv \frac{\partial \mathbf{g}}{\partial y_1}, ~~ x_2 \equiv \frac{\partial \mathbf{g}}{\partial y_2}, \cdots, ~~ x_n \equiv \frac{\partial \mathbf{g}}{\partial y_n} \] Summarizing, there is a strong symmetry between the two functions:
The physical meaning of this transformation is discussed by Prof. Balakrishnan, where he mentioned that Legendre transformation is describing a function with it’s velocity, not position.
From the Legendre transformation, we now define the Hamiltonian \(\mathcal{H}(\mathbf{q},\mathbf{p},t)\) of
the system, which is the Legendre transformation of the Lagrangian \(\mathcal{L}(\mathbf{q},\mathbf{\dot{q}},t)\).
The dual variable of \(\mathbf{\dot{q}}=(\dot{q}_1,\dot{q}_2,\cdots,\dot{q}_n)\)
is defined by the momentum \(\mathbf{p}=(p_1,
p_2, \cdots, p_n)\), where: \[
\mathbf{p} \equiv \frac{\partial
\mathcal{L}(\mathbf{q},\mathbf{\dot{q}},t)}{\partial \mathbf{q}}, ~~~~~
\mathcal{H}(\mathbf{q},\mathbf{p},t) = \sum_{i=1}^{n}p_i\dot{q}_i -
\mathcal{L}(\mathbf{q},\mathbf{\dot{q}},t)
\] We can further derive that for \(i=1,2,\cdots, n\). \[
\frac{\partial L(\mathbf{q},\mathbf{\dot{q}},t)}{\partial q_i} =
-\frac{\partial H(\mathbf{q},\mathbf{p},t)}{\partial q_i} ~~~~~~~~~
\frac{\partial L(\mathbf{q},\mathbf{\dot{q}},t)}{\partial t} =
-\frac{\partial H(\mathbf{q},\mathbf{p},t)}{\partial t}
\] Considering the Euler-Lagrange equation: \[
\frac{d}{dt}\Big( \frac{\partial
L(\mathbf{q},\mathbf{\dot{q}},t)}{\partial \dot{q}_i} \Big) -
\frac{\partial L(\mathbf{q},\mathbf{\dot{q}},t)}{\partial q_i} = Q_i ~~~
i=1,2,\cdots, n
\] It is quick to check that we have \(2n+1\) equations: \[
\begin{align}
q_i &= \phantom{-} \frac{\partial
H(\mathbf{q},\mathbf{p},t)}{\partial p_i} \\
p_i &= -\frac{\partial H(\mathbf{q},\mathbf{p},t)}{\partial q_i}
+Q_i\\
\end{align}
\]