Last modified: December 2020

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


AHELP for CIAO 4.13 Sherpa v1

gamma

Context: utilities

Synopsis

Calculate the Gamma function.

Syntax

gamma(z)

z - scalar or array

Examples

Example 1

>>> gamma(2.3)
1.1667119051981603

Example 2

>>> gamma([2.3,1.9])
array([ 1.16671191,  0.96176583])

PARAMETERS

The parameter for this function is:

Parameter Definition
z -171 <= z <- 171.6

Return value

The return value from this function is:

val -- The gamma function of the input.

Notes

This implementation is provided by the Cephes Math Library [1] . Arguments |x| >= 34 are reduced by recurrence and the function approximated by a rational function of degree 6/7 in the interval (2,3). Large arguments are handled by Stirling's formula. Large negative arguments are made positive using a reflection formula.

Relative errors are

domain # trials peak rms
-170,33 20000 2.3e-15 3.3e-16
-33,33 20000 9.4e-16 2.2e-16
33,171.6 20000 2.3e-15 3.2e-16

Errors for arguments outside the test range will be larger owing to amplification by the exponential function.

References


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, igam, igamc, incbet, lgam