# Hamiltonian mechanics - the independence of p and q

• QuasarBoy543298

#### QuasarBoy543298

in the Lagrangian mechanics, we assumed that the Lagrangian is a function of space coordinates, time and the derivative of those space coordinates by time (velocity) L(q,dq/dt,t).

to derive the Hamiltonian we used the Legendre transformation on L with respect to dq/dt and got
H = p*(dq/dt) - L (q,(dq/dt)(q,p,t),t). so my question is - why we can treat p and q as independent coordinates here (dp/dq = 0...) , when obviously there is a conection?

By definition, the Hamiltonian is a function ##H(q,p,t)## with the ##q## and ##p## as independent variables. You eliminate the generalized velocities ##\dot{q}## with help of the ##p## (and ##q##). This is a socalled "contact transformation" or "Legendre transformation".

but dq/dt is dependent on q, so why we can transform p(q,dq/dt) to (dq/dt)(p,q) using Legendre transformation?

In the Lagrangian formulation the ##q## and ##\dot{q}## are considered independent variables of the Lagrange function, in the Hamiltonian formulation the ##q## and ##p## are considered independent variables of the Hamilton function. The Hamilton function is constructed such that this holds true (that's the Legendre transformation between the Lagrange and the Hamilton function!):
$$\mathrm{d} L = \mathrm{d} q \cdot \partial_q L + \mathrm{d} \dot{q} \cdot \partial_{\dot{q}} L$$
Now we have
$$H=\dot{q} \cdot p-L \quad \text{with} \quad p=\partial_{\dot{q}} L$$
and thus
$$\mathrm{d} H = \mathrm{d} \dot q \cdot p + \dot{q} \cdot \mathrm{d} p - \mathrm{d} L = \dot{q} \cdot \mathrm{d} p - \mathrm{d} q \cdot \partial_q L.$$
Thus the "natural independent variables" for ##H## are indeed ##q## and ##p##, and thus we have
$$\partial_p H=\dot{q}, \quad \partial_q H=-\partial_q L.$$
For the solutions of the Euler-Lagrange equations the latter equation gets
$$\partial_q H=-\partial_q L=-\frac{\mathrm{d}}{\mathrm{d} t} (\partial_{\dot{q}} L) = -\dot{p},$$
which gives the Hamilton canonical equations of motion.

Of course, you can also extend this to explicitly time-dependent Hamilton and Lagrange functions. Nothing changes in the above, you only get additionally
$$\frac{\partial L}{\partial t}=-\frac{\partial H}{\partial t}.$$

thank you for the quick response!
so if I understand correctly, we treat q and q dot as independent in the Lagrangian formalism (in the Lagrangian itself), but only when using EL equations we treat q dot as the derivative of q (or when constructing them from the extremal action principle). that is why we can treat them as independent until we demand EL to hold (or ds = 0...). that is why we can transform to p,q without having to worry about the relations between q and q dot. that relation wakes up only when constructing Hamilton equations using EL.

so at first (in the differential of H ), we treated H as a mathematical function with no relation between her coordinates, and the relation only comes from Hamilton's equations.

Yes, that's it! The trouble is the usual sloppyness of physicists in their notation using ##\dot{q}## at the same time as denoting the generalized velocities as independent variables in the Lagrange function and as the time derivative of the generalized coordinates when considering trajectories in configuration space and particularly the trajectories solving the Euler-Lagrange equations, which are the equations of motion of the mechanical system under consideration.

• PeroK
thank you so much, it was really helpful !