如何在Python中求解非线性方程组?

2024-05-19 03:37:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个方程组:

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_i3x1向量,*是标量乘法,|v|v的欧氏范数,x是交叉乘法。你知道吗

如何使用Python(科学优化?) 去解这个方程组?我以前只用numpy.linalg.solve解了Ax = b,所以我有点困惑。你知道吗

我在想我应该用Nelder-Mead simplex algorithm,听起来正确吗?你知道吗


Tags: theintargetforthatitfunction方程组
1条回答
网友
1楼 · 发布于 2024-05-19 03:37:34

基本上,我最终使用了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)

相关问题 更多 >

    热门问题