.\" Copyright (c) 1985, 1991 Regents of the University of California.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)lgamma.3 6.4 (Berkeley) 5/6/91
.ta \w'Lgamma returns ln\||\(*G(x)| where'u+1n +1.7i
Lgamma returns ln\||\(*G(x)| where
.Bd -unfilled -offset indent
\(*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
\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. \}
Lgamma returns ln\||\(*G(x)|.
.Dq Li signgam\(**exp(lgamma(x))
to compute g := \(*G(x). Instead use a program like this (in C):
.Bd -literal -offset indent
lg = lgamma(x); g = signgam\(**exp(lg);
has returned can signgam be correct.
Note too that \(*G(x) must overflow when x is large enough,
underflow when \-x is large enough, and spawn a division by zero
when x is a nonpositive integer.
math library for C was the name gamma ever attached
to ln\(*G. Elsewhere, for instance in
belongs to \(*G and the name
to ln\(*G in single precision;
Why should C be different?
Archaeological records suggest that C's
ln(\(*G(|x|)). Later, the program gamma was changed to
cope with negative arguments x in a more conventional way, but
the documentation did not reflect that change correctly. The most
recent change corrects inaccurate values when x is almost a
negative integer, and lets \(*G(x) be computed without
conditional expressions. Programmers should not assume that
At some time in the future, the name
and used for the gamma function, just as is done in
The reason for this is not so much compatibility with
desire to achieve greater speed for smaller values of |x| and greater
accuracy for larger values.
Meanwhile, programmers who have to use the name
Use the old math library,
Add the following program to your others:
.Bd -literal -offset indent
The reserved operand is returned on a
for negative integer arguments,
for very large arguments over/underflows will