Independence of coordinates in the Hamiltonian formulation

I was told the following statement

It is often true that the Lagrangian method leads more readily to the EoMs than does the Hamiltonian method. But because we have greater freedom in choosing the variable in the Hamiltonian formulation of a problem (the $q$ and the $p$ are independent, whereas the $q$ and the derivative of $q$ are not).

My question is the $p$ is dependent on the derivative of $q$ and the derivative of $q$ is depend on $q$, then why do we say that the $q$ and the $p$ are independent and we have greater freedom in choosing the variable in the Hamiltonian formulation of a problem?

Coordinates $q$ and momenta $p$ are independent variables in Hamiltonian formalism. Dependence of $p$ on $\dot{q}$ appears after solving the Hamiltonian equations of motion

\begin{equation} \dot{q}^i=\frac{\partial H}{\partial p_i}. \end{equation}

Doubling of independent variables in comparison with Lagrangian formulation is compensated by doubling of equations of motion.

We have greater freedom in choosing the variables because in Hamiltonian formalism we can perform change of variables of the form

\begin{equation} q \rightarrow q^{\prime} (q,p), \quad p \rightarrow p^{\prime}(q,p), \end{equation}

if such a transformation preserves the canonical 1-form

\begin{equation} \sum\limits_i p_i \mathrm{d}q^i, \end{equation}

while in Lagrangian formalism only $q \rightarrow q^{\prime} (q)$ transformations are allowed.

• Comment to the answer (v1): Note that it is the symplectic 2-form rather than the canonical 1-form that is preserved under symplectomorphisms. – Qmechanic Dec 31 '16 at 16:04

Indeed, in one very specific sense we don't have more freedom one way versus the other. So the basic rule of modeling a dynamical system says, "any Lagrangian or Hamiltonian or force law is allowed, as long as we recover the same equations of motion each way." And that freedom is the same for both the Lagrangian and Hamiltonian approaches.

But the Lagrangian path is really straightforward, it says "choose some generalized coordinates that embody your constraints," for example if you're dealing with a gyroscope you probably want its axial tilt in spherical coordinates $\theta,\phi$ but also you need to express its spin about that axis as some angle $\lambda.$ Then it says "express the normal Newtonian kinetic energy $K$ and potential energy $U$ in terms of those generalized coordinates and their time derivatives; just divide the object up into particles and express $v_i$ in your coordinates and write down e.g. $K = \frac12 \sum_i m_i v_i^2$. Then a no-nonsense Lagrangian is $L = K - U.$"

When you're done with this you've got a Lagrangian and Then the equations of motion for a generalized coordinate $q$ are,$$\frac{\partial L}{\partial q} = \frac{d}{dt}\frac{\partial L}{\partial \dot q}.$$ In the most simple cases we can see that the left-hand-side is basically a net force and the right hand side is basically $dp/dt$, for example the 1D harmonic oscillator has $L = \frac12 m \dot x^2 - \frac12 k x^2$ and we see that the left hand side is $kx$ while the right hand side is $\frac{d}{dt} m \dot x.$

So we define the canonical momentum conjugate to $q$ as $\partial L/\partial \dot q,$ and this simple approach has defined our generalized momentum without us having much say in it. In that respect the choice of momentum is "forced" in the Lagrangian picture, whereas it is not forced in the Hamiltonian picture.

Now there is a recipe for taking a Lagrangian theory and preparing it into a Hamiltonian theory, though I'm not sure there is a reverse! It is a somewhat complicated recipe. You have an expression for these variables $q_i$ and their momenta $p_i = \frac{\partial L}{\partial \dot q_i},$ so in general $p_i = p_i(q_i, \dot q_i).$ What you're looking for is a sort of one-sided inverse of this function, let's call it $v_i(q, p),$ such that $p_i(q, v_i(q,p)) = p.$

With these sorts of complicated expressions I like to remember that in the mathematically pure realm we have partial derivatives of functions with respect to their first or second arguments, not with respect to other symbols. Say $f^{[i]}(x_1, x_2, \dots, x_n) = \partial f/\partial x_i$ for short. Then total derivatives of the above expression with respect to $q$ and $p$ say $p_i^{} + p_1^{} v_i^{} = 0$ and $p_i^{} v_i^{} = 1,$ where the arguments to the functions are the obvious ones (each $p_i$ derivative gets $q$ and $v_i$, each $v_i$ derivative gets $q$ and $p$).

So then the claim is that the canonical Hamiltonian is:$$H = - L\big(q_1, v_1(q_1, p_1), q_2, v_2(q_2, p_2), \dots\big) + \sum_i v_i(q_i, p_i) ~p_i.$$I've written this out for a lot of variables but I hope you can see that it is just repeating the same process for each one individually, so we can just focus on one variable at a time, so I will drop the subscripts $i$ but keep the notation $v(q, p)$ for $v_i(q_i, p_i).$ The equations of motions come from: $$\left(\frac{\partial H}{\partial q}\right)_{p} = -\frac{\partial L}{\partial q} - \frac{\partial L}{\partial \dot q} ~ \frac{\partial v}{\partial q} + \frac{\partial v}{\partial q}~p = -\frac{\partial L}{\partial q} = -\frac{dp}{dt},$$ with that last step coming from the Euler-Lagrange equations. Meanwhile, $$\left(\frac{\partial H}{\partial p}\right)_{q} = - \frac{\partial L}{\partial \dot q} ~ \frac{\partial v}{\partial p} + \frac{\partial v}{\partial p}~p + v = v = \frac{dq}{dt},$$with that last step essentially being a sort of fundamental postulate of Hamiltonian mechanics (that this function $v_i(q_i, p_i)$ we derived should be identified with $dq_i/dt$ since it takes the role of $\dot q_i$ from the Lagrangian theory).

So the Lagrangian picture picks out a very special "canonical momentum" which you must use to derive the right Hamiltonian picture, but there is no general requirement that the Hamiltonian picture has that momentum precisely. Any momentum and position coordinates which generate the same evolution equations is the same. You technically had this freedom in the Lagrangian picture but it was so easy to choose your Lagrangian as $K - U$ and simply know that it was correct, that you didn't think twice about it.