Skip to content

Unexpected exception from hypergeometric_pFq({a}, {b}, x) when x is large. #1404

Description

@WarrenWeckesser

I'm exercising hypergeometric_pFq with this code:

#include <string>
#include <iostream>
#include <iomanip>
#include <boost/math/special_functions/hypergeometric_pFq.hpp>

using namespace boost::math;


int main(int argc, char *argv[])
{
    if (argc != 4 ) {
        printf("use: hyppfq a b x\n");
        return -1;
    }

    double a = std::stod(argv[1]);
    double b = std::stod(argv[2]);
    double x = std::stod(argv[3]);

    double y = hypergeometric_pFq({a}, {b}, x);
    std::cout << "pFq = " << std::scientific << std::setw(25)
        << std::setprecision(17) << y << std::endl;

    return 0;
}

Normal case:

$ ./hyppfq 2 3 10.0
pFq =   3.96478384306520911e+03

Overflow exception (working as expected):

$ ./hyppfq 2 3 10000.0
terminate called after throwing an instance of 'std::overflow_error'
  what():  Error in function boost::math::hypergeometric_pFq<double>(double,double,double): numeric overflow
Aborted (core dumped)

When the third argument is much larger, the exception boost::math::rounding_error is thrown when the code attempts to convert something to an integer:

$ ./hyppfq 2 3 10000000000.0
terminate called after throwing an instance of 'boost::math::rounding_error'
  what():  Error in function boost::math::itrunc<long double>(long double): Value 9999999999 can not be represented in the target integer type.

I would expect this case to throw std::overflow_error as in the previous example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions