this repo has no description
1.\" Copyright (c) 1985, 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\" notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\" notice, this list of conditions and the following disclaimer in the
11.\" documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\" must display the following acknowledgement:
14.\" This product includes software developed by the University of
15.\" California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\" may be used to endorse or promote products derived from this software
18.\" without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\" from: @(#)erf.3 6.4 (Berkeley) 4/20/91
33.\" $Id: tgamma.3,v 1.4 2004/12/20 21:35:46 scp Exp $
34.\"
35.Dd July 02, 2008
36.Dt TGAMMA 3
37.Sh NAME
38.Nm tgamma ,
39.Nm lgamma ,
40.Nm gamma
41.Nd gamma and log of gamma
42.Sh SYNOPSIS
43.Fd #include <math.h>
44.Ft double
45.Fn tgamma "double x"
46.Ft long double
47.Fn tgammal "long double x"
48.Ft float
49.Fn tgammaf "float x"
50.Ft double
51.Fn lgamma_r "double x, int *psigngam"
52.Ft long double
53.Fn lgammal_r "long double x, int *psigngam"
54.Ft float
55.Fn lgammaf_r "float x, int *psigngam"
56.Ft double
57.Fn lgamma "double x"
58.Ft long double
59.Fn lgammal "long double x"
60.Ft float
61.Fn lgammaf "float x"
62.Sh DESCRIPTION
63.Fn tgamma
64calculates the gamma function of x.
65.Fn lgamma
66calculates the natural logorithm of the absolute value of the gamma function of x.
67.Fn gamma
68is the same function as tgamma. Its use is deprecated.
69.Pp
70.Fn lgamma_r
71is a thread-safe alternative to
72.Fn lgamma .
73Instead of setting the global variable
74.Fa signgam ,
75it stores the sign of Gamma(x) in the location pointed to by its second argument.
76In order to use the
77.Fn lgamma_r
78function, define the macro _REENTRANT before including <math.h>.
79.Sh SPECIAL VALUES
80.Fn tgamma "�0"
81returns �infinity and raises the "divide-by-zero" floating-point exception.
82.Pp
83.Fn tgamma "x"
84returns a NaN and raises the "invalid" floating-point exception if x is a negative integer.
85.Pp
86.Fn tgamma "-infinity"
87returns a NaN and raises the "invalid" floating-point exception.
88.Pp
89.Fn tgamma "+infinity"
90returns +infinity.
91.Pp
92.Fn tgamma "x"
93generates a domain error if x is a negative integer or if the result cannnot be respresented when x is 0.
94.Pp
95A range error may occur if the magnitude of x is too large or too small.
96.Pp
97.Fn lgamma "1"
98returns +0.
99.Pp
100.Fn lgamma "2"
101returns +0.
102.Pp
103.Fn lgamma "x"
104returns +infinity and raises the "divide-by-zero" floating-point exception if x is a negative integer or 0.
105.Pp
106.Fn lgamma "�infinity"
107returns +infinity.
108.Pp
109.Fn lgamma "x"
110generates a range error if x is too large.
111.Pp
112A range error may occur if x is a negative integer or 0.
113.Sh NOTE
114.Fn lgamma "x"
115and its variants have the (non-threadsafe) side-effect of setting the global variable
116.Fa signgam
117to �1, equal to the sign of
118.Fn tgamma "x" .
119.Fn lgamma_r "x, psigngam"
120instead sets the user-allocated integer pointed to by the
121.Fa psigngam
122argument.
123.Pp
124.Fn gamma
125and
126.Fn gamma_r
127are deprecated, and should not be used. The
128.Fn tgamma
129function should be used instead. Note, however, that on some platforms,
130.Fn gamma
131and
132.Fn gamma_r
133historically computed the log of the Gamma function, instead of the Gamma function
134itself. When porting code from such platforms, it will be necessary to use
135.Fn lgamma
136or
137.Fn lgamma_r
138instead.
139.Sh SEE ALSO
140.Xr math 3
141.Sh STANDARDS
142The
143.Fn tgamma
144, and
145.Fn lgamma
146functions conform to ISO/IEC 9899:1999(E).