1LGAMMA(3M)                                                          LGAMMA(3M)
2
3
4

NAME

6       lgamma - log gamma function
7

SYNOPSIS

9       #include <math.h>
10
11       double lgamma(x)
12       double x;
13

DESCRIPTION

15       Lgamma returns ln|Γ(x)|.
16
17       The external integer signgam returns the sign of Γ(x) .
18

IDIOSYNCRASIES

20       Do  not use the expression signgam∗exp(lgamma(x)) to compute g := Γ(x).
21       Instead use a program like this (in C):
22              lg = lgamma(x); g = signgam∗exp(lg);
23
24       Only after lgamma has returned can signgam be correct.  Note  too  that
25       Γ(x)  must  overflow when x is large enough, underflow when -x is large
26       enough, and spawn a division by zero when x is a nonpositive integer.
27
28       Only in the UNIX math library for C was the name gamma ever attached to
29       lnΓ.   Elsewhere, for instance in IBM's FORTRAN library, the name GAMMA
30       belongs to Γ and the name ALGAMA to lnΓ in single precision; in  double
31       the names are DGAMMA and DLGAMA.  Why should C be different?
32
33       Archaeological  records  suggest  that  C's  gamma originally delivered
34       ln(Γ(|x|)).  Later, the program gamma was changed to cope with negative
35       arguments  x  in a more conventional way, but the documentation did not
36       reflect that change correctly.  The most recent change corrects inaccu‐
37       rate  values when x is almost a negative integer, and lets Γ(x) be com‐
38       puted without conditional expressions.  Programmers should  not  assume
39       that lgamma has settled down.
40
41       At  some  time  in the future, the name gamma will be rehabilitated and
42       used for the gamma function, just as is done in  FORTRAN.   The  reason
43       for  this  is  not  so  much  compatibility with FORTRAN as a desire to
44       achieve greater speed for smaller values of |x|  and  greater  accuracy
45       for larger values.
46
47       Meanwhile,  programmers  who  have  to use the name gamma in its former
48       sense, for what is now lgamma, have two choices:
49
50       1) Use the old math library, libom.
51
52       2) Add the following program to your others:
53          #include <math.h>
54          double gamma(x)
55          double x;
56          {
57                 return (lgamma(x));
58          }
59

DIAGNOSTICS

61       The reserved operand is returned on a VAX for  negative  integer  argu‐
62       ments, errno is set to ERANGE; for very large arguments over/underflows
63       will occur inside the lgamma routine.
64

SEE ALSO

66       math(3M), infnan(3M)
67
68
69
704.3 Berkeley Distribution        May 12, 1986                       LGAMMA(3M)
Impressum