Optimization, Programming, Python, Evolutionary Algorithms, Editors Pick.
Defining the objective function def obj_fun(x): return (x[0] - 0.5) ** 2 + 0.7 * x[0] * x[1]\ + 1.2 * (x[1] + 0.7) ** 2 # Defining the gradient function def gradient_fun(x): return np.array([2 * (x[0] - 0.5) + 0.7 * x[1],\ 0.7 * x[0] + 2 * 1.2 * (x[1] + 0.7)]) Which visually looks like this.