1tgamma(3) Library Functions Manual tgamma(3)
2
3
4
6 tgamma, tgammaf, tgammal - true gamma function
7
9 Math library (libm, -lm)
10
12 #include <math.h>
13
14 double tgamma(double x);
15 float tgammaf(float x);
16 long double tgammal(long double x);
17
18 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20 tgamma(), tgammaf(), tgammal():
21 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
22
24 These functions calculate the Gamma function of x.
25
26 The Gamma function is defined by
27
28 Gamma(x) = integral from 0 to infinity of t^(x-1) e^-t dt
29
30 It is defined for every real number except for nonpositive integers.
31 For nonnegative integral m one has
32
33 Gamma(m+1) = m!
34
35 and, more generally, for all x:
36
37 Gamma(x+1) = x * Gamma(x)
38
39 Furthermore, the following is valid for all values of x outside the
40 poles:
41
42 Gamma(x) * Gamma(1 - x) = PI / sin(PI * x)
43
45 On success, these functions return Gamma(x).
46
47 If x is a NaN, a NaN is returned.
48
49 If x is positive infinity, positive infinity is returned.
50
51 If x is a negative integer, or is negative infinity, a domain error oc‐
52 curs, and a NaN is returned.
53
54 If the result overflows, a range error occurs, and the functions return
55 HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct math‐
56 ematical sign.
57
58 If the result underflows, a range error occurs, and the functions re‐
59 turn 0, with the correct mathematical sign.
60
61 If x is -0 or +0, a pole error occurs, and the functions return
62 HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the same sign as
63 the 0.
64
66 See math_error(7) for information on how to determine whether an error
67 has occurred when calling these functions.
68
69 The following errors can occur:
70
71 Domain error: x is a negative integer, or negative infinity
72 errno is set to EDOM. An invalid floating-point exception
73 (FE_INVALID) is raised (but see BUGS).
74
75 Pole error: x is +0 or -0
76 errno is set to ERANGE. A divide-by-zero floating-point excep‐
77 tion (FE_DIVBYZERO) is raised.
78
79 Range error: result overflow
80 errno is set to ERANGE. An overflow floating-point exception
81 (FE_OVERFLOW) is raised.
82
83 glibc also gives the following error which is not specified in C99 or
84 POSIX.1-2001.
85
86 Range error: result underflow
87 An underflow floating-point exception (FE_UNDERFLOW) is raised,
88 and errno is set to ERANGE.
89
91 For an explanation of the terms used in this section, see at‐
92 tributes(7).
93
94 ┌────────────────────────────────────────────┬───────────────┬─────────┐
95 │Interface │ Attribute │ Value │
96 ├────────────────────────────────────────────┼───────────────┼─────────┤
97 │tgamma(), tgammaf(), tgammal() │ Thread safety │ MT-Safe │
98 └────────────────────────────────────────────┴───────────────┴─────────┘
99
101 C11, POSIX.1-2008.
102
104 glibc 2.1. C99, POSIX.1-2001.
105
107 This function had to be called "true gamma function" since there is al‐
108 ready a function gamma(3) that returns something else (see gamma(3) for
109 details).
110
112 Before glibc 2.18, the glibc implementation of these functions did not
113 set errno to EDOM when x is negative infinity.
114
115 Before glibc 2.19, the glibc implementation of these functions did not
116 set errno to ERANGE on an underflow range error.
117
118 In glibc versions 2.3.3 and earlier, an argument of +0 or -0 incorrect‐
119 ly produced a domain error (errno set to EDOM and an FE_INVALID excep‐
120 tion raised), rather than a pole error.
121
123 gamma(3), lgamma(3)
124
125
126
127Linux man-pages 6.04 2023-03-30 tgamma(3)