# Changing variables from $\dot{q}$ to $p$ in Lagrangian instead of Legendre Transformation

This question is motivated by a perceived incompleteness in the responses to this question, which asks why we can't just substitute $$\dot{q}(p)$$ into $$L(q,\dot{q})$$ to convert it to $$L(q,p)$$, which seems simpler than the method of using the Legendre Transform to generate the Hamiltonian. Some of the answers correctly stated that this procedure would not result in the Hamiltonian, but instead would just result in a new Lagrangian. But I didn't find an adequate explanation for why such a Hamiltonian would be preferred over such a Lagrangian, since in both cases we would be able to produce $$2n$$ 1st-order ODEs in $$q$$ and $$p$$, which is the primary motivation given in most Classical Mechanics textbooks.

My own guess at the answer is that if we make such a substitution, Lagrange's equations (in the new variables $$q$$ and $$p$$) are no longer valid, since in the term $$\frac{\partial L}{\partial q}$$ it is $$\dot{q}$$ that is held constant, not $$p$$. Therefore if we are going to change variables from $$\dot{q}$$ to $$p$$, we have to do more than merely replace $$\dot{q}$$ with $$p$$, we have to find an analog of Lagrange's equations. And so therefore we need to use the Legendre Transform.

Is this reasoning correct? I find I get particularly confused keeping track of what a given partial derivative means when changing variables, and in the aforementioned answers to this related question, no one mentioned this as an issue.

• Possible duplicate: physics.stackexchange.com/q/566046/2451 Commented Mar 30 at 5:02
• Also, note that substituting $\dot q\to p$ is inconsistent in terms of dimensional analysis. Commented Mar 30 at 10:38

Obviously, you can write the Lagrangian $$L(t,q,\dot{q})$$ as a function of $$t,q,p$$ instead of $$t,q,\dot{q}$$, by just inverting the relation $$p= \frac{\partial L(t,q,\dot{q})}{\partial \dot{q}}.$$
However the fundamental issue concerns what the equation is which determines the motion in terms of the variables $$q,p$$.
Here a motion is any curve $$t\mapsto (q(t), p(t,q(t),\dot{q}(t)))$$ where $$t\mapsto (q(t), \dot{q}(t))$$ is a solution of the standard Euler-Lagrange equations.
Here the Hamiltonian function enters the play. The answer selects the Hamiltonian function. The motion equations,i.e. Hamilton equations, are written in terms of $$-L(t,q, \dot{q}(t,q,p))+ p \dot{q}(t,q,p)=:H(t,q,p)$$ and not $$L(t,q, \dot{q}(t,q,p))$$.