I am using scipy.optimize's function fsolve
to solve for two unknowns in two equations. The equations that I am trying to solve in the end are (much) more complex but I already struggle understanding the following basic example.
import scipy.optimize as scopt
def fun(variables) :
(x,y) = variables
eqn_1 = x ** 2 + y - 4
eqn_2 = x + y ** 2 +3
return [eqn_1, eqn_2]
result = scopt.fsolve(fun, (0.1, 1))
print(result)
This gives the result [-2.08470396 -0.12127194]
, however when I plug those numbers back into the function (one time assuming the first is meant as x, one time assuming the first is y), I get results very different from zero.
print((-2.08470396)**2 - 0.12127194 - 4)
print((-2.08470396) + (- 0.12127194) ** 2 + 3)
Result 0.22 and 0.93.
print((-0.12127194)**2 -2.08470396 - 4)
print((-0.12127194) + (-2.08470396) ** 2 + 3)
Result -6.06 and 7.22.
What am I missing here?