In order to achieve that I want to use fsolve from scipy package. So I have first to create a function f(x), i.e.

- Code: Select all
`def func f(x, imax):`

for i in range(imax):

y = [ x[i]-2*x[i-2]...-1/x[i]**2, ] #this should be a matrix containing the

#equations in where all the equations are

# seperated with ','

return y

After define the function you use fsolve like this: scipy.optimize.fsolve( func, inGuess, args = ( imax ). So the argument to fsolve is a function containing the system of equations. My problem is how to create this function having the number of equations depended from imax. e.g. I want to write fsolve(func,args(10)), or fsolve(func,args(20)) etc

This is an example that works:

- Code: Select all
`>>> def func2(x): y = [x[0]*cos(x[1]) - 4, x[1]*x[0] - x[1] - 5] return y`

>>> x0 = scipy.optimize.fsolve(func2, [1, 1])

>>> print x0

[ 6.5041, 0.9084]