Chandra X-Ray Observatory
	(CXC)
Skip to the navigation links
Last modified: December 2013

URL: http://cxc.harvard.edu/sherpa/ahelp/lgam.html
Jump to: Description · Examples · Bugs · See Also


AHELP for CIAO 4.9 Sherpa v1

lgam

Context: utilities

Synopsis

Calculate the log of the Gamma function

Syntax

lgam(z)

Description

Calculate the CEPHES function, lgam, in the range [0 <= z <= MAXLGM]. The function returns the base e (2.718...) logarithm of the absolute value of the Gamma function of the argument (scalar or array).

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.

Relative error:

arithmetic domain # trials peak rms
DEC 0, 3 7000 5.2e-17 1.3e-17
DEC 2.718, 2.035e36 5000 3.9e-17 9.9e-18
IEEE 0, 3 28000 5.4e-16 1.1e-16
IEEE 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.

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

Reference

Cephes Math Library Release 2.0: April, 1987. Copyright 1985, 1987 by Stephen L. Moshier. Direct inquiries to 30 Frost Street, Cambridge, MA 02140.

Example 1

sherpa> lgam(3.14)

Calculate the lgam of 3.14.

Example 2

sherpa> lgam([3.14,2.71])

Calculate the lgam of the array [3.14,2.71].

Bugs

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

See Also

tools
aprates, modelflux
utilities
calc_chisqr, calc_energy_flux, calc_model_sum, calc_photon_flux, calc_source_sum, calc_stat, gamma, igam, igamc, incbet

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email:   cxchelp@head.cfa.harvard.edu Smithsonian Institution, Copyright © 1998-2017. All rights reserved.