Scipy:使用数值导数的牛顿法是否比正割法更快

Scipy: Is Newton's Method Faster with Numerical Derivatives than Secant Method

我正在尝试使用 SciPy (scipy.optimize.newton) 提供的 Newton-Raphson 求方程的根。

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

由于 Newton-Raphson 法比正割法收敛得更快,我的直觉认为也许我应该在数值上近似 fprime 并提供它以便使用牛顿法。

哪一个通常会导致更快的收敛/更快的根实际计算?

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

C 中的数值食谱,第二版,第 365 页的“9.4 Newton-Raphson Method Using Derivative”一节中指出:

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.

(为适应本网站的限制而进行了编辑。)选择另一种方法来提高数值导数的准确性会增加函数计算的次数,从而进一步降低收敛阶数。因此,您应该选择第一种方法,最终使用割线法求根。