Debian Codegraph @

upstream/debian-trixie/man3/tgamma.3

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