newton_raphson_iterate bisection fallback does not work
- Dominant language
- C++
- Stars
- 374
- Forks
- 264
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 17
Description
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
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.