Local picture is explained in
Suppose we choose a Lagrangean submanifold, what gives the splitting between submanifold coordinates , and the corresponding moment where the Hamiltonian is and , . The canonical transformation by definition preserves the equations of motion; let the new coordinates be and momenta and the new Hamiltonian is . Thus both variations
\delta \int p d q - H d t = \delta \int P d Q - K d t = 0
vanish. Here we of course write . Subtracting the left and right hand side variations we get that the difference must be a (variation of the integral of the) total differential of a function, which can be chosen as a function of some set of old and new coordinates in a consistent way. For example in 1 dimension, we have 4 possibilities of one new and one old generalized coordinate.
p d q - H d t = P d Q - K d t + d F
d F = p d q - P d Q + (K - H) d t
therefore if then , , , what gives the relation between the old and new coordinates and momenta and the new Hamiltonian , which must be expressed in terms of .
If then we add , use the Leibniz rule and we see that for the generating function of the “second kind”, the total differential
d \Phi = d (F + P Q) = p d q + Q d P + (K - H) d t
and , , . A similar analysis can be done straightfowardly for other possibilities of the choice of arguments.
An invariant picture of generating functions on symplectic manifolds is in