OSDN Git Service

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