# A problem with canonical transformation exchanging $p$ and $q$

Any function $$F$$ of the old coordinate $$q$$ and the new coordinate $$Q$$ describes the canonical transformation according to $$p\,dq-P\,dQ=dF(q,Q)$$ where $$p,P$$ are the old and new momentums respectively. From this relation follows $$p=\frac{\partial F}{\partial q},\quad P=-\frac{\partial F}{\partial Q}. \tag{1}$$ Also, defining $$\Phi=F+PQ$$ one has $$p\,dq+Q\,dP=d\Phi\tag{2}$$ and hence $$\Phi$$ is naturally a function of $$q,P$$. Relation (2) implies that $$p=\frac{\partial \Phi}{\partial q},\quad Q=\frac{\partial \Phi}{\partial P}.\tag{3}$$ I want to check formulas (1) and (3) at an explicit example. Let us choose $$F=qQ$$. Then from (1) follows $$p=Q,\quad P=-q.$$ That is indeed a canonical transformation exchanging $$(p,q)\to (Q,-P)$$. My problem is with formula (3). In fact, $$\Phi=F+PQ=(q+P)Q=0$$ since $$P=-q$$. Naively then (3) implies that $$p=Q=0$$. What is the trap that I've fallen into?

1. Let us here for simplicity only discuss 2D phase spaces. Then a CT carves out a codimension-2 (or 3D) submanifold in the 5D space ${\cal M}$ with local coordinates $(q,p,Q,P,t)$.
2. OP's trap seems to be to think that any CT can be reproduced with all of the four type 1-4 generating functions. Locally it is generically true, but there are counterexamples, such as, e.g. OP's CT $$(Q,P)~=~(p,-q).\tag{A}$$ The good news is that (one may show that) for any CT at least one of the type 1-4 generating functions works locally.
4. The CT (A) works nicely with a type 1 generating function $F(q,Q,t)=qQ$, as OP already noted.
5. However, there is no type 2 generating function $\Phi(q,P,t)$. The problem is that the type 2 CT is a graph from the 3D space with coordinates $(q,P,t)$ to ${\cal M}$, which can never reproduce OP's CT (A). [The variables $q$ & $P$ are independent in a type 2 graph, but constrained to be opposite in the CT (A).]