This came from the expression of conservation of energy:
, assuming
is constant.
This gives the expression
. You can plug in some given
and do the integral (analytically if you can, or numerically).
You then get a function of
on the RHS, which you can solve for in terms of
-- that's then your answer,
.