Calculate the log (base e) of the Gamma function.
z (scalar or array) – 0 <= z <= 2.556348e305
val – The log of the Gamma function of the input.
- Return type:
scalar or array
This implementation is provided by the Cephes Math Library . For arguments greater than 13, the logarithm of the Gamma function is approximated by the logarithmic version of Stirling’s formula using a polynomial approximation of degree 4. Arguments between -33 and +33 are reduced by recurrence to the interval [2,3] of a rational approximation. The cosecant reflection formula is employed for arguments less than -33.
Relative errors are
The error criterion was relative when the function magnitude was greater than one but absolute when it was less than one.
The following test used the relative error criterion, though at certain points the relative error could be much higher than indicated.
>>> lgam(104.56) 380.21387239435785
>>> lgam([104.56,2823.4]) array([ 380.21387239, 19607.42734396])