Gamma Function
Returns Gamma(X) using a Series Expansion for 1/Gamma (X) as defined in Abramowitz & Stegun.

Unit
QESBPCSMath

Declaration
Function Gamma(const X: Extended): Extended;

Description
Defined for all values of X except negative integers and 0.

Accuracy: Gives about 15 digits.

Parameters
Value to process.

Category
Arithmetic Routines for Floats

Implementation

function Gamma (const X: Extended): Extended;
var
     Z: Extended;
begin
     if FloatIsZero (X) or (FloatIsNegative (X) and SameFloat (X, Int (X))) then
          raise EMathError.Create (rsNotDefinedForValue);

     Z := InverseGamma (X);

     if FloatIsZero (Z) then
          raise EMathError.Create (rsNotDefinedForValue);

     Result := 1 / Z;
End;


HTML generated by Time2HELP
http://www.time2help.com