From da33ba44259fecf4bb0769c62289ba6baab89c92 Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Tue, 28 Apr 2015 19:16:33 +0100 Subject: [PATCH] Fix heuristic in schroeder_iterate. Brings schroeder_iterate more into line with halley_iterate. --- include/boost/math/tools/roots.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/math/tools/roots.hpp b/include/boost/math/tools/roots.hpp index 6e01523ad..e238dad30 100644 --- a/include/boost/math/tools/roots.hpp +++ b/include/boost/math/tools/roots.hpp @@ -513,7 +513,8 @@ T schroeder_iterate(F f, T guess, T min, T max, int digits, boost::uintmax_t& ma else delta = ratio; // fall back to Newton iteration. } - if(fabs(delta * 2) > fabs(delta2)) + T convergence = fabs(delta / delta2); + if((convergence > 0.8) && (convergence < 2)) { // last two steps haven't converged, try bisection: delta = (delta > 0) ? (result - min) / 2 : (result - max) / 2;