ENH minimize, minimize_scalar: Add support for user-provided methods