我有一个方程组:
for i [1, N]:
|A_i x (X - B_i)|
y_i = ------------------------
|A_i|
the goal: find X such that it minimizes the target function:
sum_{i in [1, N]} (y_i)^2 -> min
其中 A_i, X, B_i
是 3x1
向量,*
是标量乘法,|v|
是 v
的欧几里得范数,x
是叉乘。
如何使用 Python(scipy.optimize?)来求解这个方程组?我之前只使用 numpy.linalg.solve
解决了 Ax = b
,所以我有点困惑。
我想我应该使用Nelder-Mead simplex algorithm ,听起来正确吗?
最佳答案
基本上我最终使用了 SciPy documentation 中的代码:
import numpy as np
from scipy.optimize import minimize
# Target function
def rosen(x):
"""The Rosenbrock function"""
return sum(100.0*(x[1:]-x[:-1]**2.0)**2.0 + (1-x[:-1])**2.0)
x0 = np.array([1.3, 0.7, 0.8, 1.9, 1.2])
res = minimize(rosen, x0, method='nelder-mead',
options={'xtol': 1e-8, 'disp': True})
print(res.x)
关于python - 如何在 Python 中求解非线性方程组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55827156/