[SciPy-user] help needed using optimize.fsolve
Robert Kern
rkern at ucsd.edu
Mon Jun 6 10:08:37 EDT 2005
Guillem Borrell Nogueras wrote:
> I've seen that the scipy's fsolve function has the option to pass
> optional arguments to the function one wants to solve.
>
> fsolve(func, x0, args=(), fprime=None, full_output=0, col_deriv=0,
> xtol=1.49012e-08,
> maxfev=0, band=None, epsfcn=0.0, factor=100, diag=None)
> ...
> args -- Any extra arguments to func are placed in this tuple.
>
>
> I need to solve a set of non-linear equations changing some parameters.
> The way i use in matlab and fortran is to write a file with the
> parameter and read it when the function is evaluated. This is slow and
> annoying.
>
> I've tried unsuccessfully to pass the arguments this way. ¿Anyone can help?
In [1]:def func(x, some, other, args):
...: print some, other, args
...: return x*x*some + x*other + args
...:
In [2]:optimize.fsolve(func, 0.0, args=(1,2,3))
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
[etc.]
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the SciPy-User
mailing list