# Invariance of canonical Hamiltonian equation when adding the total time derivative of a function of $q_i$ and $t$ to the Lagrangian

The following is exercise 8.2 in 3rd edition (and exercise 8.19 in 2nd edition) of Goldstein's Classical Mechanics.

Adding the total time derivative of a function of $q_i$ and t to the Lagrangian will not change the the Euler-Lagrangian equation. So if we make the following change to Lagrangian,

$$L'(q,\dot{q},t) = L(q,\dot{q},t) + \frac{dF(q_1,q_2,...,q_n,t)}{dt}$$ we can get $$\frac{d}{dt}\frac{\partial{L'}}{\partial{\dot{q_i}}} - \frac{\partial{L'}}{\partial{q_i}} = 0$$ from $$\frac{d}{dt}\frac{\partial{L}}{\partial{\dot{q_i}}} - \frac{\partial{L}}{\partial{q_i}} = 0$$

How can we get the corresponding Hamiltonian equation part? This is to prove $$\dot{p'_i} = \frac{\partial{H'}}{\partial q_i}$$ $$-\dot{q_i} = \frac{\partial{H'}}{\partial p'_i}$$

from

$$\dot{p_i} = \frac{\partial{H}}{\partial q_i}$$ $$-\dot{q_i} = \frac{\partial{H}}{\partial p_i}$$ where $p'_i = \frac{\partial L'}{\partial \dot q_i}$.

Edit

The corresponding $H'$ is $$H' = \sum_k{p'_k \dot{q_k}} - L'$$ where $p'_k = \frac{\partial L'}{\partial \dot q_k}$.

• For the "corresponding" part, do you know how the corresponding addition to the Hamiltonian looks like? I.e. how do we get $H'$ from $H$? How do you define $H'$ within the Hamiltonian formalism without referring to $L$ and $L'$? – ACuriousMind Jul 19 '14 at 16:38
• Actually, the question is from Chapter 8 derivation 2 in Goldstein's Classical Mechanics, third edition. – Negelis Jul 19 '14 at 16:54
• Hm. You're right (and I'm apparently a bit rusty in classical mechanics), I apologize. (I'll delete my wrong comments, no point in them cluttering this) I'm still not satisifed though, since $H'$ is defined in terms of $L'$, so it's a tautology that $H'$ fulfills Hamilton's equations since it is the Legendre transform of a valid Lagrangian for the system. – ACuriousMind Jul 19 '14 at 17:01
• So the point is to prove H' fulfills Hamilton equation based on H fulfills Hamilton equation, not based on it is the Legendre transform of a Lagrangian L'. – Negelis Jul 19 '14 at 17:24
• If anybody is interested in the solutions of exercise 8.2 in the Goldstein, you can find it as a spanish version here : github.com/nquesada/Goldstein/blob/master/capitulo08.pdf – Knowledge Nov 9 '15 at 8:42

As you state in the comments, $$\frac{\mathrm dF}{\mathrm dt}=\frac{\partial F}{\partial q}\dot{q}+\frac{\partial F}{\partial t}$$ So popping this into the Lagrangian, $$L'=L+\frac{\partial F}{\partial q}\dot{q}+\frac{\partial F}{\partial t}$$

The Hamiltonian $$H=p\dot q-L$$ implies $$H'=p'\dot{q}-L'=p\dot q+something\tag{1}$$ where $$something$$ is for you to work out. Since $$p=\partial L/\partial \dot q$$, then we should assume that $$p'=\partial L'/\partial\dot q$$. It's not really necessary for this particular problem, but you can solve for $$p'$$.

The Hamiltonian formalism states that $$q$$, $$\dot q$$ and $$p$$ are independent, so we assume similarly that $$q$$, $$\dot{q}$$ and $$p'$$ are independent; hence $$\partial L/\partial p=0\to\partial L'/\partial p'=0$$.

So now all you have to do is solve $$\frac{\partial H'}{\partial p'}\text{ and }-\frac{\partial H'}{\partial q}$$ using Eq. (1) to see if the transformation in the Lagrangian preserves the Hamiltonian EOM (hint: it does). Note also that I assume a single coordinate $$q$$, there really isn't much of a difference between $$q_i$$ for $$i=1$$ and $$i\in(1,N)$$.

If $$L \to L' = L +\frac{dF(q,t)}{dt}$$ the corresponding Hamiltonian becomes $$H \to H' = H - \frac{\partial F(q,t)}{\partial t}$$ as shown here. Moreover, the canonical momentum becomes $$p \to P = p + \frac{\partial F}{\partial q}$$ while $$q \to Q = q$$ as shown here.

These formulas allow us to check the invariance of Hamilton's equations explicitly. Concretely, \begin{align} \frac{dq}{dt} &= \frac{\partial H}{\partial p} \notag \\ \end{align} becomes \begin{align} \frac{dQ}{dt} &= \frac{\partial H'}{\partial P} \\ \therefore \quad \frac{dq}{dt} &= \frac{\partial \left(H - \frac{\partial F(q,t)}{\partial t} \right)}{\partial P} \\ \therefore \quad \frac{dq}{dt} &= \frac{\partial H}{\partial P} - \frac{\partial }{\partial P} \left( \frac{\partial F(q,t)}{\partial t} \right) \\ \therefore \quad \frac{dq}{dt} &= \frac{\partial H}{\partial P} \\ \therefore \quad \frac{dq}{dt} &= \frac{\partial H}{\partial p} \frac{\partial P}{\partial p} \\ \therefore \quad \frac{dq}{dt} &= \frac{\partial H}{\partial p} \quad \checkmark \end{align} where I used that $$F$$ does not depend on $$P$$ and $$\frac{\partial P}{\partial p} =\frac{\partial }{\partial p} \left( p+ \frac{\partial F}{\partial q} \right) = 1.$$

Analogously, we can check Hamilton's second equation: $$\frac{dp}{dt}= -\frac{\partial H(q,p,t)}{\partial q} .$$ However, there is a subtlety. After the transformation, we have on the right-hand side $$\frac{\partial H'(Q,P,t)}{\partial Q}$$. But here we need take into account that $$p$$ also depends on $$q$$, since $$p \to P = p + \frac{\partial F(Q,t)}{\partial Q}$$. Therefore \begin{align} \frac{\partial H'(Q,P,t)}{\partial Q} &= \frac{\partial H'(Q,p + \frac{\partial F}{\partial q} ,t)}{\partial Q} \\ &= \frac{\partial H'(Q,p,t)}{\partial Q} + \frac{\partial H(Q,p,t) }{\partial p} \frac{\partial p}{\partial Q} \\ &= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{\partial^2 F(Q,t)}{\partial Q \partial t} + \frac{\partial H(Q,p,t) }{\partial p} \frac{\partial p}{\partial Q} \\ &= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{\partial^2 F(Q,t)}{\partial Q \partial t} + \dot Q \frac{\partial \left(P- \frac{\partial F}{\partial q} \right)}{\partial Q} \\ &= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{\partial^2 F(Q,t)}{\partial Q \partial t} - \dot Q \frac{\partial }{\partial Q} \frac{\partial F}{\partial q} \\ &= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{d}{dt} \frac{\partial F}{\partial Q} \,. \end{align} where we used that $$\frac{d}{dt} \frac{\partial F}{\partial Q}= \frac{\partial^2 F(Q,t)}{\partial Q \partial t} + \dot Q \frac{\partial }{\partial Q} \frac{\partial F}{\partial q} .$$

Using this, we can rewrite Hamilton's second equation after the transformation as follows: \begin{align} \frac{dP}{dt}&= -\frac{\partial H'(Q,P,t)}{\partial Q} \\ \therefore \quad \frac{d}{dt} \left( p+ \frac{\partial F(q,t)}{\partial q} \right) &= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{d}{dt} \frac{\partial F}{\partial Q} \\ \therefore \quad \frac{dp}{dt} + \frac{d}{dt} \left(\frac{\partial F(q,t)}{\partial q} \right)&= \frac{\partial H(Q,p,t)}{\partial Q} - \frac{d}{dt} \frac{\partial F}{\partial Q} \\ \therefore \quad \frac{dp}{dt} &= -\frac{\partial H}{\partial q} \quad \checkmark \end{align}

EDIT: The subtlety was also noted here, but unfortunately without an answer and a few years ago there was even a paper which didn't notice it and claimed that Hamilton's equations are not invariant.