Several formulas can approximate the gamma function on the complex domain, but all of them have issues. Please, look at its plot before starting. Nonetheless, there is a trick that makes them all work; and you must find it (I've lost some time trying different formulas, adding more terms, but it is not the way to go).
I've found a 1968-paper by Wrench, Concerning Two Series for the Gamma Function, which gives us the 20th first terms of one formula for instance. https://www.ams.org/journals/mcom/1968-22-103/S0025-5718-1968-0237078-4/ (It would be more than enough if there weren't issues with all approximations.)
A clever and simple approach to deal with the pitfalls in the test suite. It can be easily extended to deal with other problematic values of the argument.
It took me a while to realize the same thing...
Find the two most distant points
vectorization in N
Determine the square root
Integer Sequence - II : New Fibonacci
Find MPG of Lightest Cars
Set the Euler-Mascheroni constant with an identity using available MATLAB functions
Compute expulsions from the Kimberling shuffle
Investigate the frequency of last non-zero digits of primorials
List ways to reach a target sum
Solve the arithmetic differential equation D(n) = n
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office