Skip to content

Commit

Permalink
Catch evaluation_error's in temme_method_2_ibeta_inverse
Browse files Browse the repository at this point in the history
See #1169.
  • Loading branch information
jzmaddock committed Aug 10, 2024
1 parent 2a4351e commit aa9959e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions include/boost/math/special_functions/detail/ibeta_inverse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,19 @@ T temme_method_2_ibeta_inverse(T /*a*/, T /*b*/, T z, T r, T theta, const Policy
//
// And iterate:
//
x = tools::newton_raphson_iterate(
temme_root_finder<T>(-lu, alpha), x, lower, upper, policies::digits<T, Policy>() / 2);
try {
x = tools::newton_raphson_iterate(
temme_root_finder<T>(-lu, alpha), x, lower, upper, policies::digits<T, Policy>() / 2);
}
catch (const evaluation_error&)
{
// Due to numerical instability we may have cases where no root is found when
// in fact we should just touch the origin. We simply ignore the error here
// and return our best guess for x so far...
// Maybe we should special case the symmetrical parameter case, but it's not clear
// whether that is the only situation when problems can occur.
// See https://github.com/boostorg/math/issues/1169
}

return x;
}
Expand All @@ -319,6 +330,7 @@ T temme_method_3_ibeta_inverse(T a, T b, T p, T q, const Policy& pol)
{
BOOST_MATH_STD_USING // ADL of std names


//
// Begin by getting an initial approximation for the quantity
// eta from the dominant part of the incomplete beta:
Expand Down

0 comments on commit aa9959e

Please sign in to comment.