所以我试图用fsolve求解6个方程6个未知数的非线性系统。我按照这里找到的格式:
http://folk.uio.no/inf3330/scripting/doc/python/SciPy/tutorial/old/node18.html
我的方程组:
def func(x):
out = [x[0] - c*(t1 - x[3])]
out.append(x[1] - c*(t2 - x[3]))
out.append(x[2] - c*(t3 - x[3]))
out.append(x[0]**2 - (right_x - x[4])**2 - (right_y - x[5])**2)
out.append(x[1]**2 - (middle_x - x[4])**2 - (middle_y - y[5])**2)
out.append(x[2]**2 - (left_x - x[4])**2 - (left_y - x[5])**2)
return out
solve = fsolve(func, [1.0, 1.0, 1.0, 1.5, 1.0, 1.0])
print(solve)
返回错误:
File "C:\Anaconda3\lib\site-packages\numpy\core\numeric.py", line 525, in asanyarray
return array(a, dtype, copy=False, order=order, subok=True)
ValueError: setting an array element with a sequence.
所有常量都是dtype:float
关于我做错了什么的任何想法?
我能发现的一件事是y [5]在这里看起来像一个错字:
out.append(x [1] ** 2 - (middle_x - x [4])** 2 - (middle_y - y [5])** 2)
你的上下文中的y [5]可能是一个像numpy数组或类似的东西吗?