Open ryanelandt opened 1 year ago
Because of the issue described above, the unit test https://github.com/boostorg/math/blob/50ef83a47b13c02bf9d6c0e86f9066c431ac42cb/test/test_roots.cpp#L657-L659 passes, even though the answer in produces in inaccurate due to running out of iterations.
The documentation for
newton_raphson_iterate
says:There are two issues relating to
max_iter
:max_iter
is copied to a variablecount
. After each Newton iteration, one is subtracted fromcount
. Because of thedo {...} while (count && ...)
structure of the Newton iteration, ifmax_iter = 0
, rollover occurs, makingmax_iter
functionally infinite.0 < max_iter
, running out of iterations exits the Newton loop as if the tolerance was met.These two observations are demonstrated in the code below.