On Sat, Jan 30, 2010 at 6:47 PM, Scott <[email protected]> wrote:
> I am currently using scipy.optimize.fsolve to solve a 15 and 420
> equation nonlinear system but I would like to try methods other than
> Powell's hybrid.  The answer to the previous become a parameter for
> the next step.  The nonlinear system is polynomial and was created in
> sympy.
>
> sympy.nsolve, mpmath.findroots both provide a variety of solvers but
> the interfaces seem to be less friendly regarding passing parameters
> to the residual function and analytical jacobian.
>
>   Advice on how to get from :
>        >>> def f(x1, x2):
>        ...     return x1**2 + x2, 5*x1**2 - 3*x1 + 2*x2 - 3
>        ...
>        >>> findroot(f, (0, 0))
>        matrix(
>        [['-0.618033988749895'],
>         ['-0.381966011250105']])
>
>
> to something like the following would be appreciated.
>        >>> def f(x1, x2,a,b):
>        ...     return a*x1**2 + x2, b*5*x1**2 - 3*x1 + 2*x2 - 3
>        ...
>        >>> findroot(f, parameters=(a,b),(0, 0))
>        matrix(
>        [['-0.618033988749895'],
>         ['-0.381966011250105']])

Either by modifying our solvers, I think we should provide this
"parameters" argument. If you could send us a patch fixing it, it'd be
awesome.

In the meantime, just use global variables, e.g. something like:

params = [ <whatever you need here> ]

def f(...):
    global params
    <use params>


global params
params = (a, b)
findroot(f, (0, 0))


Ondrej

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to