Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

This question already has an answer here:

how to calculate gamma function in programming language? I also need to support complex numbers (complex numbers are in the programming language) and negative numbers. thank you :)

share|improve this question
2  
Any particular programming language you have in mind ... ? –  Zev Chonoles Mar 1 '13 at 5:04
    
C#, maybe C++. complex is class in those. –  Lior Mar 1 '13 at 5:05
    
not for complex! –  Lior Mar 1 '13 at 5:10
add comment

marked as duplicate by MJD, Trevor Wilson, Stefan Hansen, Jim, Ittay Weiss Mar 1 '13 at 7:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

Try the Lanczos approximation.

share|improve this answer
    
what is "$g$"?<br> what is "$p_n$"?<br> @rlgordonma –  Lior Mar 1 '13 at 12:42
    
@Lior: $g$ can be any real number, but is selected for optimum accuracy with as few terms as possible. In the Python code, they choose $g=7.0$. The $p_n$ are the coefficients defined in the article and are precomputed in the Python code for $g=7.0$. –  Ron Gordon Mar 1 '13 at 13:19
    
how to define $p_n(x)$? –  Lior Mar 1 '13 at 13:42
    
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.