Algorithm to compute Gamma function The question is simple. I would like to implement the Gamma function in my calculator written in C; however, I have not been able to find an easy way to programmatically compute an approximation to arbitrary precision.
Is there a good algorithm to compute approximations of the Gamma function?
Thanks!
 A: It is now part of the C++11 standard library.
http://en.cppreference.com/w/cpp/numeric/math/tgamma
A: Someone asked a similar question yesterday. I thought of replacing $e^{-t}$ by a series.
$$\Gamma (z) = \int_{0}^{\infty} t^{z-1} e^{-t} dt \approx \sum_{j=0}^{a} \frac{(-1)^j b^{j+z}}{(j + z) j !} . \text{Choose } a > b ,$$ but as J. M. points out, I should have checked this a bit better. Take great care in the choice of $a, b$.
A: Try Nemes' approximation:
$$\ln ( \Gamma( x ) ) = \frac12 \ln( 2 \pi ) + \left( x - \frac12 \right) \ln( x ) - x + \frac x2  
                       \ln\left( x \sinh\left( \frac1x \right) + \frac 1 {810 x^6} \right) $$
The last term, $\dfrac1 { 810 x^6}$ is an error-checking term and may be eliminated from your calculations.
Here is my reference.
A: Looks like the Lanczos approximation will suit my needs : 
http://en.wikipedia.org/wiki/Lanczos_approximation
Thanks for your help!
A: How about interpolation of the numbers in a look-up table featuring numbers drawn from a graph of the curve you are looking for?
If you have the program Stella, you can literally shape by hand a curve that you desire, and it produces the numbers to be added to the table.
