flintlib / flint

FLINT (Fast Library for Number Theory)
http://www.flintlib.org
GNU Lesser General Public License v3.0
401 stars 235 forks source link

arb_hypgeom_beta_lower gives weird results #1979

Closed Mostafa86 closed 1 month ago

Mostafa86 commented 1 month ago
arb_t res;
arb_t aa;
arb_t bb;
arb_t zz;

arb_init(res);
arb_init(aa);
arb_init(bb);
arb_init(zz);

arb_set_str(aa, "17.24094565", 200);
arb_set_str(bb, "294.4532014", 200);
arb_set_str(zz, "0.5", 200);

arb_hypgeom_beta_lower(res, aa, bb, zz, 1, 200);

arb_printd(res, 10);
printf("\n");

results in

nan +/- +inf

Wolfram Alpha result

fredrik-johansson commented 1 month ago

It does work if one sets the precision a bit higher.

It ought to work to work at this precision too, using the integration algorithm, but currently arb_hypgeom_2f1_integration doesn't accept these particular parameters.

One way to fix it would be to express the incomplete beta function using a different 2F1 formula (https://functions.wolfram.com/GammaBetaErf/Beta3/26/01/ShowAll.html) depending on the parameters.

Or arb_hypgeom_2f1_integration could try to implement a suitable fractional linear transformations. This fix would be more general.