The Hamiltonian transformation is extended to the case of varying relations as follows. Instead of (4) we write

H = p1q˙1 + p2q˙2 + ... − T + V,

(8)

and imagine H to be expressed in terms of the momenta p1, p2, ..., the co-ordinates q1, q2, ..., and the time. The internal forces of the system are assumed to be conservative, with the potential energy V. Performing the variation δ on both sides, we find

δH = q˙1δp1 + ... − ∂Tδq1 + ∂Vδq + ...,
∂q1 ∂q1

(9)

terms which cancel in virtue of the definition of p1, p2, ... being omitted. Since δp1, δp2, ..., δq1, δq2, ... may be taken to be independent, we infer

q˙1 = ∂H,   q˙2 = ∂H, ...,
∂p1 ∂p2

(10)

and