In [8]:
alpha = 0.4
cur_w = 1
N = 200

w_list = [1]
fw_list = [4]

for i in range(N):
    prev_w = cur_w
    cur_w += - alpha * derivative(f,prev_w)
    
    w_list.append(cur_w)
    fw_list.append(np.power((cur_w-3),2))
    

print("The local minimum occurs at: %.1f" % cur_w)
The local minimum occurs at: 3.0