Given a transformation $$(q, p, t)\to (Q(q, p, t), P(q, p, t), t),$$ the modified Hamiltonian, $K$ is related to the original one, $H$, as $$H(q, p, t) = K(Q(q, p, t), P(q, p, t), t).$$ Now, what I've seen done everywhere$^1$ is to heuristically cook up some unjustified extremization principle for the Hamiltonians, demanding that $$ \int (p_i\dot q_i-H(q, p, t))\; dt,\\ \int(P_i \dot Q_i-K(Q, P, t))\;dt $$ be extremized. And this is followed by saying that a sufficient condition for them to lead to to the same equations of motion is that they differ by some total time derivative, and hence are born the generating functions.
However, there are several things that I don't understand at all:
- The statement that seems to being (mis)used here is that if a trajectory $q(t)$ extremizes the integral $\int_{t_0}^{t_f} L(q(t), \dot q(t), t) dt$, then the same trajectory extremizes the integral if $\frac{\partial f}{\partial q}(q, t)\dot q+\frac{\partial f}{\partial t}(q, t)$ is added to $L(q, \dot q, t)$. Question: Is this justly used in the above? If so, how? There is no $p$ or $P$ in Lagrangian!
- I don't even understand the claimed extremization principle. Question: How can one even go about extremizing this? Are we to perturb $(q(t), p(t))$ by two functions, $\delta q(t)$ and $\delta p(t)$? I'm familiar only with the action extremization principle that gives rise to E-L equations.
$^1$For example, these notes. (Section 4.1, Eq. (4.7-4.9).)