%mathpiper,def="Gamma"

/////////////////////////////////////////////////
/// Euler's Gamma function
////////////////////////////////////////////////////
/// Serge Winitzki

/// User visible functions: Gamma(x), LnGamma(x)

5 # Gamma(Infinity)	<-- Infinity;

10 # Gamma(_n)_(IsInteger(n) And n<=0) <-- Infinity;


20 # Gamma(n_IsRationalOrNumber)_(IsPositiveInteger(n) Or FloatIsInt(2*n)) <-- (Round(2*n)/2-1)!;


30 # Gamma(x_IsConstant)_(InNumericMode()) <-- Internal'GammaNum(N(Eval(x)));


%/mathpiper



%mathpiper_docs,name="Gamma",categories="User Functions;Special Functions"
*CMD Gamma --- Euler's Gamma function
*STD
*CALL
	Gamma(x)

*PARMS

{x} -- expression

{number} -- expression that can be evaluated to a number

*DESC

{Gamma(x)} is an interface to Euler's Gamma function $Gamma(x)$. It returns exact values on integer and half-integer arguments. {N(Gamma(x)} takes a numeric parameter and always returns a floating-point number in the current precision.

Note that Euler's constant $gamma<=>0.57722$ is the lowercase {gamma} in MathPiper.

*E.G.

In> Gamma(1.3)
Result: Gamma(1.3);
In> N(Gamma(1.3),30)
Result: 0.897470696306277188493754954771;
In> Gamma(1.5)
Result: Sqrt(Pi)/2;
In> N(Gamma(1.5),30);
Result: 0.88622692545275801364908374167;

*SEE !, N, gamma
%/mathpiper_docs