from scipy import optimize def f(x): return 3 * (1 - x) + (x - 2)**2 res = optimize.minimize_scalar(f) print(res.x) print(f(res.x))