Solution (source code)

= Solution

Let $\mu$ be the instantaneous total <mass> of the rocket, including its remaining <rocket propellant>. During a short ejection it changes by $d\mu<0$. The expelled <mass> $-d\mu$ has <velocity> $v-v_0$ to first order in a fixed <inertial frame>. With no external <force>, <momentum conservation> reads
$$
\mu v=(\mu+d\mu)(v+dv)+(-d\mu)(v-v_0).
$$
Discarding the second-order product gives $\mu\,dv=-v_0\,d\mu$. Integrate from initial total <mass> $m_0+M$ to <rocket dry mass> $m_0$:
$$
v_f=-v_0\int_{m_0+M}^{m_0}\frac{d\mu}{\mu},
\qquad\boxed{v_f=v_0\ln\left(1+\frac M{m_0}\right).}
$$
For constant <mass flow rate> $\alpha=-\dot\mu>0$, the same <rocket equation> gives $\mu(t)=m_0+M-\alpha t$ and $v(t)=v_0\ln[(m_0+M)/\mu(t)]$ until $t=M/\alpha$. The final result depends on the <rocket mass ratio>, not on how rapidly the fuel is ejected. These are Newtonian <velocities>; a very large <rocket mass ratio> would require a relativistic treatment even if the exhaust is slow in the instantaneous rocket frame.