Solution (source code)

= Solution

A <type-two generating function for a canonical transformation> uses the mixed variables $(q,P)$ and defines
$$
\boxed{p=\frac{\partial F_2}{\partial q},\qquad
Q=\frac{\partial F_2}{\partial P}.}
$$
For a local invertible <canonical transformation>, require $F_{2,qP}\ne0$ so that $p=F_{2,q}(q,P)$ can be solved for $P$. The differential identity $dF_2=p\,dq+Q\,dP$ gives $d(F_2-PQ)=p\,dq-P\,dQ$, expressing preservation of the canonical <symplectic form>.