# Lagrangian total time derivative - continues second-order differential

In the lagrangian, adding total time derivative doesn't change equation of motion. $$L' = L + \frac{d}{dt}f(q,t).$$

After playing with it, I realize that this is only true if the $$f(q,t)$$ function has "continuous second partial derivatives". If it doesn't have, then the proof that equations are motion are the same for $$L'$$ and $$L$$ fail. The reason why proof would fail will take me a long time to explain, but if necessary, let me know and will try to update this.

Though, I have not seen anywhere such a restriction about $$f(q,t)$$. Shouldn't we be careful not to take $$f(q,t)$$ which doesn't have "continuous second partial derivatives"? In that case, it doesn't seem general to assume for any $$f(q,t)$$, it would yield the same EOM.

Update

Let me show why proof would fail.

$$F$$ is a function of $$q(t), t$$.

Since $$L' = L + \frac{d}{dt}f(q,t)$$, since we hear that it yields the same EOM, then let's see if it does.

$$\frac{d}{dt}\frac{\partial L'}{\partial \dot q} - \frac{\partial L'}{\partial q} = 0$$

$$\frac{d}{dt}\frac{\partial}{\partial \dot q} (L + \frac{df}{dt}) - \frac{\partial}{\partial q}(L + \frac{df}{dt}) = 0$$

$$\frac{d}{dt}\frac{\partial L}{\partial \dot q} + \frac{d}{dt}\frac{\partial }{\partial \dot q} \frac{df}{dt} - \frac{\partial L}{\partial q} - \frac{\partial }{\partial q}\frac{df}{dt} = 0$$

$$\frac{d}{dt}\frac{\partial L}{\partial \dot q} - \frac{\partial L}{\partial q} + \frac{d}{dt}\frac{\partial }{\partial \dot q} \frac{df}{dt} - \frac{\partial }{\partial q}\frac{df}{dt} = 0$$

If people say that $$L'$$ and $$L$$ yield the same EOM, then first 2 members are equal to 0 which means that we have to show that:

$$\frac{d}{dt}\frac{\partial }{\partial \dot q} \frac{df}{dt} - \frac{\partial }{\partial q}\frac{df}{dt} = 0$$

$$\frac{d}{dt}\frac{\partial }{\partial \dot q} \frac{df}{dt} = \frac{\partial }{\partial q}\frac{df}{dt}\tag{1}$$

We can figure out what $$\frac{df}{dt}$$ is. since it's a function of $$q,t$$, we get: $$\frac{df}{dt} = \frac{\partial f}{\partial q} \dot q + \frac{\partial f}{\partial t}$$. Plugging this in (1), we get:

$$\frac{d}{dt}\frac{\partial }{\partial \dot q} (\frac{\partial f}{\partial q} \dot q + \frac{\partial f}{\partial t}) = \frac{\partial }{\partial q}(\frac{\partial f}{\partial q} \dot q + \frac{\partial f}{\partial t})$$

$$\frac{d}{dt}(\frac{\partial }{\partial \dot q} (\frac{\partial f}{\partial q}\dot q)) = \frac{\partial }{\partial q}(\frac{\partial f}{\partial q} \dot q + \frac{\partial f}{\partial t})$$

$$\frac{d}{dt}(\frac{\partial f}{\partial q}) = \frac{\partial }{\partial q}(\frac{\partial f}{\partial q}) \dot q + \frac{\partial }{\partial q}\frac{\partial f}{\partial t}$$

Left side is total time derivative, so we can do the following:

$$\frac{\partial }{\partial q} \frac{\partial f}{\partial q} \dot q + \frac{\partial }{\partial t}\frac{\partial f}{\partial q} = \frac{\partial }{\partial q}(\frac{\partial f}{\partial q}) \dot q + \frac{\partial }{\partial q}\frac{\partial f}{\partial t}$$

One can see the first member of left side and first member of right side cancel, so we're left with:

$$\frac{\partial }{\partial t}\frac{\partial f}{\partial q} = \frac{\partial }{\partial q}\frac{\partial f}{\partial t}$$

So this must be equal otherwise, it fails. Then we know that the final equation is a mixed partial differential - Check here So you see $$f$$'s all the second partial derivatives must exist and must be continuous)

After playing with it, I realize that this is only true if the $$f(q,t)$$ function has "continuous second partial derivatives".

$$\frac{\partial }{\partial t}\frac{\partial f}{\partial q} = \frac{\partial }{\partial q}\frac{\partial f}{\partial t}$$

So this must be equal otherwise, it fails. Then we know that the final equation is a mixed partial differential - Check here So you see $$f$$'s all the second partial derivatives must exist and must be continuous)

This looks correct to me.

In the lagrangian, adding total time derivative doesn't change equation of motion. $$L' = L + \frac{d}{dt}f(q,t).$$

I think you have just shown that this is only true for a certain (very wide and very typical) class of transformations. So, this is not true in all generality.

What is true, however, is that this transformation ($$L \to L' = L + \frac{df}{dt}$$) does not change the variation in the action: $$\delta S \to \delta S' = \delta S$$. Therefore, the form of the Hamiltonian principle equation remains the same regardless of which $$L$$ or $$L'$$ is used.

This is true because the respective actions are: $$S = \int_{t_1}^{t_2}dt L\;,$$ and $$S' = \int_{t_1}^{t_2}dt L' = \int_{t_1}^{t_2}dt \left(L + \frac{df}{dt}\right) = S + f(t_2) - f(t_1)$$

Clearly $$\delta S' = \delta S\;,$$ since $$\delta (f(t_2) - f(t_1)) = 0\;,$$ since $$f(t_2) - f(t_1)$$ does not depend on the path. (The variation $$\delta$$ is with respect to the path.)

• I know how to prove with action principle that you showed. but I wanted to prove differently. If my proof is correct, then doesn't it mean that $f$ must be continues and must have 2nd order differentials as a restriction ? you mention: "So, this is not true in all generality." Can you tell why ? the plain math that I have written definitely shows it. Commented Aug 29, 2023 at 19:01
• I'm agreeing with you. The statement you made "adding total time derivative doesn't change equation of motion" is not always true.
– hft
Commented Aug 29, 2023 at 19:03
• I'm not sure what additional explanation you are looking for other than what you have already found...
– hft
Commented Aug 29, 2023 at 19:04
• The funny thing though is If I use second type of proof with action principle, then I prove that it works for any $d/dt f(q,t)$, but I might have a mistake in there who knows. Commented Aug 29, 2023 at 19:04
• You should try to come up with an explicit example where $\frac{\partial^2 f}{\partial q \partial t}\neq \frac{\partial^2 f}{\partial t \partial q}$. This will likely help explain what is going on.
– hft
Commented Aug 29, 2023 at 19:05

I think that the textbook 'Classical Dynamics of Particles and Systems' by Marion and Thornton has mentioned this restriction (Section 7.4 in the fifth edition):

However, certain transformations that change the Lagrangian but leave the equations of motion unchanged are allowed. For example, equations of motion are unchanged if $$L$$ is replaced by $$L + \frac{d}{dt}[f(q_i, t ) ]$$ for a function $$f(q_i, t)$$ with continuous second partial derivatives.