# Is it possible to circumvent this overflow?

I'm trying to evaluate the following function numerically:

$f(A,B)=\frac{2A\pi ^{5/2} (-1)^B}{(A!)^2B!} \, _4\tilde{F}_3\left({\frac{1}{2},1-A,1-A,1-B\atop \frac{1}{2}-A,\frac{1}{2}-A,\frac{1}{2}-B}\bigg| 1\right)$

By construction, $0\leq f(A,B)\leq 1$ as long as A and B are positive integers. My problem is that the values of A and B that I need are quite large powers of 2 (in the ballpark of $2^{100}$, possibly larger and not too different, like $A=2^{103},\ B=2^{97}$). The problem is that the regularized Hypergeometric function returns very large values and the computation eventually overflows/undeflows already at $2^{50}$ on my system.

Of course, on paper these large values of the numerator are taken care of by the factorials in the denominator, but Mathematica seems to deal with the numerator and the denominator independently, which is what causes the overflow.

Is anyone aware of a trick that I can use? At the moment the best I can do is to feed approximated values to the function (e.g. 2.^40. rather than 2^40), but while this speeds up the evaluation it does not stop the overflow/undeflow. I could use Stirling's approximation of the denominator, but I don't know what to do with the numerator.

EDIT: for completeness, this is the code I'm using, with memoization (The Re is to avoid small spurious imaginary components creeping up in the numerical evaluation):

f[A_, B_] :=  f[A, B] =
Re[(2 A (-1)^B Pi^2.5
HypergeometricPFQRegularized[{1/2, 1 - A, 1 - A, 1 - B},
{1/2 - A, 1/2 - A, 1/2 - B}, 1])/(B! (A!)^2)]

• Including Mathematica code will often help you get an answer sooner or better. – Mr.Wizard Feb 18 '15 at 16:55
• Yes you are right, although the code in this case is simply the MMA version of the definition. But I will add it now. – Ziofil Feb 18 '15 at 16:57
• With what runtimes are you dealing with? I am running your code on $A=2^{103}$ and $B=2^{97}$ since approximately 30min now with no result (or error) yet. – Jinxed Feb 18 '15 at 17:30
• this may be more of a math.stackexchange.com question. – george2079 Feb 18 '15 at 17:30
• @Jinxed, may as well abort, it will certainly overflow just because of the factorials. – george2079 Feb 18 '15 at 17:37