# How is it possible to have four types of generating functions?

Since the Hamilton's equations of motion remain unchanged in form under a canonical transformation $$(q,p)\to (Q,P)$$, the Lagrangians must differ by a total time derivative of a function of $$q,t$$. In other words, $$L-L'=\frac{dF(q,t)}{dt}$$ $$\Rightarrow (p\dot{q}-H)-(P\dot{Q}-K)=\frac{dF(q,t)}{dt}$$ where $$H(q,p,t)$$ and $$K(Q,P,t)$$ are respectively the old and new Hamiltonians. How can there be four types of canonical transformations $$(i)\ F_1(q,Q,t), \qquad (ii)\ F_2(q,P,t),\qquad (iii)\ F_3(p,Q,t),\qquad (iv)\ F_4(p,P,t)$$ if $$F$$ were to be a function of $$q$$ and $$t$$ only?

OP's first formula applies to the Lagrangian formalism in configuration space. In the context of canonical transformations (CT), it must be replaced with the corresponding formula in Hamiltonian phase space, i.e. the generating function $$F(q,p,t)$$ is also allowed to depend on momenta $$p$$. Since the new phase space variables $$(Q,P)$$ are supposed to depend on the old phase space variables $$(q,p)$$ and time $$t$$, we may assume that the generating function $$F(q,p,Q,P,t)$$ depends on both new and old variables. The four types of CT are special cases.