I'm implementing an arbitrary precision arithmetic library in C++ and I'm pretty much stuck when implementing the gamma function.
By using the equivalences gamma(n) = gamma(n - 1) * n
and gamma(n) = gamma(n + 1) / n
, respectively, I can obtain a rational number r
in the range (1; 2]
for all real values x
.
However, I don't know how to evaluate gamma(r)
. For the Lanczos approximation (https://en.wikipedia.org/wiki/Lanczos_approximation), I need precomputed values p which happen to calculate a factorial of a non-integer value (?!) and can't be calculated dynamically with my current knowledge... Precomputing values for p wouldn't make much sense when implementing an arbitrary precision library.
Are there any algorithms that compute gamma(r)
in a reasonable amount of time with arbitrary precision? Thanks for your help.