[SciPy-user] optimize.fsolve

Ryan Krauss ryanfedora at comcast.net
Thu Aug 18 09:57:34 CDT 2005


That's a good question.  I can think of some ways to hack it, but there 
must be a clean way.  I just don't know what that is.  My first hack 
idea would be to check if the second argument was a tuple and then deal 
its contents to the desired variables (arguments 3 through the end would 
have to have default values for this to work).

Looking at the source to fsolve didn't provide any insight.  It 
eventually calls something like
retval = 
_minpack._hybrd(func,x0,args,full_output,xtol,maxfev,ml,mu,epsfcn,factor,diag) 

and _hybrd must be a fortran routine or something because I can't find 
it defined as Python anywhere.

Ryan

Howey, David A wrote:
> thanks for all your help Ryan and Brett.
> 
> I have now got fsolve working in my code. You won't believe how overjoyed I am!!! (the simple things in life, eh..)
> 
> one more general python question relating to parameter passing. With routines like fsolve, the additional arguments for the user-defined function are passed in in a tuple, eg
> args = (80000, 80000, 12.7)
> 
> is it possible to do a hack to call the function directly, eg something like
> answer = myfunc(x, args)
> 
> .. this doesn't work, but is there some kind of 'unpack' or something which will make the function think it's just getting positional arguments instead of a tuple?
> 
> There must be a way, otherwise how would fsolve (etc etc) work?
> 
> Dave
> 
> 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user



More information about the SciPy-user mailing list