Consider the following code.
from scipy import optimize
def fun(x):
return [x[0] + 0.5 * (x[0] - x[1])**3 - 1.0,
0.5 * (x[1] - x[0])**3 + x[1]]
def jac(x):
return np.array([[1 + 1.5 * (x[0] - x[1])**2,
-1.5 * (x[0] - x[1])**2],
[-1.5 * (x[1] - x[0])**2,
1 + 1.5 * (x[1] - x[0])**2]])
sol = optimize.root(fun, [0, 0],method='hybr')
print(sol)
In particular print(sol.fjac)
returns the following 2 x 2
matrix. Let's call it matrix A
.
[[-0.9 0.44]
[-0.44 -0.9 ]]
According to documentation this is the Jacobian matrix of the function fun
evaluated at some point.
Question. Exactly at which point?. More precisely what is the value of x0
for which jac(x0)
equals the matrix A
?
I have given the explicit Jacobian above for testing purposes.
For example I tested jac(sol.x)
and it it not the same 2 x 2
matrix as above so it can't be the Jacobian evaluated at the solution. I also did jac([0,0])
and it still does not equal the given matrix.
Any ideas?