I am using fsolve(eqs,initial_condition) in python but I defined the function eqs in two different ways, by meaning the same (same equations in both cases). However it gets different outputs and I do not see where the error is. I have attached the code used.
If you rearrange the equations you'll see that they are the same (in the second block x[0] is the x in the first block, x[1] would be y in the first block and x[-1] would be equal to lamda in the first block)
#First block
from scipy.optimize import fsolve
import numpy as np
def my_function(z):
x = z[0]
y = z[1]
lamda = z[2]
F = np.empty(3)
F[0] = -lamda*x/8 + 2*x -16
F[1] = -lamda*y/2 + 2*y -12
F[2] = x**2/16 + y**2/4 -1
return F
zGuess = np.array([8,6,10])
z = fsolve(my_function,zGuess)
print('Valor de x:',z[0])
print('Valor de y:',z[1])
print('Valor de lambda:',z[2])
#Second block
from scipy.optimize import fsolve
import numpy as np
a = np.array([4,2])
centroid = np.array([8,6])
def eqs(x):
return [x[0]-centroid[0]/(1-x[-1]/a[0]**2),x[1]-centroid[1]/(1-
x[-1]/a[1]**2),x[0]**2/a[0]**2 + x[1]**2/a[1]**2 -1]
zGuess = np.array([8,6,10])
sol = fsolve(eqs,zGuess)
print('Valor de x:',sol[0])
print('Valor de y:',sol[1])
print('Valor de lambda:',sol[2])