# 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
@ACuriousMind: I add it in my original question. – Negelis Jul 19 '14 at 16:43
p' is not equal with p. $p'_i = p_i + \partial{F}/\partial{q_i}$. – Negelis Jul 19 '14 at 16:51
Actually, the question is from Chapter 8 derivation 2 in Goldstein's Classical Mechanics, third edition. – Negelis Jul 19 '14 at 16:54
Please notice $L' = L + dF/dt$, not $L' = L + F$ – Negelis Jul 19 '14 at 16:56

As you state in the comments, $$\frac{dF}{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'}\,{\rm and}\,-\frac{\partial H'}{\partial q}$$ using (1) to see if the transformation in the Lagrangian preserves the Hamiltonian (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)$.