Initial import from FreeBSD RELENG_4:
[dragonfly.git] / lib / msun / man / lgamma.3
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.7.2.6 2003/01/04 01:01:29 jdp Exp $
34 .\"
35 .Dd December 3, 1992
36 .Dt LGAMMA 3
37 .Os
38 .Sh NAME
39 .Nm lgamma ,
40 .Nm lgammaf ,
41 .Nm gamma ,
42 .Nm gammaf
43 .Nd log gamma functions, gamma functions
44 .Sh LIBRARY
45 .Lb libm
46 .Sh SYNOPSIS
47 .In math.h
48 .Ft extern int
49 .Fa signgam ;
50 .sp
51 .Ft double
52 .Fn lgamma "double x"
53 .Ft float
54 .Fn lgammaf "float x"
55 .Ft double
56 .Fn gamma "double x"
57 .Ft float
58 .Fn gammaf "float x"
59 .Sh DESCRIPTION
60 .Fn lgamma x
61 and
62 .Fn lgammaf x
63 .if t \{\
64 return ln\||\(*G(x)| where
65 .Bd -unfilled -offset indent
66 \(*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
67 .br
68 \(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1.
69 .Ed
70 .\}
71 .if n \
72 return ln\||\(*G(x)|.
73 .Pp
74 The external integer
75 .Fa signgam
76 returns the sign of \(*G(x).
77 .Pp
78 .Fn gamma
79 and
80 .Fn gammaf
81 are deprecated aliases for
82 .Fn lgamma
83 and
84 .Fn lgammaf ,
85 respectively.
86 .Sh IDIOSYNCRASIES
87 Do not use the expression
88 .Dq Li signgam\(**exp(lgamma(x))
89 to compute g := \(*G(x).
90 Instead use a program like this (in C):
91 .Bd -literal -offset indent
92 lg = lgamma(x); g = signgam\(**exp(lg);
93 .Ed
94 .Pp
95 Only after
96 .Fn lgamma
97 or
98 .Fn lgammaf
99 has returned can signgam be correct.
100 .\".Pp
101 .\"For arguments in its range,
102 .\".Fn gamma
103 .\"is preferred, as for positive arguments
104 .\"it is accurate to within one unit in the last place.
105 .\"Exponentiation of
106 .\".Fn lgamma
107 .\"will lose up to 10 significant bits.
108 .Sh RETURN VALUES
109 .Fn gamma ,
110 .Fn gammaf ,
111 .Fn lgamma ,
112 and
113 .Fn lgammaf
114 return appropriate values unless an argument is out of range.
115 Overflow will occur for sufficiently large positive values, and
116 non-positive integers.
117 On the
118 .Tn VAX ,
119 the reserved operator is returned,
120 and
121 .Va errno
122 is set to
123 .Er ERANGE .
124 \."For large non-integer negative values,
125 \.".Fn gamma
126 \."will underflow.
127 .Sh SEE ALSO
128 .Xr math 3
129 .Sh HISTORY
130 The
131 .Fn lgamma
132 function appeared in
133 .Bx 4.3 .
134 The
135 .Fn gamma
136 function appeared in
137 .Bx 4.4
138 as a function which computed \(*G(x).
139 This version was used in
140 .Fx 1.1 .
141 The name
142 .Fn gamma
143 was originally dedicated to the
144 .Fn lgamma
145 function,
146 and that usage was restored by switching to Sun's fdlibm in
147 .Fx 1.1.5 .
148 The
149 .St -isoC-99
150 standard specifies a function
151 .Fn tgamma
152 for computing \(*G(x).
153 This function is currently unimplemented in this library.