Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

second_order_root_finder (near) infinite loop #776

Closed
TFiFiE opened this issue Mar 12, 2022 · 0 comments · Fixed by #777
Closed

second_order_root_finder (near) infinite loop #776

TFiFiE opened this issue Mar 12, 2022 · 0 comments · Fixed by #777

Comments

@TFiFiE
Copy link

TFiFiE commented Mar 12, 2022

halley_iterate and schroder_iterate can get stuck in a (virtually) infinite loop even when given a limited max_iter, because in the function:

T second_order_root_finder(F f, T guess, T min, T max, int digits, std::uintmax_t& max_iter) noexcept(policies::is_noexcept_error_policy<policies::policy<> >::value&& BOOST_MATH_IS_FLOAT(T) && noexcept(std::declval<F>()(std::declval<T>())))

the variable count might already be zero when either of the following functions is called:
delta = bracket_root_towards_min(f, guess, f0, min, max, count);

delta = bracket_root_towards_max(f, guess, f0, min, max, count);

where it will wrap around by any of:
while (--count && ((f_current < 0) == (f0 < 0)))

while (--count && ((f_current < 0) == (f0 < 0)))

while (--count && ((f_current < 0) == (f0 < 0)))

while (--count && ((f_current < 0) == (f0 < 0)))

becoming std::numeric_limits<boost::uintmax_t>::max() before reaching:
} while(count && (fabs(result * factor) < fabs(delta)));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant