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(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE;
20 or cc -std=c99
21
23 The Gamma function is defined by
24
25 Gamma(x) = integral from 0 to infinity of t^(x-1) e^-t dt
26
27 It is defined for every real number except for non-positive integers.
28 For non-negative integral m one has
29
30 Gamma(m+1) = m!
31
32 and, more generally, for all x:
33
34 Gamma(x+1) = x * Gamma(x)
35
36 Furthermore, the following is valid for all values of x outside the
37 poles:
38
39 Gamma(x) * Gamma(1 - x) = PI / sin(PI * x)
40
42 On success, these functions return Gamma(x).
43
44 If x is a NaN, a NaN is returned.
45
46 If x is positive infinity, positive infinity is returned.
47
48 If x is a negative integer, or is negative infinity, a domain error
49 occurs, and a NaN is returned.
50
51 If the result overflows, a range error occurs, and the functions return
52 HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct math‐
53 ematical sign.
54
55 If the result underflows, a range error occurs, and the functions
56 return 0, with the correct mathematical sign.
57
58 If x is -0 or +0, a pole error occurs, and the functions return
59 HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the same sign as
60 the 0.
61
63 See math_error(7) for information on how to determine whether an error
64 has occurred when calling these functions.
65
66 The following errors can occur:
67
68 Domain error: x is a negative integer, or negative infinity
69 errno is set to EDOM. An invalid floating-point exception
70 (FE_INVALID) is raised (but see BUGS).
71
72 Pole error: x is +0 or -0
73 errno is set to ERANGE. A divide-by-zero floating-point excep‐
74 tion (FE_DIVBYZERO) is raised.
75
76 Range error: result overflow
77 errno is set to ERANGE. An overflow floating-point exception
78 (FE_OVERFLOW) is raised.
79
80 glibc also gives the following error which is not specified in C99 or
81 POSIX.1-2001.
82
83 Range error: result underflow
84 An underflow floating-point exception (FE_UNDERFLOW) is raised.
85
86 errno is not set for this case.
87
89 These functions first appeared in glibc in version 2.1.
90
92 C99, POSIX.1-2001.
93
95 This function had to be called "true gamma function" since there is
96 already a function gamma(3) that returns something else (see gamma(3)
97 for details).
98
100 If x is negative infinity, errno is not set (it should be set to EDOM).
101
102 In glibc versions 2.3.3 and earlier, an argument of +0 or -0 incor‐
103 rectly produced a domain error (errno set to EDOM and an FE_INVALID
104 exception raised), rather than a pole error.
105
107 gamma(3), lgamma(3)
108
110 This page is part of release 3.22 of the Linux man-pages project. A
111 description of the project, and information about reporting bugs, can
112 be found at http://www.kernel.org/doc/man-pages/.
113
114
115
116GNU 2008-08-11 TGAMMA(3)