boostorg / boostorg/math

newton_raphson_iterate bisection fallback does not work

未关闭
#808 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
374
派生
264
平均合并
1 天 23 小时
30 天内合并 PR
17

描述

The documentation for `newton_raphson_iterate` states that "Out-of-bounds steps revert to bisection of the current bounds", which should be robust, but the implementation fails to bisect correctly in some cases. The following program requests the root of a quartic with the sole root 1 in the bounding interval, but with an initial guess on the wrong side of an extremum that causes a step out of bounds. The returned result is approximately the endpoint of the interval farthest from the actual root, which should have been eliminated by a single bisection.

```c++
#include
#include
#include

int main() {
const auto quartic = [](const double x) {
return std::make_pair((x * x - 1.0) * (x * x + 0.1),
2.0 * x * ((x * x - 1.0) + (x * x + 0.1)));
};

const double result =
boost::math::tools::newton_raphson_iterate(quartic, 0.5, 0.1, 1.1, 5);
std::cout << result << "\t" << quartic(result).first << "\n";
return result;
}
```

Output:
```
0.10625 -0.110033
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。