Why does a transformation on $p$ imply the inverse transformation on $q$ in phase space? I'm reading A conceptual introduction to Hamiltonian Monte Carlo. On pages 30-31 it is stated that applying a transformation to the momentum p in phase space, implies the opposite transformation to the parameters q:
$$p'= \sqrt{M^{-1}}p$$
implies
$$q'= \sqrt{M}q$$
for some Euclidean metric $M$, known as the mass matrix.
I don't understand why this is. Suppose we are working in 1 dimension (so $M$ is just a number), and suppose $M = 4$. Then:
$$q' = \sqrt{M}q = 2q$$
The momentum would then be:
$$p = mv = m \frac{dq}{dt} = \frac{1}{2} m \frac{dq'}{dt} = \frac{1}{2}p' \iff p' = 2p$$
To me it seems both p and q transform in the same way, getting multiplied by 2. So where did I go wrong?
 A: The author of this statistics paper aims for transformations $p\mapsto p'\,,q\mapsto q'$ that preserve Hamiltonian geometry. As far as I can tell from a quick look at Hamiltonian Monte Carlo this means he wants to preserve the energies expressed as
$$
H=\frac{1}{2}\boldsymbol p^\top M^{-1}\boldsymbol p\,,\quad T=\frac{1}{2}\dot{\boldsymbol q}^\top M\dot{\boldsymbol q}\,.
$$
This looks quite familar to a physicist. Now take the square root of $M$ and $M^{-1}\,.$ Clearly, the invariance of $H$ and $T$ under the above transformations is compatible with $\boldsymbol p'=\sqrt{M^{-1}}\boldsymbol p$ and $\dot{\boldsymbol q}'=\sqrt{M}\dot{\boldsymbol q}\,$ and assuming that $M$ is constant we can undo the time derivative of the $\dot{\boldsymbol q}$ relation.
A: The answer lies in Lagrangian mechanics, where we define the Lagrangian to be $L = T - V$ where $T$ is the kinetic energy and $V$ is the potential energy. In our case:
$$
L = \frac{p^2}{2m} + V(q) = \frac{mv^2}{2} + V(q) = \frac{m\dot{q}^2}{2} + V(q)
$$
so that:
$$
p = \frac{\partial L}{\partial \dot{q}}
$$
If we now apply the transformation $q' = \sqrt{M}q$ (with constant $M$) we get:
$$
p' = \frac{\partial L}{\partial \dot{q'}} = \frac{\partial L}{\partial \dot{q}} \frac{\partial \dot{q}}{\partial \dot{q'}} = p \frac{1}{\sqrt{M}}
$$
