A problem in my classical mechanics textbook is stated as follows:
Show that if the Lagrangian $L(\mathbf{q},\dot{\mathbf{q}},t)$ is modified to $L'$ by any transformation of the form $$ L' = L + \dfrac{d}{dt}g(\mathbf{q},t) $$ then Lagrange's equations remain unchanged.
I approched the problem as follows: $$ \dfrac{d}{dt}\left(\dfrac{\partial L'}{\partial \dot{q}_j}\right)-\dfrac{\partial L'}{\partial q_j} =0 $$ Since $g(\mathbf{q},t)$ is independent of $\dot{\mathbf{q}}$, this becomes: $$ \dfrac{d}{dt}\left(\dfrac{\partial L}{\partial \dot{q}_j}\right)-\dfrac{\partial}{\partial q_j}\left(L+\dfrac{d}{dt}g(\mathbf{q},t)\right) =0 $$ $$ \dfrac{d}{dt}\left(\dfrac{\partial L}{\partial \dot{q}_j}\right)-\dfrac{\partial L}{\partial q_j} = \dfrac{\partial}{\partial q_j}\left(\dfrac{d}{dt}g(\mathbf{q},t)\right) $$ Which leaves us to prove that $$ \dfrac{\partial}{\partial q_j}\left(\dfrac{d}{dt}g(\mathbf{q},t)\right) = 0 $$
However, I seem to be unable to prove this. Did I make a mistake, or do I just fail to see how this can be proven?