root and minimize from scipy.optimize