Hamiltonian Dynamics in Bijected Vector Space

Starting with a regular Lagrangian of the form

L(q,q˙)=12∑imiq˙2+U(q)

bijecting it into another vector space so Q=f(q) and q=f−1(q)

Using the chain rule we can see that

q˙i=dqidt=∑j∂fi−1(Q)∂QjdQjdt=∑j∂fi−1(Q)∂QjQ˙j

Then substituting back into the Lagrangian

L(Q,Q˙)=12∑imi(∑j∂fi−1(Q)∂QjQ˙j)2+U(f−1(Q))
=12∑imi∑j∑k∂fi−1(Q)∂Qj∂fi−1(Q)∂QkQ˙jQ˙k+U(f−1(Q))
=12∑j∑k(∑imi∂fi−1(Q)∂Qj∂fi−1(Q)∂Qk)Q˙jQ˙k+U(f−1(Q))

Then define a matrix

Gjk(Q)=∑imi∂fi−1(Q)∂Qj∂fi−1(Q)∂Qk

Making

L(Q,Q˙)=Q˙⊤𝐆(Q)Q˙+U(f−1(Q))

Then do the Legendre transform to make it a Hamiltonian

Pi=∂L∂Q˙i=12∑j𝐆ijQ˙j+12∑j𝐆jiQ˙j

And 𝐆 is symmetric so

=∑j𝐆ijQ˙j

So

P=𝐆(Q)Q˙

The Legendre transform requires that it's invertable so if the matrix is invertable then

Q˙=𝐆−1(Q)P

Then with the Legrendre transform

H(Q,P)=P⊤Q˙−L(Q,Q˙)
=P⊤𝐆−1(Q)P−L(Q,𝐆−1(Q)P)
=P⊤𝐆−1(Q)P−12((𝐆−1(Q)P)⊤𝐆(Q)(𝐆−1(Q)P))+U(Q)
=P⊤𝐆−1(Q)P−12(P⊤𝐆−1(Q)𝐆(Q)𝐆−1(Q)P)+U(Q)
=P⊤𝐆−1(Q)P−12(P⊤𝐆−1(Q)P)+U(Q)
=12P⊤𝐆−1(Q)P+U(Q)