Adiabatic Invariant in Variable Mass Oscillator Suppose you have an harmonic oscillator whose mass is adiabatically changing such that $T\frac{dm}{dt}\ll m$ where $T$ is the period of the motion. It could for example be an ice ball slowly melting connected to a spring.
Considering the adiabatic invariant $\frac{E}{\omega}$ where $E$ is the energy of the oscillator and $\omega^2=\frac{k}{m}$, the energy of the oscillator should increase. However I can't figure out why this happens by starting from first principles (like Newton equations). How does it work?
 A: The equation of motion for " ice ball slowly melting connected to a spring"
you start with the kinetic energy $T_c$
$$T_c=\frac 12 m(\tau)\,\dot x^2$$
and the potential energy of the spring $U$
$$U=\frac 12 k\,x^2$$
with Euler- Lagrange you obtain the EOM.
$$ \begin {array}{c} m \left( \tau \right) {\ddot x}+kx+ \left( {
\frac {d}{d\tau}}m \left( \tau \right)  \right) {\dot x}\end {array}
 =0
$$
you can make this Ansatz for $m(\tau)$
$$m(\tau)=m_{{0}}\,{{e}^{-{\frac {\tau}{T}}}}$$
where $T$ is the time constant $~[s]$ for the ice melting process and $m_0$ is the initial ice  mass
the EOM is now
$$\ddot x+\underbrace{\frac{e^{(\tau/T)}\,k}{m_0}}\,x-\frac{1}{T}\,\dot x$$
Edit
The total energy is:
$$E=\frac 12\,m_{{0}}{{\rm e}^{-{\frac {\tau}{T}}}}{{\dot x}}^{2}+\frac 12\,k{x}^{2}$$
with :
$$T=\frac {2\pi}{\omega}=\frac{2\,\pi}{\sqrt{\frac{k}{m_0}}}~,k=m_0\,\omega^2$$
$$E=\frac 12\,m_{{0}}{{\rm e}^{-\frac{1}{2\,\pi}\,\sqrt {{\frac {k}{m_{{0}}}}}\tau}}{{\dot x}}^{2}+\frac 12\,m_{{0}}{\omega}^{2}{x}^{2}
$$
for $\tau \mapsto \infty$
$$E=\frac 12\,m_{{0}}{\omega}^{2}{x}^{2}
~,\frac{E}{\omega}=\frac 12\,m_0\,\omega\,x^2=\text{const.}$$
