boostorg / boost

Super-project for modularized Boost
https://github.com/boostorg/wiki/wiki/Getting-Started%3A-Overview
Boost Software License 1.0
6.97k stars 1.72k forks source link

finite_difference_derivative with 6th Order calc coeff error value #926

Open Swordhalo opened 1 month ago

Swordhalo commented 1 month ago

Version: 1.85.0 file path: boost\math\differentiation\finite_difference.hpp

In function: finite_difference_derivative with 6th Order, calc step h by :

// Error: h^6f^(7)(x)/140 + 5|f(x)|eps/h
      Real h = pow(eps / 168, static_cast<Real>(1) / static_cast<Real>(7));

The coeff number 168 was wrong acrooding to the comment expression below. The Number 168 seems to be calc by 1406/5, which the correct coeff should be 1405/6 = 350/3. Besides, it should be eps * Coeff instead of eps / 168. The final expression of step h should be like:

Real h = pow(eps * 350 / 3 , static_cast<Real>(1) / static_cast<Real>(7));

And, every comment about ’eps^2/3, eps^4/5, eps^6/7' were not used in the code, which also attentioned in the website document.