Use the following HTML code to embed the calculators within other websites:
Log Gamma Stirling
doublelog_gamma_stirling(
double
x
int*
sign = NULL
)
The logarithm of the gamma function is sometimes treated as a special function to avoid additional
'branch cut' stuctures that are introduced by the logarithm function (see http://mathworld.wolfram.com/LogGammaFunction.html )
The log-gamma function can be defined by
The function returns the base e (2.718...) logarithm of the absolute value of the gamma function of the argument.
The sign (+1 or -1) of the gamma function is returned in a global (extern) variable named sgngam.
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.
Arguments greater than MAXLGM return MAXNUM and an error message. MAXLGM = 2.035093e36 for DEC arithmetic
or 2.556348e305 for IEEE arithmetic.
Accuracy:
<pre>
domain # trials peak rms
0, 3 28000 5.4e-16 1.1e-16
2.718, 2.556e305 40000 3.5e-16 8.3e-17
</pre>
The error criterion was relative when the function magnitude was greater than one but absolute when it was less than one.