naginterfaces.library.specfun.gamma

naginterfaces.library.specfun.gamma(x)[source]

gamma returns the value of the gamma function .

For full information please refer to the NAG Library document for s14aa

https://www.nag.com/numeric/nl/nagdoc_28.5/flhtml/s/s14aaf.html

Parameters
xfloat

The argument of the function.

Returns
gxfloat

The value of the gamma function .

Raises
NagValueError
(errno )

On entry, .

Constraint: .

The argument is too large, the function returns the approximate value of at the nearest valid argument.

(errno )

On entry, . The function returns zero.

Constraint: .

The argument is too large and negative, the function returns zero.

Warns
NagAlgorithmicWarning
(errno )

On entry, .

Constraint: .

The argument is too close to zero, the function returns the approximate value of at the nearest valid argument.

(errno )

On entry, .

Constraint: must not be a negative integer.

The argument is a negative integer, at which values is infinite. The function returns a large positive value.

Notes

gamma evaluates an approximation to the gamma function . The function is based on the Chebyshev expansion:

where and uses the property . If where is integral and then it follows that:

for ,

,

for ,

,

for ,

.

There are four possible failures for this function:

  1. if is too large, there is a danger of overflow since could become too large to be represented in the machine;

  2. if is too large and negative, there is a danger of underflow;

  3. if is equal to a negative integer, would overflow since it has poles at such points;

  4. if is too near zero, there is again the danger of overflow on some machines. For small , , and on some machines there exists a range of nonzero but small values of for which is larger than the greatest representable value.

References

NIST Digital Library of Mathematical Functions