Skip to content

newton_raphson_iterate bisection fallback does not work #808

Open
@wthrowe

Description

@wthrowe

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.

#include <boost/math/tools/roots.hpp>
#include <iostream>
#include <utility>

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions