Starting with a regular Lagrangian of the form
bijecting it into another vector space so and
Using the chain rule we can see that
Then substituting back into the Lagrangian
Then define a matrix
Making
Then do the Legendre transform to make it a Hamiltonian
And is symmetric so
So
The Legendre transform requires that it's invertable so if the matrix is invertable then
Then with the Legrendre transform