# When do total and partial derivatives commute?

In Classical Mechanics, the Lagrangian is a function of a generalized coordinate $$q$$, the corresponding generalized velocity $$\dot{q}$$, and time $$t$$.

For the Lagrangian, $$\dfrac{d}{dt}\frac{\partial L}{\partial \dot{q}} \neq \frac{\partial \dot{L}}{\partial \dot{q}},$$ that is, the two derivatives do not commute. However, what if $$L$$ were a function only of $$q$$ and $$t$$? Then would the total derivative in $$t$$ and the partial derivative in $$q$$ always commute?

Also, for $$L(q, t)$$, is $$\frac{\partial \dot{L}}{\partial \dot{q}}$$ always equal to $$\frac{\partial L}{\partial q}$$?

Take into account that, for a function $$f$$ of $$q,\dot{q},t,$$ the total derivative is given by $$\frac{d}{dt}=\sum_{h=1}^n\left(\dot{q}_h\frac{\partial}{\partial{q_h}}+\ddot{q}_h\frac{\partial}{\partial{\dot{q}_h}}\right)+\frac{\partial}{\partial{t}}$$ If $$f$$ only depends on $$q,t$$ then \begin{align} \require{cancel} \frac{\partial}{\partial{q_k}}\frac{df}{dt} &=\frac{\partial}{\partial{q_k}}\left[\sum_{h=1}^n\left(\dot{q}_h\frac{\partial{f}}{\partial{q_h}}+\cancel{\ddot{q}_h\frac{\partial{f}}{\partial{\dot{q}_h}}}\right)+\frac{\partial{f}}{\partial{t}}\right]=\\ &=\sum_{h=1}^n\left(\dot{q}_h\frac{\partial}{\partial{q_h}}\frac{\partial{f}}{\partial{q_k}}+\right)+\frac{\partial}{\partial{t}}\frac{\partial{f}}{\partial{q_k}}=\frac{d}{dt}\frac{\partial{f}}{\partial{q_k}} \end{align} Note that the two derivatives commute also if $$f$$ depends on $$\dot{q}.$$
Also, for $$\partial\dot{L}/\partial\dot{q}$$ and $$\partial{L}/\partial{q}$$ when $$L$$ does not depend on $$\dot{q},$$ while the former is zero, the latter in general is not.
• How come $\frac{\partial}{\partial q_k}(\dot{q_h}\frac{\partial f}{\partial q_h})=\dot{q}_h\frac{\partial}{\partial q_h}\frac{\partial f}{\partial q_k}$? I can see commuting partials being useful eventually, but how do we know that $\dot{q}_h$ does not depend on $q_k$? Oct 12, 2023 at 4:26
• @ShadyPuck they are independent variable, like in $y'' = f(x,y,y')$ you can obtain by derivation $y''' = \frac{\partial f}{\partial x} + \frac{\partial f}{\partial y}y' +\frac{\partial f}{\partial y'}y''$ Oct 12, 2023 at 21:59
In general a Lagrangian $$L$$ that depends on functions $$\phi:M\to N$$ and their $$k$$ derivatives, i.e. a function $$\newcommand{\R}{\mathbb R}$$ $$$$L:J^k(M,N) \to \R$$$$ can be written in local coordinates as \begin{align} L(j^k_x\phi) &= L(x,\phi_{i}(x),\phi_{i,\mu}(x),\phi_{i,\mu\nu}(x),\dots,\phi_{i,\mu_1\dots\mu_k}(x)) \\ &= L(x^{\mu},\phi_{i,(\alpha)}(x)). \end{align} where the indices after the commas represent partial derivatives and $$(\alpha)$$ represents a list of indices of size $$\geq 0$$. The total derivative along the $$\mu$$-th coordinate in $$M$$ is the operator $$$$\frac{dL}{dx^{\mu}} = \frac{\partial L}{\partial x^{\mu}} + \frac{\partial L}{\partial \phi_{i}}\phi_{i,\mu} + \frac{\partial L}{\partial \phi_{i,\nu}}\phi_{i,\nu\mu} + \dots + \frac{\partial L}{\partial \phi_{i,\nu_1\dots\nu_k}}\phi_{i,\nu_1\dots\nu_k\mu} .$$$$ we abreviate this as $$$$\frac{dL}{dx^{\mu}} = \frac{\partial L}{\partial x^{\mu}} + \frac{\partial L}{\partial \phi_{i,(\alpha)}}\phi_{i,(\alpha)\mu}$$$$ where the repeated indices imply sum. Then for any list of indices $$(\alpha)$$ we get \begin{align} \frac{\partial}{\partial\phi_{i,(\alpha)}}\frac{dL}{dx^{\mu}} &= \frac{\partial}{\partial\phi_{i,(\alpha)}} \left( \frac{\partial L}{\partial x^{\mu}} + \frac{\partial L}{\partial \phi_{j,(\beta)}} \phi_{j,(\beta)\mu} \right) \\ &= \frac{\partial^{2} L}{\partial\phi_{i,(\alpha)}\partial x^{\mu}} + \frac{\partial^{2} L}{\partial\phi_{i,(\alpha)}\partial \phi_{j,(\beta)}} \phi_{j,(\beta)\mu} + \frac{\partial L}{\partial \phi_{j,(\beta)}} \frac{\partial \phi_{j,(\beta)\mu}}{\partial\phi_{i,(\alpha)}} \\ &= \left( \frac{\partial^{2} L}{\partial x^{\mu}\partial\phi_{i,(\alpha)}} + \frac{\partial^{2} L}{\partial \phi_{j,(\beta)}\partial\phi_{i,(\alpha)}} \phi_{j,(\beta)\mu} \right) + \frac{\partial L}{\partial \phi_{j,(\beta)}} \delta^{i}_j\delta^{(\alpha)}_{(\beta)\mu} \\ &= \frac{d}{dx^{\mu}}\frac{\partial L}{\partial\phi_{i,(\alpha)}} + \frac{\partial L}{\partial \phi_{i,(\beta)}} \delta^{(\alpha)}_{(\beta)\mu} .\end{align} So the operators $$\frac{d}{dx^{\mu}}$$ and $$\frac{\partial}{\partial\phi_{i,(\alpha)}}$$ don't quite commute, but almost. The difference is $$$$\frac{\partial }{\partial \phi_{i,(\alpha)}}\frac{dL}{dx^{\mu}} - \frac{d}{dx^{\mu}}\frac{\partial L}{\partial\phi_{i,(\alpha)}} = \frac{\partial L}{\partial \phi_{i,(\beta)}} \delta^{(\alpha)}_{(\beta)\mu} .$$$$ This makes clear that the operators fail to commute exactly when $$(\alpha)=(\beta)\mu$$ for some list of indices $$(\beta)$$ such that $$L$$ depends on $$\phi_{i,(\beta)}$$. I.e., whenever the variable $$\phi_{i,(\alpha)}$$ is the $$\mu$$-th derivative of a variable $$\phi_{i,(\beta)}$$ upon which $$L$$ depends.
For example, for $$M=\R$$ and $$N=\R^{3}$$, take $$$$L(t,\phi_{i}(t),\dot\phi_{i}(t)) = \frac{m}{2}\|\dot\phi(t)\|^{2} - V(\phi_3(t)) .$$$$ Then since the $$\dot\phi_i$$ appear in $$L$$, the derivatives $$$$\frac{\partial }{\partial\ddot\phi_i}\frac{dL}{dt} \qquad \text{and} \qquad \frac{d}{dt}\frac{\partial L}{\partial\ddot\phi_i}$$$$ won't match up. Also, since $$L$$ depends on $$\phi_3$$, the derivatives $$$$\frac{\partial }{\partial\dot\phi_3}\frac{dL}{dt} \qquad \text{and} \qquad \frac{d}{dt}\frac{\partial L}{\partial\dot\phi_3}$$$$ won't agree, but all the other derivatives will commute.