Try this, I assure you that it will work perfectly.
import scipy.optimize as opt from numpy import exp import timeit st1 = timeit.default_timer() def f(variables) : (x,y) = variables first_eq = x + y**2 -4 second_eq = exp(x) + x*y - 3 return [first_eq, second_eq] solution = opt.fsolve(f, (0.1,1) ) print(solution) st2 = timeit.default_timer() print("RUN TIME : {0}".format(st2-st1)) -> [ 0.62034452 1.83838393] RUN TIME : 0.0009331008900937708
Fyi. as mentioned above, you can also use the "Broyden approximation" by replacing "fsolve" with "broyden1". It is working. I have done it.
I donβt know exactly how the Bruiden approximation works, but it took 0.02 s.
And I recommend that you do not use the Sympy <functions - conveniently, but in terms of speed it is rather slow. You'll see.
Dane Lee Nov 04 '17 at 4:01 2017-11-04 04:01
source share