Scipy:牛顿法的数值导数比割线法快吗

2024-06-10 19:36:08 发布

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

我试图用SciPy(scipy.optimize.newton)提供的Newton Raphson来找到一个方程的根。在

目前我还没有文档建议使用的fprime值,据我所知,这意味着正割方法正在用于查找根。在

由于Newton-Raphson方法的收敛速度比割线法快,我的直觉认为也许我应该用数值逼近fprime并提供它,以便使用牛顿法。在

哪一种方法通常会导致更快的收敛/更快的实际计算我的根?在

  1. 只使用scipy.optimize.newton而不提供fprime(即割线方法,或
  2. 使用数值微分法计算fprime(例如数字差异)并将其提供给scipy.optimize.newton,以便使用Newton-Raphson方法。在

Tags: 方法文档newtonscipy速度建议数值optimize
1条回答
网友
1楼 · 发布于 2024-06-10 19:36:08

第二版《C中的数值配方》一书第365页“9.4牛顿-拉斐逊导数法”中指出:

The Newton-Raphson formula can also be applied using a numerical difference to approximate the true local derivative,

f'(x) ≈ (f(x + dx) - f(x)) / dx .

This is not, however, a recommended procedure for the following reasons: (i) You are doing two function evaluations per step, so at best the superlinear order of convergence will be only sqrt(2). (ii) If you take dx too small you will be wiped out by roundoff, while if you take it too large your order of convergence will be only linear, no better than using the initial evaluation f'(x_0) for all subsequent steps. Therefore, Newton-Raphson with numerical derivatives is (in one dimension) always dominated by the secant method of section 9.2.

选择另一种方法来提高数值导数的精度会增加函数求值的次数,从而使收敛阶数进一步降低。因此,您应该选择第一个方法,它最终使用割线方法来查找根。在

相关问题 更多 >