Calculate the gamma function in a program

284 Views Asked by At

I am currently trying to implement the gamma function in a program I am writing. I know that the gamma function is: $$\Gamma(\alpha) = \int\limits_{0}^{\infty}x^{\alpha - 1}e^{-x}\text{ d}x$$

However, I do not know what the $\int$, the ${x}$, and the ${d}$ are supposed to stand for.

I know that you can do it quite easily with positive integers like this:

$$\Gamma(\alpha) = (a -1)!$$ How would I go about implementing that into a program for numbers other than positive integers?

1

There are 1 best solutions below

2
On

My suggestion would be to take a look at SymPy's implementation of the Gamma Function:

enter image description here

The full implementation considers numerical integral arguments, half-integral values and it is publicly available at this GitHub Page.