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

Inconsistent behavior of ibeta_inv(a, b, x) with nan input #878

Closed
WarrenWeckesser opened this issue Nov 14, 2022 · 1 comment
Closed

Inconsistent behavior of ibeta_inv(a, b, x) with nan input #878

WarrenWeckesser opened this issue Nov 14, 2022 · 1 comment

Comments

@WarrenWeckesser
Copy link
Contributor

WarrenWeckesser commented Nov 14, 2022

I don't know if this qualifies as a bug, or is undefined behavior as far as boost/math is concerned, but I get three different behaviors from ibeta_inv(nan, 2, 0.5), ibeta_inv(2, nan, 0.5) and ibeta_inv(2, 2, nan):

  • ibeta_inv(nan, 2, 0.5) does not raise an exception; nan is returned.

  • ibeta_inv(2, nan, 0.5) raises:

    ibeta_inv: /home/warren/repos/git/forks/boost/math/include/boost/math/special_functions/beta.hpp:723:
    T boost::math::detail::ibeta_fraction2(T, T, T, T, const Policy&, bool, T*)
    [with T = long double; Policy = boost::math::policies::policy<boost::math::policies::promote_float<false>, boost::math::policies::promote_double<false>, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy>]:
    Assertion `*p_derivative >= 0' failed.
    
  • ibeta_inv(2, 2, nan) raises:

    terminate called after throwing an instance of 'boost::wrapexcept<boost::math::rounding_error>'
    what():  Error in function boost::math::trunc<long double>(long double):
    Value nan can not be represented in the target integer type.
    
@jzmaddock
Copy link
Collaborator

I would say it's a bug, and should probably raise a domain error in all 3 cases. Will investigate.

AZero13 pushed a commit to AZero13/math that referenced this issue Jan 19, 2023
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

No branches or pull requests

2 participants