• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: @(#)lgamma.3	6.6 (Berkeley) 12/3/92
33.\" $FreeBSD: src/lib/msun/man/lgamma.3,v 1.22 2005/01/16 16:46:14 ru Exp $
34.\"
35.Dd January 14, 2005
36.Dt LGAMMA 3
37.Os
38.Sh NAME
39.Nm lgamma ,
40.Nm lgamma_r ,
41.Nm lgammaf ,
42.Nm lgammaf_r ,
43.Nm gamma ,
44.Nm gamma_r ,
45.Nm gammaf ,
46.Nm gammaf_r ,
47.Nm tgamma
48.Nd log gamma functions, gamma function
49.Sh LIBRARY
50.Lb libm
51.Sh SYNOPSIS
52.In math.h
53.Ft extern int
54.Fa signgam ;
55.sp
56.Ft double
57.Fn lgamma "double x"
58.Ft double
59.Fn lgamma_r "double x" "int *signgamp"
60.Ft float
61.Fn lgammaf "float x"
62.Ft float
63.Fn lgammaf_r "float x" "int *signgamp"
64.Ft double
65.Fn gamma "double x"
66.Ft double
67.Fn gamma_r "double x" "int *signgamp"
68.Ft float
69.Fn gammaf "float x"
70.Ft float
71.Fn gammaf_r "float x" "int *signgamp"
72.Ft double
73.Fn tgamma "double x"
74.Sh DESCRIPTION
75.Fn lgamma x
76and
77.Fn lgammaf x
78.if t \{\
79return ln\||\(*G(x)| where
80.Bd -unfilled -offset indent
81\(*G(x) = \(is\d\s8\z0\s10\u\u\s8\(if\s10\d t\u\s8x\-1\s10\d e\u\s8\-t\s10\d dt	for x > 0 and
82\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px))	for x < 1.
83.Ed
84.\}
85.if n \
86return ln\||\(*G(x)|.
87.Pp
88The external integer
89.Fa signgam
90returns the sign of \(*G(x).
91.Pp
92.Fn lgamma_r x signgamp
93and
94.Fn lgammaf_r x signgamp
95provide the same functionality as
96.Fn lgamma x
97and
98.Fn lgammaf x
99but the caller must provide an integer to store the sign of \(*G(x).
100.Pp
101.Fn gamma ,
102.Fn gammaf ,
103.Fn gamma_r ,
104and
105.Fn gammaf_r
106are deprecated aliases for
107.Fn lgamma ,
108.Fn lgammaf ,
109.Fn lgamma_r ,
110and
111.Fn lgammaf_r ,
112respectively.
113.Fn tgamma x
114returns \(*G(x), with no effect on
115.Fa signgam .
116.Sh IDIOSYNCRASIES
117Do not use the expression
118.Dq Li signgam\(**exp(lgamma(x))
119to compute g := \(*G(x).
120Instead use a program like this (in C):
121.Bd -literal -offset indent
122lg = lgamma(x); g = signgam\(**exp(lg);
123.Ed
124.Pp
125Only after
126.Fn lgamma
127or
128.Fn lgammaf
129has returned can signgam be correct.
130.Pp
131For arguments in its range,
132.Fn tgamma
133is preferred, as for positive arguments
134it is accurate to within one unit in the last place.
135Exponentiation of
136.Fn lgamma
137will lose up to 10 significant bits.
138.Sh RETURN VALUES
139.Fn gamma ,
140.Fn gamma_r ,
141.Fn gammaf ,
142.Fn gammaf_r ,
143.Fn lgamma ,
144.Fn lgamma_r ,
145.Fn lgammaf ,
146and
147.Fn lgammaf_r
148return appropriate values unless an argument is out of range.
149Overflow will occur for sufficiently large positive values, and
150non-positive integers.
151For large non-integer negative values,
152.Fn tgamma
153will underflow.
154.Sh SEE ALSO
155.Xr math 3
156.Sh STANDARDS
157The
158.Fn lgamma
159and
160.Fn tgamma
161functions are expected to conform to
162.St -isoC-99 .
163.Sh HISTORY
164The
165.Fn lgamma
166function appeared in
167.Bx 4.3 .
168The
169.Fn gamma
170function appeared in
171.Bx 4.4
172as a function which computed \(*G(x).
173This version was used in
174.Fx 1.1 .
175The name
176.Fn gamma
177was originally dedicated to the
178.Fn lgamma
179function,
180and that usage was restored by switching to Sun's fdlibm in
181.Fx 1.1.5 .
182The
183.Fn tgamma
184function appeared in
185.Fx 5.0 .
186