# I Adding a term to the Lagrangian

#### kent davidge

It's known that the Lagragian is invariant when one adds to it a total time derivative of a function. I was thinking about the possible forms of this function. Could it be a function of $x,\dot x, \lambda$? Or it should be a function of $x$ only?

Here $x: \ \{x^\mu (\lambda) \}$ are the coordinates, $\dot x: \ \{ dx^\mu/d\lambda \}$ the corresponding "velocities" and $\lambda$ the parameter.

I think my question is due to my lack of knowledge on variation, because:
if one considers $\delta \int (df / d\lambda) d\lambda = \delta (f|_{\lambda_f} - f|_{\lambda_i})$ then it seems that $f$ can be a function of the three quantities I mentioned above, because the variation will be zero anyways. But if the correct way is to put the $\delta$ symbol inside the integral first, then the variation would vanish only if $f = f(x)$.

#### Orodruin

Staff Emeritus
Homework Helper
Gold Member
2018 Award
It's known that the Lagragian is invariant when one adds to it a total time derivative of a function.
The Lagrangian is not invariant. The equations of motion are.

It does not matter what the function is a function of because it will be directly integrable and only give a boundary contribution that does not affect the variations inside your time interval.

#### samalkhaiat

It does not matter what the function is a function of
That is not correct. It cannot depend on the velocities. Given $L_{1}(x_{a} , \dot{x}_{a} , t)$, then in order for $L_{2}(x_{a} , \dot{x}_{a} , t) = L_{1}(x_{a} , \dot{x}_{a} , t) + F (x_{a} , \dot{x}_{a} ,t)$ to reproduce the same E-L equations, the function $F$ must satisfies E-L equations identically (independent of the specific time dependence of $x_{a}$, i.e., independent of the solutions $x_{a}(t)$). Indeed, we prove the following: A function of $x_{a}(t), \ \dot{x}_{a}(t)$ and $t$ satisfies E-L equations identically (i.e., off-shell) if, and only if, it is the total time derivative $dG/dt$ of some continuous function $G(x_{a}(t) , t )$.
Proof
The “if” part: Let $$F = \frac{d}{dt} G(x , t) = \frac{\partial G}{\partial x_{c}} \dot{x}_{c} + \frac{\partial G}{\partial t} .$$ (repeated indices are summed over). Now $$\frac{\partial F}{\partial \dot{x}_{a}} = \frac{\partial G}{\partial x_{a}}, \ \ \frac{d}{dt} \left( \frac{\partial F}{\partial \dot{x}_{a}} \right) = \frac{\partial^{2}G}{\partial x_{c}\partial x_{a}} \dot{x}_{c} + \frac{\partial^{2}G}{\partial t \partial x_{a}} ,$$ and $$\frac{\partial F}{\partial x_{a}} = \frac{\partial^{2}G}{\partial x_{a}\partial x_{c}} \dot{x}_{c} + \frac{\partial^{2}G}{\partial x_{a} \partial t}.$$ Thus, from the continuity of $G( x, t)$, we see that $F$ satisfies E-L’s equations $$\frac{d}{dt} \left( \frac{\partial F}{\partial \dot{x}_{a}} \right) = \frac{\partial F}{\partial x_{a}},$$ identically (i.e., independent of the functional form of $G(x ,t)$ and of the specific time dependence of $x_{a}$).
The “only if” part: Let $F$ be some function of $x_{a}, \dot{x}_{a}$ and $t$, which satisfies the E-L’s equations identically. These can be rewritten as $$\frac{\partial^{2}F}{\partial \dot{x}_{c}\partial \dot{x}_{a}} \ddot{x}_{c} + \frac{\partial^{2}F}{\partial x_{c}\partial \dot{x}_{a}}\dot{x}_{c} + \frac{\partial^{2}F}{\partial t \partial \dot{x}_{a}} = \frac{\partial F}{\partial x_{a}} .$$ The $\ddot{x}$’s appear only in the first term on the left. Since we want the equations to be satisfied independent of the $x$’s, the coefficients of each of the $\ddot{x}$’s must be zero $$\frac{\partial^{2}F}{\partial \dot{x}_{a}\partial \dot{x}_{c}} = 0 .$$ This means that $F$ is a linear function of the velocities $\dot{x}$’s. We may write $$F(x , \dot{x} , t) = f_{c}(x , t) \dot{x}_{c} + g(x , t),$$ for some functions $f_{a}(x,t)$ and $g(x,t)$ to be determined. From this we get $$\frac{d}{dt}\left( \frac{\partial F}{\partial \dot{x}_{a}} \right) = \frac{\partial f_{a}}{\partial x_{c}} \dot{x}_{c} + \frac{\partial f_{a}}{\partial t} ,$$ and $$\frac{\partial F}{\partial x_{a}} = \frac{\partial f_{c}}{\partial x_{a}} \dot{x}_{c} + \frac{\partial g}{\partial x_{a}} .$$ Thus, the E-L equations for $F$ becomes $$\left( \frac{\partial f_{a}}{\partial x_{c}} - \frac{\partial f_{c}}{\partial x_{a}} \right) \dot{x}_{c} + \frac{\partial f_{a}}{\partial t} = \frac{\partial g}{\partial x_{a}} . \ \ \ (1)$$ Again, we want these equations to be satisfied independent of the $x$’s. Thus the coefficients of each of the $\dot{x}$’s must vanish: $$\frac{\partial f_{a}}{\partial x_{c}} = \frac{\partial f_{c}}{\partial x_{a}}.$$ Thus, there exists some continuous function $G(x,t)$ such that $$f_{a}(x,t) = \frac{\partial}{\partial x_{a}}G(x,t) .$$ Substituting this in (1), we find $$\frac{\partial^{2}G}{\partial t \partial x_{a}} = \frac{\partial g}{\partial x_{a}}, \ \ \Rightarrow \ \ g = \frac{\partial G}{\partial t} .$$ Thus, in order to satisfy E-L’s equation off shell, a function $F(x , \dot{x} , t)$ must have the form $$F = \frac{\partial G}{\partial x_{c}} \dot{x}_{c} + \frac{\partial G}{\partial t} = \frac{d}{dt} G(x , t).$$

#### Orodruin

Staff Emeritus
Homework Helper
Gold Member
2018 Award
That is not correct.
Yes, it most certainly is. A total time derivative of a function that depends on velocities still satisfies the Euler-Lagrange equations, but it does not depend only on $x$ and $\dot x$. It also depends on $\ddot x$, which breaks your assumption that the function added to the Lagrangian can only depend on $x$ and $\dot x$.

Sure, you can go ahead and have a discussion about including second derivatives in the Lagrangian, but mathematically it is absolutely clear that adding any total time derivative does not affect the equations of motion (see below), because such a term satisfies the EL equations off shell by design.

These can be rewritten as
No they generally cannot, not if $F$ depends on $\ddot x$ (or any higher order derivatives), which it will if the function you are taking the time derivative of depends on velocities. There is an additional term in the EL equations for integrands that depend on the second derivatives. In general in variational calculus where the integrand $\mathcal L$ depends on derivatives up to $x^{(n)}$, you have
$$\sum_{k = 0}^n (-1)^k \frac{d^k}{dt^k}\frac{\partial \mathcal L}{\partial x^{(k)}} = 0.$$
(This does appear, e.g., (for the spatial derivatives) in deriving the equations of motion for a beam with some stiffness (where the potential energy per unit length is proportional to the curvature of the beam, which can be expressed using the second spatial derivatives).)

To see that a total derivative does not affect the action apart from a boundary term is trivial. Let $\mathcal L_2 = \mathcal L_1 + dG/dt$ with $G$ being an arbitrary function, containing as many time derivatives as you want of $x$. You then have
$$S_2 = \int_{t_1}^{t_2} \mathcal L_2 dt = \int_{t_1}^{t_2} (\mathcal L_1 + dG/dt) dt.$$
The second term can be integrated directly to yield
$$S_2 = S_1 + [G|_{t_2} - G|_{t_1}].$$
Taking the variation of this will not introduce terms depending on anything other than $t_1$ and $t_2$ in the boundary terms so if you look at only internal variations, you immediately end up with the same Euler-Lagrange equations.

Note that, if you assume that $G$ is a function of $x$ and $\dot x$, then $dG/dt$ will generally be a function of $x$, $\dot x$, and $\ddot x$. Then you can go on and argue about whether you should allow second derivatives in the Lagrangian, but the math is clear. You can add any function on the form $dG/dt$ without affecting the Euler-Lagrange equations because any function of the form $dG/dt$ satisfies the Euler-Lagrange equations off shell.

Thus, in order to satisfy E-L’s equation off shell, a function $F(x , \dot{x} , t)$ must have the form $$F = \frac{\partial G}{\partial x_{c}} \dot{x}_{c} + \frac{\partial G}{\partial t} = \frac{d}{dt} G(x , t).$$
This is correct for a function $F$ that is only a function of $x$, $\dot x$, and $t$. It is not true for an arbitrary function $F$. For example, it certainly is not true if you allow $F$ to depend on $\ddot x$, which it will if it is the total derivative of a function that depends on $\dot x$. Generally, for a $G$ that depends on derivatives up to $x^{(n-1)}$, you would have
$$F = \frac{\partial G}{\partial t} + \sum_{k=0}^{n-1} \frac{\partial G}{\partial x^{(k)}} x^{(k+1)} = \frac{dG}{dt}.$$

Last edited:

#### samalkhaiat

Yes, it most certainly is.
Then you should be able to answer this: I give you $L_{1} = \frac{1}{2}\dot{x}^{2}$, find for me a function $G(x,\dot{x},t)$ such that $L_{2} \equiv L_{1} + dG/dt$ is another equivalent Lagrangian.

Sure, you can go ahead and have a discussion about including second derivatives in the Lagrangian
Yes, it is obviously clear that my post was about Lagrangians that are at most quadratic in the velocities, i.e., those which describe wide range of mechanical systems.

#### Orodruin

Staff Emeritus
Homework Helper
Gold Member
2018 Award
Yes, it is obviously clear that my post was about Lagrangians that are at most quadratic in the velocities, i.e., those which describe wide range of mechanical systems
Sorry, but this is not the point. The point is not depending on accelerations. This was your assumption and it is obvious that if you place this restriction you cannot have G depend on velocities. However, this does not change the fact that you get the same equations of motion if you let G depend on velocities. I suggest you try it.

As an example, you can always add $t_0 d\mathcal L/dt$ to your Lagrangian and recover the same equations of motion. In your proposed case this would be $t_0 \dot x \ddot x$. This will give you the same equations of motion unless you make arithmetic errors. This leads to:
\begin{align*}
\delta S &= \int \delta L dt = \int \left(\frac{1}{2}(\dot x + \delta \dot x)^2 + t_0 (\dot x + \delta \dot x)(\ddot x + \delta \ddot x) - \frac{\dot x^2}{2} - t_0 \dot x \ddot x\right)dt \\
&\simeq \int (\dot x\, \delta \dot x + t_0 \dot x \, \delta\ddot x + t_0 \ddot x \, \delta\dot x) dt
\simeq \int (- \ddot x + t_0 \dddot x - t_0 \dddot x)\delta x\, dt = - \int \ddot x \, \delta x\, dt,
\end{align*}
which is the same variation as that of $\mathcal L = \dot x^2/2$ up to boundary terms and have the same EL equations (i.e., $\ddot x = 0$).

Last edited:

#### samalkhaiat

Sorry, but this is not the point. The point is not depending on accelerations. This was your assumption and it is obvious that if you place this restriction you cannot have G depend on velocities.
Yes, sorry, I meant to say “at most quadratic in velocities and not depending on accelerations”.
However, this does not change the fact that you get the same equations of motion if you let G depend on velocities.
Of course, by going from the variation problem for $L_{1}(x, \dot{x})$ with $$\frac{\partial L_{1}}{\partial x} = \frac{d}{dt} \frac{\partial L_{1}}{\partial \dot{x}},$$ to another variation problem for $L_{2}(x, \dot{x}, \ddot{x}, \cdots )$ with $$\frac{\partial L_{2}}{\partial x} = \frac{d}{dt} \frac{\partial L_{2}}{\partial \dot{x}} - \frac{d^{2}}{dt^{2}} \frac{\partial L_{2}}{\partial \ddot{x}} + \cdots ,$$ then $G = G(x, \dot{x} , \cdots )$

"Adding a term to the Lagrangian"

### Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving