3
$\begingroup$

Earlier, I asked a question on MathOverflow regarding how one might analytically approximate a function of the form: $f(n) = \prod_{i=1}^{n-1} (1-ai)$ for $a \ge 0$, $(ai) < 1$, and $n > 10^5$ or $10^6$. Robert Israel answered the question in a very nice way, observing that:

$f(n) = \dfrac{a^{n-1} \Gamma(1/a)}{\Gamma(1-n+1/a)}$

...and that one could use Stirling's series for an asymptotic approximation of $\ln(\Gamma(1-n+ 1/a))$.


My question here is: how might one actually compute values for this function (using, for example, Mathematica) for very large $n$ ($n > 10^9$ or so) and very small $a$ ($a < 10^{-30}$), without overflows/underflows, provided that the known output for $f(n)$ falls in the range of, say, $10^{-12} \le f(n) \le 1$? Are there any simple strategies for achieving this?

1 Answers 1

1

Since this is a common problem many software implemented a lngamma function.
In the case of Mathematica it is named LogGamma[].

If this fails you may use an expansion of $\ln(\Gamma(x))$. You may find these at Wikipedia.

Of course once the LogGamma obtained you shouldn't compute directly the exponential ! Instead evaluate the $\log$ of the complete expression and take the exponential of the (simplified) result.

  • 1
    @Roger, `With[{n = 10^6, a = 10^-30}, Block[{$MaxExtraPrecision = 60}, N[(n - 1) Log[a] + LogGamma[1/a] - LogGamma[1 - n + 1/a], 25]]]`2012-08-16