Debian Codegraph @

upstream/debian-unstable/man3/tgamma.3

raw
1 '\" t
2 .\" Copyright 2002, Walter Harms <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: GPL-1.0-or-later
6 .\"
7 .TH tgamma 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 tgamma, tgammaf, tgammal \- true gamma function
10 .SH LIBRARY
11 Math library
12 .RI ( libm ,\~ \-lm )
13 .SH SYNOPSIS
14 .nf
15 .B #include <math.h>
16 .P
17 .BI "double tgamma(double " x );
18 .BI "float tgammaf(float " x );
19 .BI "long double tgammal(long double " x );
20 .fi
21 .P
22 .RS -4
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
25 .RE
26 .P
27 .BR tgamma (),
28 .BR tgammaf (),
29 .BR tgammal ():
30 .nf
31 _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
32 .fi
33 .SH DESCRIPTION
34 These functions calculate the Gamma function of
35 .IR x .
36 .P
37 The Gamma function is defined by
38 .P
39 .RS
40 Gamma(x) = integral from 0 to infinity of t\[ha](x\-1) e\[ha]\-t dt
41 .RE
42 .P
43 It is defined for every real number except for nonpositive integers.
44 For nonnegative integral
45 .I m
46 one has
47 .P
48 .RS
49 Gamma(m+1) = m!
50 .RE
51 .P
52 and, more generally, for all
53 .IR x :
54 .P
55 .RS
56 Gamma(x+1) = x * Gamma(x)
57 .RE
58 .P
59 Furthermore, the following is valid for all values of
60 .I x
61 outside the poles:
62 .P
63 .RS
64 Gamma(x) * Gamma(1 \- x) = PI / sin(PI * x)
65 .RE
66 .SH RETURN VALUE
67 On success, these functions return Gamma(x).
68 .P
69 If
70 .I x
71 is a NaN, a NaN is returned.
72 .P
73 If
74 .I x
75 is positive infinity, positive infinity is returned.
76 .P
77 If
78 .I x
79 is a negative integer, or is negative infinity,
80 a domain error occurs,
81 and a NaN is returned.
82 .P
83 If the result overflows,
84 a range error occurs,
85 and the functions return
86 .BR HUGE_VAL ,
87 .BR HUGE_VALF ,
88 or
89 .BR HUGE_VALL ,
90 respectively, with the correct mathematical sign.
91 .P
92 If the result underflows,
93 a range error occurs,
94 and the functions return 0, with the correct mathematical sign.
95 .P
96 If
97 .I x
98 is \-0 or +0,
99 a pole error occurs,
100 and the functions return
101 .BR HUGE_VAL ,
102 .BR HUGE_VALF ,
103 or
104 .BR HUGE_VALL ,
105 respectively, with the same sign as the 0.
106 .SH ERRORS
107 See
108 .BR math_error (7)
109 for information on how to determine whether an error has occurred
110 when calling these functions.
111 .P
112 The following errors can occur:
113 .TP
114 Domain error: \f[I]x\f[] is a negative integer, or negative infinity
115 .I errno
116 is set to
117 .BR EDOM .
118 An invalid floating-point exception
119 .RB ( FE_INVALID )
120 is raised (but see BUGS).
121 .TP
122 Pole error: \f[I]x\f[] is +0 or \-0
123 .I errno
124 is set to
125 .BR ERANGE .
126 A divide-by-zero floating-point exception
127 .RB ( FE_DIVBYZERO )
128 is raised.
129 .TP
130 Range error: result overflow
131 .I errno
132 is set to
133 .BR ERANGE .
134 An overflow floating-point exception
135 .RB ( FE_OVERFLOW )
136 is raised.
137 .P
138 glibc also gives the following error which is not specified
139 in C99 or POSIX.1-2001.
140 .TP
141 Range error: result underflow
142 .\" e.g., tgamma(-172.5) on glibc 2.8/x86-32
143 .\" .I errno
144 .\" is set to
145 .\" .BR ERANGE .
146 An underflow floating-point exception
147 .RB ( FE_UNDERFLOW )
148 is raised, and
149 .I errno
150 is set to
151 .BR ERANGE .
152 .\" glibc (as at 2.8) also supports an inexact
153 .\" exception for various cases.
154 .SH ATTRIBUTES
155 For an explanation of the terms used in this section, see
156 .BR attributes (7).
157 .TS
158 allbox;
159 lbx lb lb
160 l l l.
161 Interface Attribute Value
162 T{
163 .na
164 .nh
165 .BR tgamma (),
166 .BR tgammaf (),
167 .BR tgammal ()
168 T} Thread safety MT-Safe
169 .TE
170 .SH STANDARDS
171 C11, POSIX.1-2008.
172 .SH HISTORY
173 glibc 2.1.
174 C99, POSIX.1-2001.
175 .SH NOTES
176 This function had to be called "true gamma function"
177 since there is already a function
178 .BR gamma (3)
179 that returns something else (see
180 .BR gamma (3)
181 for details).
182 .SH BUGS
183 Before glibc 2.18, the glibc implementation of these functions did not set
184 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6809
185 .I errno
186 to
187 .B EDOM
188 when
189 .I x
190 is negative infinity.
191 .P
192 Before glibc 2.19,
193 .\" https://www.sourceware.org/bugzilla/show_bug.cgi?id=6810
194 the glibc implementation of these functions did not set
195 .I errno
196 to
197 .B ERANGE
198 on an underflow range error.
199 .P
200 .\"
201 In glibc versions 2.3.3 and earlier,
202 an argument of +0 or \-0 incorrectly produced a domain error
203 .RI ( errno
204 set to
205 .B EDOM
206 and an
207 .B FE_INVALID
208 exception raised), rather than a pole error.
209 .SH SEE ALSO
210 .BR gamma (3),
211 .BR lgamma (3)