OSDN Git Service

Update README
[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 2014-12-31 "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 .I errno
117 is set to
118 .BR EDOM .
119 An invalid floating-point exception
120 .RB ( FE_INVALID )
121 is raised (but see BUGS).
122 .TP
123 Pole error: \fIx\fP is +0 or \-0
124 .I errno
125 is set to
126 .BR ERANGE .
127 A divide-by-zero floating-point exception
128 .RB ( FE_DIVBYZERO )
129 is raised.
130 .TP
131 Range error: result overflow
132 .I errno
133 is set to
134 .BR ERANGE .
135 An overflow floating-point exception
136 .RB ( FE_OVERFLOW )
137 is raised.
138 .PP
139 glibc also gives the following error which is not specified
140 in C99 or POSIX.1-2001.
141 .TP
142 Range error: result underflow
143 .\" e.g., tgamma(-172.5) on glibc 2.8/x86-32
144 .\" .I errno
145 .\" is set to
146 .\" .BR ERANGE .
147 An underflow floating-point exception
148 .RB ( FE_UNDERFLOW )
149 is raised.
150 .IP
151 .I errno
152 is not set for this case.
153 .\" FIXME . Is it intentional that errno is not set:
154 .\" Bug raised: http://sources.redhat.com/bugzilla/show_bug.cgi?id=6810
155 .\"
156 .\" glibc (as at 2.8) also supports and an inexact
157 .\" exception for various cases.
158 .SH VERSIONS
159 These functions first appeared in glibc in version 2.1.
160 .SH CONFORMING TO
161 C99, POSIX.1-2001.
162 .SH NOTES
163 This function had to be called "true gamma function"
164 since there is already a function
165 .BR gamma (3)
166 that returns something else (see
167 .BR gamma (3)
168 for details).
169 .SH BUGS
170 Before version 2.18, the glibc implementation of these functions did not set
171 .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=6809
172 .I errno
173 to
174 .B EDOM
175 when
176 .I x
177 is negative infinity.
178
179 In glibc versions 2.3.3 and earlier,
180 an argument of +0 or \-0 incorrectly produced a domain error
181 .RI ( errno
182 set to
183 .B EDOM
184 and an
185 .B FE_INVALID
186 exception raised), rather than a pole error.
187 .SH SEE ALSO
188 .BR gamma (3),
189 .BR lgamma (3)
190 .SH COLOPHON
191 This page is part of release 3.79 of the Linux
192 .I man-pages
193 project.
194 A description of the project,
195 information about reporting bugs,
196 and the latest version of this page,
197 can be found at
198 \%http://www.kernel.org/doc/man\-pages/.