BSD 4_3_Net_2 release
[unix-history] / usr / src / lib / libm / common_source / lgamma.3
index 97c9ef1..761769e 100644 (file)
-.\" Copyright (c) 1985 Regents of the University of California.
-.\" All rights reserved.  The Berkeley software License Agreement
-.\" specifies the terms and conditions for redistribution.
+.\" Copyright (c) 1985, 1991 Regents of the University of California.
+.\" All rights reserved.
 .\"
 .\"
-.\"    @(#)lgamma.3    6.2 (Berkeley) %G%
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 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.
 .\"
 .\"
-.TH LGAMMA 3M  ""
-.UC 6
-.SH NAME
-lgamma \- log gamma function
-.SH SYNOPSIS
-.nf
-.B #include <math.h>
-.PP
-.B double lgamma(x)
-.B double x;
-.fi
-.SH DESCRIPTION
-.nf
+.\" 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
+.\" SUCH DAMAGE.
+.\"
+.\"     @(#)lgamma.3   6.4 (Berkeley) 5/6/91
+.\"
+.Dd May 6, 1991
+.Dt LGAMMA 3
+.Os BSD 4.3
+.Sh NAME
+.Nm lgamma
+.Nd log gamma function
+.Sh SYNOPSIS
+.Fd #include <math.h>
+.Ft double
+.Fn lgamma "double x"
+.Sh DESCRIPTION
 .ta \w'Lgamma returns ln\||\(*G(x)| where'u+1n +1.7i
 .if t \{\
 .ta \w'Lgamma returns ln\||\(*G(x)| where'u+1n +1.7i
 .if t \{\
-Lgamma returns ln\||\(*G(x)| where     \(*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
+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
 .br
 .br
-       \(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1.  \}
+\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px))        for x < 1.  \}
+.Ed
 .if n \
 Lgamma returns ln\||\(*G(x)|.
 .ta
 .if n \
 Lgamma returns ln\||\(*G(x)|.
 .ta
-.fi
-.PP
-The external integer signgam returns the sign of
+.Pp
+The external integer
+.Fa signgam
+returns the sign of
 \(*G(x) .
 \(*G(x) .
-.SH IDIOSYNCRASIES
-Do \fBnot\fR use the expression signgam\(**exp(lgamma(x))
+.Sh IDIOSYNCRASIES
+Do
+.Em not
+use the expression
+.Dq Li signgam\(**exp(lgamma(x))
 to compute g := \(*G(x).  Instead use a program like this (in C):
 to compute g := \(*G(x).  Instead use a program like this (in C):
-.RS
+.Bd -literal -offset indent
 lg = lgamma(x); g = signgam\(**exp(lg);
 lg = lgamma(x); g = signgam\(**exp(lg);
-.RE
-.PP
-Only after lgamma has returned can signgam be correct.
+.Ed
+.Pp
+Only after
+.Fn lgamma
+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.
 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.
-.PP
-Only in the UNIX math library for C was the name gamma ever attached
-to ln\(*G.  Elsewhere, for instance in IBM's FORTRAN library, the name
-GAMMA belongs to \(*G and the name ALGAMA to ln\(*G in single precision;
-in double the names are DGAMMA and DLGAMA.  Why should C be different?
-.PP
-Archaeological records suggest that C's gamma originally delivered
+.Pp
+Only in the
+.Tn UNIX
+math library for C was the name gamma ever attached
+to ln\(*G.  Elsewhere, for instance in
+.Tn IBM Ns 's
+.Tn FORTRAN
+library, the name
+.Tn GAMMA
+belongs to \(*G and the name
+.Tn ALGAMA
+to ln\(*G in single precision;
+in double the names are
+.Tn DGAMMA
+and
+.Tn DLGAMA .
+Why should C be different?
+.Pp
+Archaeological records suggest that C's
+.Em gamma
+originally delivered
 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
 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
-lgamma has settled down.
-.PP
-At some time in the future, the name \fIgamma\fR will be rehabilitated
-and used for the gamma function, just as is done in FORTRAN.
-The reason for this is not so much compatibility with FORTRAN as a
+.Fn lgamma
+has settled down.
+.Pp
+At some time in the future, the name
+.Em gamma
+will be rehabilitated
+and used for the gamma function, just as is done in
+.Tn FORTRAN .
+The reason for this is not so much compatibility with
+.Tn FORTRAN
+as a
 desire to achieve greater speed for smaller values of |x| and greater
 accuracy for larger values.
 desire to achieve greater speed for smaller values of |x| and greater
 accuracy for larger values.
-.PP
-Meanwhile, programmers who have to use the name \fIgamma\fR in its former
-sense, for what is now \fIlgamma\fR, have two choices:
-.IP 1) \w'1)\0'u
-Use the old math library, \fIlibom\fR.
-.IP 2) \w'1)\0'u
+.Pp
+Meanwhile, programmers who have to use the name
+.Em gamma
+in its former
+sense, for what is now
+.Fn lgamma ,
+have two choices:
+.Bl -enum -width indent
+.It
+Use the old math library,
+.Pa libom .
+.It
 Add the following program to your others:
 Add the following program to your others:
-.RS
-.nf
-\fB#include <math.h>
+.Bd -literal -offset indent
+#include <math.h>
 double gamma(x)
 double x;
 {
 double gamma(x)
 double x;
 {
-.RS
-\fBreturn (lgamma(x));
-.RE
-}\fR
-.RE
-.fi
-.SH DIAGNOSTICS
-The reserved operand is returned on a VAX for negative integer arguments,
-\fIerrno\fR is set to ERANGE; for very large arguments over/underflows will
-occur inside the \fIlgamma\fP routine.
-.SH SEE ALSO
-math(3M), infnan(3M)
+       return (lgamma(x));
+}
+.Ed
+.Sh DIAGNOSTICS
+The reserved operand is returned on a
+.Tn VAX
+for negative integer arguments,
+.Va errno
+is set to
+.Er ERANGE ;
+for very large arguments over/underflows will
+occur inside the
+.Fn lgamma
+routine.
+.Sh SEE ALSO
+.Xr math 3 ,
+.Xr infnan 3
+.Sh HISTORY
+The
+.Nm
+function appeared in 
+.Bx 4.3 .