diff --git a/include/boost/math/tools/roots.hpp b/include/boost/math/tools/roots.hpp index 81e846613..804f0101c 100644 --- a/include/boost/math/tools/roots.hpp +++ b/include/boost/math/tools/roots.hpp @@ -514,9 +514,10 @@ namespace detail{ template static T step(const T& x, const T& f0, const T& f1, const T& f2) BOOST_NOEXCEPT_IF(BOOST_MATH_IS_FLOAT(T)) { + using std::fabs; T ratio = f0 / f1; T delta; - if(ratio / x < 0.1) + if((x != 0) && (fabs(ratio / x) < 0.1)) { delta = ratio + (f2 / (2 * f1)) * ratio * ratio; // check second derivative doesn't over compensate: