# Variable mass systems in Lagrangian mechanics

When we write the Lagrangian $$\mathcal{L}=\frac{1}{2}m\dot{x}^2-U(x)$$, where $$U$$ is the potential energy, we are assuming that the mass $$m$$ is constant, the only variables being the velocity $$\dot{x}$$ and position $$x$$. What can be done to determine the equation of motion of the particle in case the mass is changing?

I know that we cannot simply use the formula $$\dot{p}=m\ddot{x}+\dot{m}\dot{x},$$ with $$p=\frac{\partial \mathcal{L}}{\partial \dot{x}}$$, because it isn't Galilean invariant and the system is not closed, so some other procedure must be used.

Perhaps the method of Lagrange multipliers may be used? Or via a non-standard Lagrangian that somehow reproduces the equation of motion given here?

If you just give the mass an explicit time-dependence, $$L = \frac12 m(t) \dot{x}^2 - U(x)$$ then the Euler-Lagrange equation is $$\frac{d}{dt} (m \dot{x}) = \dot{m} \dot{x} + \dot{m} \ddot{x} = - \frac{dU}{dx}.$$ It's unclear to me why you think "we simply cannot use" this result. It isn't Galilean invariant, but once you let $$m(t)$$ have arbitrary time-dependence, the action isn't Galilean invariant either.