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.\" $Id: lgamma.3,v 1.1.1.1 1994/08/19 09:39:42 jkh Exp $ 34.\" 35.Dd December 3, 1992 36.Dt LGAMMA 3 37.Os BSD 4.3 38.Sh NAME 39.Nm lgamma , 40.Nm lgammaf , 41.Nm gamma , 42.Nm gammaf 43.Nd log gamma functions, gamma functions 44.Sh SYNOPSIS 45.Fd #include <math.h> 46.Ft extern int 47.Fa signgam ; 48.sp 49.Ft double 50.Fn lgamma "double x" 51.Ft float 52.Fn lgammaf "float x" 53.Ft double 54.Fn gamma "double x" 55.Ft float 56.Fn gamma "float x" 57.Sh DESCRIPTION 58.Fn lgamma x 59and 60.Fn lgammaf x 61.if t \{\ 62return ln\||\(*G(x)| where 63.Bd -unfilled -offset indent 64\(*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 65.br 66\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. 67.Ed 68.\} 69.if n \ 70returns ln\||\(*G(x)|. 71.Pp 72The external integer 73.Fa signgam 74returns the sign of \(*G(x). 75.Pp 76.Fn gamma x 77and 78.Fn gammaf x 79return \(*G(x), with no effect on 80.Fa signgam . 81.Sh IDIOSYNCRASIES 82Do not use the expression 83.Dq Li signgam\(**exp(lgamma(x)) 84to compute g := \(*G(x). 85Instead use a program like this (in C): 86.Bd -literal -offset indent 87lg = lgamma(x); g = signgam\(**exp(lg); 88.Ed 89.Pp 90Only after 91.Fn lgamma 92or 93.Fn lgammaf 94has returned can signgam be correct. 95.Pp 96For arguments in its range, 97.Fn gamma 98and 99.Fn gammaf 100is preferred, as for positive arguments 101it is accurate to within one unit in the last place. 102Exponentiation of 103.Fn lgamma 104will lose up to 10 significant bits. 105.Sh RETURN VALUES 106.Fn gamma , 107.Fn gammaf , 108.Fn lgamma , 109and 110.Fn lgammaf 111return appropriate values unless an argument is out of range. 112Overflow will occur for sufficiently large positive values, and 113non-positive integers. 114On the 115.Tn VAX, 116the reserved operator is returned, 117and 118.Va errno 119is set to 120.Er ERANGE 121For large non-integer negative values, 122.Fn gamma 123will underflow. 124.Sh SEE ALSO 125.Xr math 3 , 126.Xr infnan 3 127.Sh HISTORY 128The 129.Nm lgamma 130function appeared in 131.Bx 4.3 . 132The 133.Nm gamma 134function appeared in 135.Bx 4.4 . 136The name 137.Fn gamma 138was originally dedicated to the 139.Fn lgamma 140function, so some old code may no longer be compatible. 141