1TGAMMA(3) Linux Programmer's Manual TGAMMA(3)
2
3
4
6 tgamma, tgammaf, tgammal - true gamma function
7
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 _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE ||
21 _POSIX_C_SOURCE >= 200112L;
22 or cc -std=c99
23
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
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
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
88 errno is not set for this case.
89
91 These functions first appeared in glibc in version 2.1.
92
94 C99, POSIX.1-2001.
95
97 This function had to be called "true gamma function" since there is
98 already a function gamma(3) that returns something else (see gamma(3)
99 for details).
100
102 If x is negative infinity, errno is not set (it should be set to EDOM).
103
104 In glibc versions 2.3.3 and earlier, an argument of +0 or -0 incor‐
105 rectly produced a domain error (errno set to EDOM and an FE_INVALID
106 exception raised), rather than a pole error.
107
109 gamma(3), lgamma(3)
110
112 This page is part of release 3.53 of the Linux man-pages project. A
113 description of the project, and information about reporting bugs, can
114 be found at http://www.kernel.org/doc/man-pages/.
115
116
117
118GNU 2010-09-20 TGAMMA(3)