我想对以下非线性方程进行根搜索,我在 Python 中进行,但它不起作用。我的代码在下面
from pylab import *
import scipy
import scipy.optimize
def z1(x,y):
temp=1+1j+x+2*y;
return temp
def z2(x,y):
temp=-1j-2*x+sqrt(3)*y;
return temp
def func(x):
temp=[z1(x[0],x[1])-1.0/(1-1.0/(z2(x[0],x[1]))),1-2.0/(z2(x[0],x[1])-4.0/z1(x[0],x[1]))]
return temp
result=scipy.optimize.fsolve(func,[1+1j,1+1j])
print result
当我运行它时,它显示错误:
---> 30 结果=scipy.optimize.fsolve(func,[1+1j,1+1j])
C:\Python27\lib\site-packages\scipy\optimize\minpack.py in fsolve(func, x0, args, fprime, full_output, col_deriv, xtol, maxfev, band, epsfcn, factor, diag)
123 maxfev = 200*(n + 1)
124 retval = _minpack._hybrd(func, x0, args, full_output, xtol,
--> 125 maxfev、ml、mu、epsfcn、因子、诊断)
126 else:
127 _check_func('fsolve', 'fprime', Dfun, x0, args, n, (n,n))