Не могу понять что это за ошибка и с чем она связана
import numpy as np
def num_deriv(func):
def deriv_func(val):
dx = 1e-10
x = val[0]
y = val[1]
result_x = (func(x + dx, y) - func(x - dx, y)) / (2 * dx)
result_y = (func(x, y + dx) - func(x, y - dx)) / (2 * dx)
return np.array([result_x, result_y])
return deriv_func
def grad_local(func_, deriv_, mas):
current_point = mas
STEP_SIZE = 0.01
step = 0
current_point
while step != 40000:
step += 1
type(current_point)
current_point = current_point - STEP_SIZE * num_deriv(func_(current_point))
return current_point
def f(mas):
return 2 * mas[0] + 2 * mas[1] ** 2
local = grad_local(f, num_deriv, np.array([1, 1]))
Вывод:
Traceback (most recent call last):
File "C:/Users/paulr/PycharmProjects/Stepik/Tinkoff/Lectoin1Prac/Prac5.py", line 35, in <module>
local = grad_local(f, num_deriv, np.array([1, 1]))
File "C:/Users/paulr/PycharmProjects/Stepik/Tinkoff/Lectoin1Prac/Prac5.py", line 26, in grad_local
current_point = current_point - STEP_SIZE * num_deriv(func_(current_point))
TypeError: unsupported operand type(s) for *: 'float' and 'function'