move numerical optimization functions into a separate module