]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/tgamma.3
a64l.3, addseverity.3, argz_add.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name...
[thirdparty/man-pages.git] / man3 / tgamma.3
1 .\" Copyright 2002 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
2 .\" %%%LICENSE_START(GPL_NOVERSION_ONELINE)
3 .\" Distributed under GPL
4 .\" %%%LICENSE_END
5 .\" Based on glibc infopages
6 .\" and Copyright 2008, Linux Foundation, written by Michael Kerrisk
7 .\" <mtk.manpages@gmail.com>
8 .\" Modified 2004-11-15, fixed error noted by Fabian Kreutz
9 .\" <kreutz@dbs.uni-hannover.de>
10 .TH TGAMMA 3 2010-09-20 "GNU" "Linux Programmer's Manual"
11 .SH NAME
12 tgamma, tgammaf, tgammal \- true gamma function
13 .SH SYNOPSIS
14 .B #include <math.h>
15 .sp
16 .BI "double tgamma(double " x );
17 .br
18 .BI "float tgammaf(float " x );
19 .br
20 .BI "long double tgammal(long double " x );
21 .sp
22 Link with \fI\-lm\fP.
23 .sp
24 .in -4n
25 Feature Test Macro Requirements for glibc (see
26 .BR feature_test_macros (7)):
27 .in
28 .sp
29 .ad l
30 .BR tgamma (),
31 .BR tgammaf (),
32 .BR tgammal ():
33 .RS 4
34 _XOPEN_SOURCE\ >=\ 600 || _ISOC99_SOURCE ||
35 _POSIX_C_SOURCE\ >=\ 200112L;
36 .br
37 or
38 .I cc\ -std=c99
39 .RE
40 .ad
41 .SH DESCRIPTION
42 The Gamma function is defined by
43 .sp
44 Gamma(x) = integral from 0 to infinity of t^(x\-1) e^\-t dt
45 .sp
46 It is defined for every real number except for nonpositive integers.
47 For nonnegative integral \fIm\fP one has
48 .sp
49 Gamma(m+1) = m!
50 .sp
51 and, more generally, for all \fIx\fP:
52 .sp
53 Gamma(x+1) = x * Gamma(x)
54 .sp
55 Furthermore, the following is valid for all values of \fIx\fP
56 outside the poles:
57 .sp
58 Gamma(x) * Gamma(1 \- x) = PI / sin(PI * x)
59 .PP
60 .SH RETURN VALUE
61 On success, these functions return Gamma(x).
62
63 If
64 .I x
65 is a NaN, a NaN is returned.
66
67 If
68 .I x
69 is positive infinity, positive infinity is returned.
70
71 If
72 .I x
73 is a negative integer, or is negative infinity,
74 a domain error occurs,
75 and a NaN is returned.
76
77 If the result overflows,
78 a range error occurs,
79 and the functions return
80 .BR HUGE_VAL ,
81 .BR HUGE_VALF ,
82 or
83 .BR HUGE_VALL ,
84 respectively, with the correct mathematical sign.
85
86 If the result underflows,
87 a range error occurs,
88 and the functions return 0, with the correct mathematical sign.
89
90 If
91 .I x
92 is \-0 or +0,
93 a pole error occurs,
94 and the functions return
95 .BR HUGE_VAL ,
96 .BR HUGE_VALF ,
97 or
98 .BR HUGE_VALL ,
99 respectively, with the same sign as the 0.
100 .SH ERRORS
101 See
102 .BR math_error (7)
103 for information on how to determine whether an error has occurred
104 when calling these functions.
105 .PP
106 The following errors can occur:
107 .TP
108 Domain error: \fIx\fP is a negative integer, or negative infinity
109 .\" FIXME . errno is not set to EDOM for x == -inf
110 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6809
111 .I errno
112 is set to
113 .BR EDOM .
114 An invalid floating-point exception
115 .RB ( FE_INVALID )
116 is raised (but see BUGS).
117 .TP
118 Pole error: \fIx\fP is +0 or \-0
119 .I errno
120 is set to
121 .BR ERANGE .
122 A divide-by-zero floating-point exception
123 .RB ( FE_DIVBYZERO )
124 is raised.
125 .TP
126 Range error: result overflow
127 .I errno
128 is set to
129 .BR ERANGE .
130 An overflow floating-point exception
131 .RB ( FE_OVERFLOW )
132 is raised.
133 .PP
134 glibc also gives the following error which is not specified
135 in C99 or POSIX.1-2001.
136 .TP
137 Range error: result underflow
138 .\" e.g., tgamma(-172.5) on glibc 2.8/x86-32
139 .\" .I errno
140 .\" is set to
141 .\" .BR ERANGE .
142 An underflow floating-point exception
143 .RB ( FE_UNDERFLOW )
144 is raised.
145 .IP
146 .I errno
147 is not set for this case.
148 .\" FIXME . Is it intentional that errno is not set:
149 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6810
150 .\"
151 .\" glibc (as at 2.8) also supports and an inexact
152 .\" exception for various cases.
153 .SH VERSIONS
154 These functions first appeared in glibc in version 2.1.
155 .SH CONFORMING TO
156 C99, POSIX.1-2001.
157 .SH NOTES
158 This function had to be called "true gamma function"
159 since there is already a function
160 .BR gamma (3)
161 that returns something else (see
162 .BR gamma (3)
163 for details).
164 .SH BUGS
165 If
166 .I x
167 is negative infinity,
168 .I errno
169 is not set (it should be set to
170 .BR EDOM ).
171 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6809
172
173 In glibc versions 2.3.3 and earlier,
174 an argument of +0 or \-0 incorrectly produced a domain error
175 .RI ( errno
176 set to
177 .B EDOM
178 and an
179 .B FE_INVALID
180 exception raised), rather than a pole error.
181 .SH SEE ALSO
182 .BR gamma (3),
183 .BR lgamma (3)