diff --git a/boost/math/special_functions/beta.hpp b/boost/math/special_functions/beta.hpp index 90977dab0..830de9d30 100644 --- a/boost/math/special_functions/beta.hpp +++ b/boost/math/special_functions/beta.hpp @@ -390,7 +390,7 @@ T ibeta_power_terms(T a, else { T p1 = pow(b1, a / b); - T l3 = (log(p1) + log(b2)) * b; + T l3 = (p1 != 0) && (b2 != 0) ? (log(p1) + log(b2)) * b : tools::max_value(); // arbitrary large value if the logs would fail! if((l3 < tools::log_max_value()) && (l3 > tools::log_min_value())) { diff --git a/patches/0002-beta.hpp-prevent-ibeta_derivative-underflow-error.patch b/patches/0002-beta.hpp-prevent-ibeta_derivative-underflow-error.patch new file mode 100644 index 000000000..c02bbb6fa --- /dev/null +++ b/patches/0002-beta.hpp-prevent-ibeta_derivative-underflow-error.patch @@ -0,0 +1,13 @@ +diff --git a/boost/math/special_functions/beta.hpp b/include/boost/math/special_functions/beta.hpp +index 87e8950dc..f74937c1a 100644 +--- a/boost/math/special_functions/beta.hpp ++++ b/boost/math/special_functions/beta.hpp +@@ -390,7 +390,7 @@ T ibeta_power_terms(T a, + else + { + T p1 = pow(b1, a / b); +- T l3 = (log(p1) + log(b2)) * b; ++ T l3 = (p1 != 0) && (b2 != 0) ? (log(p1) + log(b2)) * b : tools::max_value(); // arbitrary large value if the logs would fail! + if((l3 < tools::log_max_value()) + && (l3 > tools::log_min_value())) + {