I'm trying to calculate the minimum of a function using the newton-raphson(with shift) method and I get the following error: "object arrays are not supported" (the problem occurs in solve(H, gf))
Here is my code:
import numpy as np
from sympy.abc import x, y
from sympy import ordered, Matrix, hessian
from sympy.utilities.iterables import ordered
from scipy.linalg import solve
n_iter = 50
a = 1
eq = 100*(y-x**2) + (1-x**2)**2
v = list(ordered(eq.free_symbols)); v
[x, y]
x_ = [-1.2, 1]
gradient = lambda f, v: Matrix([f]).jacobian(v)
H = hessian(eq, v)
gf = gradient(eq, v)
for _ in range(n_iter):
H = H + a * np.identity(2)
p = solve(H, gf)
x = x + p
print(x)