def 150 f0 110 return sum for in range len -1 f0 def Grad 150 return n

1
2
3
4
5
6
7
def f(x, a = 150, b = 2, f0 = 110):
return sum([a*(x[i]**2 - x[i+1])**2 + b*(x[i] - 1)**2 for i in range(0, len(x)-1)]) + f0
def Grad(x, a = 150, b = 2):
return np.array([4*a*x[0]*(x[0]**2-x[1]) + 2*b*(x[0]-1),
4*a*x[1]*(x[1]**2-x[2]) + 2*b*(x[1]-1) - 2*a*(x[0]**2-x[1]),
-2*a*(x[1]**2-x[2])])