import numpy as np import collections from scipy.optimize import fminbound bool = np.array([True, False, False, True]) vec = np.array([1,4,3,4,5]) def f(x): return np.power(x, 4) - np.power(x, 2) def f_neg(x): return -1.0*f(x) print(np.random.uniform(0.0, 1e-7, 10)) print(np.where(vec < f(vec), True, False)) print(fminbound(f_neg, -2, 2))