Last modified: December 2023

URL: https://cxc.cfa.harvard.edu/sherpa/ahelp/lgam.html
Jump to: · Examples · PARAMETERS · Notes · References · Bugs · See Also


AHELP for CIAO 4.16 Sherpa

lgam

Context: utilities

Synopsis

Calculate the log (base e) of the Gamma function.

Syntax

lgam(z)

z - scalar or array

Examples

Example 1

>>> lgam(104.56)
380.21387239435785

Example 2

>>> lgam([104.56,2823.4])
array([   380.21387239,  19607.42734396])

PARAMETERS

The parameter for this function is:

Parameter Definition
z 0 <= z <= 2.556348e305

Return value

The return value from this function is:

val -- The log of the Gamma function of the input.

Notes

This implementation is provided by the Cephes Math Library [1] . 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

domain # trials peak rms
0,3 28000 5.4e-16 1.1e-16
2.718,2.556e305 40000 3.5e-16 8.3e-17

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.

domain # trials peak rms
-200,-4 10000 4.8e-16 1.3e-16

References


Bugs

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

See Also

tools::response
color_color, modelflux
tools::statistics
aprates
utilities
calc_chisqr, calc_energy_flux, calc_model_sum, calc_photon_flux, calc_source_sum, calc_stat, gamma, igam, igamc, incbet