# Hamiltonian and Lagrangian classical mechanics

Is the following logic correct?:

If you have an Hamiltonian, that has time has a variable explicitly, and you get the Lagrangian $L$ from it, and then you get an equivalent $L'$, since $L$ has the total time derivate of a function, both Lagrangians will lead to the same equations Euler-Lagrange equations right? If so, and if you get you get the Hamiltonian from $L'$, and you find the Hamilton equations from it will they be equal to the original Hamiltonian's Hamilton equations?

If it is of any help, the given Hamiltonian is:

$$H = \frac{p^2}{2m} - bqpe^{-\alpha t} + \frac{ba}{2}e^{-\alpha t}(\alpha + b e^{-\alpha t}) + \frac{kq^2}{2} \, .$$

It seems OP is essentially asking the following two questions:

1. Is the Legendre transformation an involutive transformation?

• The answer is Yes in the regular case, i.e. when there is a bijective correspondence $v\leftrightarrow p$ between velocities and momenta. This follows from the symmetric form $$H+L =p_i v^i$$ of the Legendre transformation. See also. e.g. this related Phys.SE post.
1. Under a change of the Lagrangian $$\widetilde{L}~=~ L +\frac{dF}{dt},$$ by a total time-derivative, after a Legendre transformation into the Hamiltonian formulation, are the corresponding Hamilton's equations un-changed?
Answer: Well, the function $F$ induces a canonical transformation (CT), so that Hamilton's equations turn into Kamilton's equations. This is the topic of this Phys.SE post.