[SciPy-user] fsolve help

demarchi at duke.edu demarchi at duke.edu
Fri Jul 14 20:52:02 EDT 2006


Folks:

I'm trying to use fsolve and my program crashes(!) when I execute this:

#!/usr/bin/env python
import math
from scipy.optimize import fsolve

def func2(x):
        out = [x[0]+2*x[1]+2*x[2]-1]
        out.append(x[0]+x[2] - 2*x[1])
        out.append(x[3]+x[4]-1)
        out.append(1/5-2/5*x[2]+2/5*x[0]*x[3]-x[0])
        out.append(1/5-x[1]/5-x[2]/5+2/5*x[1]*x[4]+x[1]/5-x[1])
        out.append(1/5-2/5*x[1]+2*x[2]/5+x[2]*x[3]/5)
        return out

x02 = fsolve(func2, [0.25,0.25,0.5,0.5,0.5])
print x02

I just did it in maple, and the roots are
x0=1/8
x1=3/16
x2=1/4
x3=.5
x4=.5

Moroever, the final equation isn't really needed (and I tried rerunning
the program without it).  If I do this, the program doesn't crash, but the
answer doesn't converge (and isn't close -- "The iteration is not making
good progress..." message shows up).

Am I doing something wrong in python, or is the solver weak, or...?  IF it
is the latter, is there another library that I could be using?

Thanks for any help.
Scott



More information about the SciPy-User mailing list