# Gauge invariance of the Hamiltonian

Consider a Lagrangian $L(x,\dot x,t)$ and a corresponding Hamiltonian $H=\dot xp-L$ where $p=\partial L/\partial \dot x$ which satisfies Hamilton's equations $$\frac{\partial H}{\partial x}=-\dot p$$ $$\frac{\partial H}{\partial p}=\dot x.$$ I'm trying to show that Hamilton's equations are unchanged by a gauge transformation of the Lagrangian $L'=L+ \frac{dF}{dt}$ where $F(x,t)$ is a function of the position and time only. I first expand the derivative of $F$ $$\frac{dF}{dt}=\frac{\partial F}{\partial t}+ \frac{\partial F}{\partial x}\dot x$$ the new conjugate momentum is $$p'=\frac{\partial L'}{\partial \dot x}=\frac{\partial L}{\partial \dot x}+\frac{\partial}{\partial \dot x} \frac{dF}{dt}=p+ \frac{\partial F}{\partial x}$$ and so $$\frac{\partial}{\partial p'}= \frac{\partial p}{\partial p'} \frac{\partial}{\partial p}=\frac{\partial}{\partial p}$$ The new Hamiltonian is $$H'=p'\dot x-L' = p \dot x-L+\frac{\partial F}{\partial x} \dot x - \frac{dF}{dt}=H- \frac{\partial F}{\partial t}$$ Hamilton's equations are then $$\frac{\partial H'}{\partial p'}=\frac{\partial H}{\partial p}- \frac{\partial}{\partial p} \frac{\partial F}{\partial t}=\dot x-0=\dot x$$ and $$\frac{\partial H'}{\partial x}=\frac{\partial H}{\partial x}- \frac{\partial}{\partial x} \frac{\partial F}{\partial t}= -\dot p-\frac{\partial }{\partial t} \frac{\partial F}{\partial x}$$ It is this last equation where I'm having trouble. To satisfy Hamilton's equations, the right side should be equal to $\dot p'= \frac{d}{dt}(p+\frac{\partial F}{\partial x})$ however I end up with a partial derivative on the last term rather than a total derivative as it should be. How can one justify this as satisfying Hamilton's equations?

Edit

It seems that the error is arising when taking the partial of $H'$. When applying $\partial/\partial x$ to $H'(x,p')$ we are implicitly holding $p'$ constant, where as $\partial H/\partial x=- \dot p$ is true only when we are holding $p$ constant, not $p'$. A workaround is to use the form $H'=p' \dot x-L'$ as the functional dependence is clear. Then $$\frac{\partial H'}{\partial x}= -\frac{\partial L'}{\partial x} = -\frac{\partial L}{\partial x}- \frac{\partial}{\partial x} \frac{d F}{dt}= -\frac{d}{dt} \left( \frac{\partial L}{\partial \dot x} + \frac{\partial F}{\partial x}\right) = -\dot p'$$ where Euler-Lagrange was used on the second last equality. I'm still unsure of how to apply the chain rule to my original expression to get the correct result.

This is a situation where it helps to be very careful about what everything means. First, (being very persnickety) the right hand side should be equal to $-\dot{p}'$ (since $F=-\nabla_x V$.)
Secondly, (hint) the operator $\partial_x$ has a slightly different meaning when acting on functions of $p,x$ and functions of $p',x$.
Applying the chain rule explicitly, \begin{align*} \partial_x|_{p'} H' &= \frac{\partial H}{\partial x}\Big|_p+\frac{\partial H}{\partial p}\Big|_x\frac{\partial p}{\partial x}\Big|_{p'}-\frac{\partial}{\partial x}\frac{\partial F}{\partial t}\quad \text{(since $F$ depends only on $x,t$)}\\ &=-\dot{p}+\dot{x}\Big(-\frac{\partial}{\partial x}\Big|_{p'}\frac{\partial}{\partial x}F(x,t)\Big)-\frac{\partial}{\partial x}\frac{\partial F}{\partial t}\\ &=-\dot p-\dot x\partial_x^2|_{p'}F(x,t)-\partial_x\partial_tF \\ &=-\dot p' \end{align*}
• Thanks, I've found a workaround to get the result. I'm still unsure of how one would apply $\partial_x$ to $H'$ though. Can you elaborate? – gene Oct 30 '17 at 15:47