"Setting an array element with a sequence" 对非线性方程组使用 fsolve 时出错

"Setting an array element with a sequence" error when using fsolve for a system of nonlinear equations

所以我正在尝试使用 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)

returns错误:

  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 数组或类似的东西吗?