# Hamilton’s form

### From Lagrange to Hamiltonian

We can use the Legendre transformation to go from Lagrange's to Hamilton's form, even though the Lagrangian is a function of two variables, $L = L(q_i, \dot{q_i})$. The coordinate variable is just carried along.

Write $\dot{q_i} = v_i$ so that, \begin{align*}L &= L(q_i, v_i)\\\frac{\partial L}{\partial v_i} &= p_i\\H &= \sum_{i} p_i v_i - L\end{align*}

Now we can calculate the small changes in $H$ with respect to small changes in the $p, q$'s. Then, \begin{align*}\delta H &= p_i \delta v_i + v_i \delta p_i - \frac{\partial L}{\partial q_i}\delta q_i - \frac{\partial L}{\partial v_i}\delta v_i\\&= v_i \delta p_i - \frac{\partial L}{\partial q_i}\delta q_i + \left( p_i - \frac{\partial L}{\partial v_i} \right) \delta v_i\\&= v_i \delta p_i - \frac{\partial L}{\partial q_i}\delta q_i\end{align*}

So, the partial derivatives of $H$ are then \begin{align*}\frac{\partial H}{\partial q_i} &= - \frac{\partial L}{\partial q_i}\\\frac{\partial H}{\partial p_i} &= v_i\end{align*}

We have $v_i = \dot{q_i}$, and recall from Lagrange's equations, $$\dot{p_i} = \frac{\mathrm{d} }{\mathrm{d} t} \left( \frac{\partial L}{\partial v_i} \right) = \frac{\partial L}{\partial q_i}$$ so finally, we get the 1st order equations, \begin{align*}\frac{\partial H}{\partial q_i} &= - \dot{p_i}\\\frac{\partial H}{\partial p_i} &= \dot{q_i}\end{align*}

### Hamilton's equation

Figure 6.3 - Phase space velocity

Hamilton's form, then, is summarised by the single equation, $$H = H(q_i, p_i)$$ which describes how all trajectories of a system flow through phase space. The derivatives of $H$ are velocities in that phase space, \begin{align*}\frac{\partial H}{\partial q_i} &= - \dot{p_i}\\\frac{\partial H}{\partial p_i} &= \dot{q_i}\end{align*} which we could write as a phase space velocity vector, \begin{align*}\nabla H &= \left( \frac{\partial H}{\partial q_i}, \frac{\partial H}{\partial p_i}\right)\\&= \left( \frac{\partial H}{\partial q_1}, \dots, \frac{\partial H}{\partial q_N}, \frac{\partial H}{\partial p_1}, \dots, \frac{\partial H}{\partial p_N} \right)\end{align*}

As we have seen before, for a given trajectory, energy is conserved, \begin{align*}\frac{\mathrm{d} H}{\mathrm{d} t} &= \frac{\partial H}{\partial q_i} \dot{q_i} + \frac{\partial H}{\partial p_i} \dot{p_i}\\&= \frac{\partial H}{\partial q_i} \left( \frac{\partial H}{\partial p_i} \right) + \frac{\partial H}{\partial p_i} \left( -\frac{\partial H}{\partial q_i} \right)\\&= 0\end{align*} hence the path of a phase point is a surface of constant energy, $H = H(q_i, p_i)$. Because of the incompressibility of phase space, maintaining a constant density of phase points in a given region means that the speed of the flow will necessarily vary across regions - slow where the density is low and fast where the density is high.