flintlib / arb

Arb has been merged into FLINT -- use https://github.com/flintlib/flint/ instead
http://arblib.org/
GNU Lesser General Public License v2.1
455 stars 137 forks source link

avoid asymptotic expansion for the upper incomplete gamma function under some conditions #323

Closed p15-git-acc closed 4 years ago

p15-git-acc commented 4 years ago

This pull request improves the implementation of acb_hypgeom_gamma_upper by no longer dispatching to acb_hypgeom_gamma_upper_asymp under certain conditions when doing so can be predetermined to give an uninformative result (nan +/- inf). The improvement is particularly noticeable when s is large compared to z and to the number of bits of working precision.

The shaded region of this figure shows where z is too close to the origin for the asymptotic expansion to work, and the scale of that region depends on s. The old code uses the asymptotic expansion when z is outside a disk whose radius is proportional to the working precision, without taking s into account. The new code adds a condition requiring z to also be outside of the shaded region.

This PR does not address the transition region problems when z is near the boundary of the shaded region.

There was a typo on line https://github.com/fredrik-johansson/arb/blob/master/acb_hypgeom/u_asymp.c#L73 where if (R == 0) should be if (*R == 0). It looked scary but I'm pretty sure its effects were masked.

fredrik-johansson commented 4 years ago

Looks reasonable, thanks.