1TGAMMA(3)                  Linux Programmer's Manual                 TGAMMA(3)
2
3
4

NAME

6       tgamma, tgammaf, tgammal - true gamma function
7

SYNOPSIS

9       #include <math.h>
10
11       double tgamma(double x);
12       float tgammaf(float x);
13       long double tgammal(long double x);
14
15       Link with -lm.
16
17   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19       tgamma(), tgammaf(), tgammal():
20           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
21

DESCRIPTION

23       These functions calculate the Gamma function of x.
24
25       The Gamma function is defined by
26
27              Gamma(x) = integral from 0 to infinity of t^(x-1) e^-t dt
28
29       It  is  defined  for every real number except for nonpositive integers.
30       For nonnegative integral m one has
31
32              Gamma(m+1) = m!
33
34       and, more generally, for all x:
35
36              Gamma(x+1) = x * Gamma(x)
37
38       Furthermore, the following is valid for all values  of  x  outside  the
39       poles:
40
41              Gamma(x) * Gamma(1 - x) = PI / sin(PI * x)
42

RETURN VALUE

44       On success, these functions return Gamma(x).
45
46       If x is a NaN, a NaN is returned.
47
48       If x is positive infinity, positive infinity is returned.
49
50       If  x  is  a  negative integer, or is negative infinity, a domain error
51       occurs, and a NaN is returned.
52
53       If the result overflows, a range error occurs, and the functions return
54       HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct math‐
55       ematical sign.
56
57       If the result underflows, a  range  error  occurs,  and  the  functions
58       return 0, with the correct mathematical sign.
59
60       If  x  is  -0  or  +0,  a  pole  error occurs, and the functions return
61       HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the same sign  as
62       the 0.
63

ERRORS

65       See  math_error(7) for information on how to determine whether an error
66       has occurred when calling these functions.
67
68       The following errors can occur:
69
70       Domain error: x is a negative integer, or negative infinity
71              errno is set  to  EDOM.   An  invalid  floating-point  exception
72              (FE_INVALID) is raised (but see BUGS).
73
74       Pole error: x is +0 or -0
75              errno  is set to ERANGE.  A divide-by-zero floating-point excep‐
76              tion (FE_DIVBYZERO) is raised.
77
78       Range error: result overflow
79              errno is set to ERANGE.  An  overflow  floating-point  exception
80              (FE_OVERFLOW) is raised.
81
82       glibc  also  gives the following error which is not specified in C99 or
83       POSIX.1-2001.
84
85       Range error: result underflow
86              An underflow floating-point exception (FE_UNDERFLOW) is  raised,
87              and errno is set to ERANGE.
88

VERSIONS

90       These functions first appeared in glibc in version 2.1.
91

ATTRIBUTES

93       For   an   explanation   of   the  terms  used  in  this  section,  see
94       attributes(7).
95
96       ┌───────────────────────────────┬───────────────┬─────────┐
97Interface                      Attribute     Value   
98       ├───────────────────────────────┼───────────────┼─────────┤
99tgamma(), tgammaf(), tgammal() │ Thread safety │ MT-Safe │
100       └───────────────────────────────┴───────────────┴─────────┘

CONFORMING TO

102       C99, POSIX.1-2001, POSIX.1-2008.
103

NOTES

105       This function had to be called "true gamma  function"  since  there  is
106       already  a  function gamma(3) that returns something else (see gamma(3)
107       for details).
108

BUGS

110       Before version 2.18, the glibc implementation of  these  functions  did
111       not set errno to EDOM when x is negative infinity.
112
113       Before  glibc 2.19, the glibc implementation of these functions did not
114       set errno to ERANGE on an underflow range error.  x
115
116       In glibc versions 2.3.3 and earlier, an argument of  +0  or  -0  incor‐
117       rectly  produced  a  domain  error (errno set to EDOM and an FE_INVALID
118       exception raised), rather than a pole error.
119

SEE ALSO

121       gamma(3), lgamma(3)
122

COLOPHON

124       This page is part of release 5.07 of the Linux  man-pages  project.   A
125       description  of  the project, information about reporting bugs, and the
126       latest    version    of    this    page,    can     be     found     at
127       https://www.kernel.org/doc/man-pages/.
128
129
130
131GNU                               2017-09-15                         TGAMMA(3)
Impressum