You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm interested in passing extra arguments to a function whose root to find using the "broyden1" solver of scipy.optimize. I wasn't able to find the solution online so I hope to find it here. I'm using scipy-0.12.1-1.
The following nominal case works fine:
from numpy import cos
from scipy.optimize import broyden1
def F(x):
return cos(x) + x[::-1] - [1, 2, 3, 4]
x = broyden1(F, [1,1,1,1], f_tol=1e-14)
print x
However, I would like to be able to define F such as:
def F(x, a, b):
return cos(x) + x[::-1] - [1, 2, 3, 4] + a + b
The "broyden1" function doesn't have the usual arguments "args" to pass extra arguments to F. I tried to modified the "nonlin.py" source code in scipy.optimize in vain (I tried to add "args=()" in line 223 and "args" in line 273, both as argument of each function in question).
I would like to know if there is an easy fix. Thank you.
The text was updated successfully, but these errors were encountered:
Hello,
I'm interested in passing extra arguments to a function whose root to find using the "broyden1" solver of scipy.optimize. I wasn't able to find the solution online so I hope to find it here. I'm using scipy-0.12.1-1.
The following nominal case works fine:
However, I would like to be able to define F such as:
The "broyden1" function doesn't have the usual arguments "args" to pass extra arguments to F. I tried to modified the "nonlin.py" source code in scipy.optimize in vain (I tried to add "args=()" in line 223 and "args" in line 273, both as argument of each function in question).
I would like to know if there is an easy fix. Thank you.
The text was updated successfully, but these errors were encountered: