generate functionWed, 15 Mar 2023

And now all together! You only have the function that is given to you as an argument and you must find its minimum. You will look for the global one, you should be able to do this only because they are good here. Yes, and yet, now they are not one-dimensional, but two-dimensional. You will also be given starting points from which convergence is guaranteed. Hint can use the following options: Deviation in the calculation of the derivative ε=10−10 Stopping criterion: number of iterations 104 Gradient Descent Step Length lr=0.5 Once again, we provide a step drawing feature for added convenience.

def grad_descent(df, x0, step_size=0.5, thresh=1e-10, max_iter=1e4): step = 0 x = x0 while step < max_iter and np.linalg.norm(df(x)) > thresh: x = x - step_size*df(x) step = step + 1 return x

Questions about programming?Chat with your personal AI assistant