Solution (source code)

= Solution

A <canonical transformation> preserves the <symplectic form> and therefore the form of <Hamilton's equations> for arbitrary Hamiltonians. In one degree of freedom,
$$
dQ\wedge dP=(Q_qP_p-Q_pP_q)\,dq\wedge dp=[Q,P],dq\wedge dp.
$$
Thus \b[the transformation is canonical exactly when $[Q,P]=1$]. Equivalently the chain rule gives $[F,G]_{q,p}=[Q,P]_{q,p}[F,G]_{Q,P}$ for arbitrary transformed functions, so the bracket and <Hamiltonian> dynamics are preserved precisely with this factor one. The condition also makes the Jacobian nonzero and hence supplies local invertibility; a global canonical change of variables additionally requires the stipulated global bijectivity on its domain.