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$ 34.\" 35.Dd December 3, 1992 36.Dt LGAMMA 3 37.Os 38.Sh NAME 39.Nm lgamma , 40.Nm lgamma_r , 41.Nm lgammaf , 42.Nm lgammaf_r , 43.Nm gamma , 44.Nm gamma_r , 45.Nm gammaf , 46.Nm gammaf_r , 47.Nm tgamma 48.Nd log gamma functions, gamma function 49.Sh LIBRARY 50.Lb libm 51.Sh SYNOPSIS 52.In math.h 53.Ft extern int 54.Fa signgam ; 55.sp 56.Ft double 57.Fn lgamma "double x" 58.Ft double 59.Fn lgamma_r "double x" "int *signgamp" 60.Ft float 61.Fn lgammaf "float x" 62.Ft float 63.Fn lgammaf_r "float x" "int *signgamp" 64.Ft double 65.Fn gamma "double x" 66.Ft double 67.Fn gamma_r "double x" "int *signgamp" 68.Ft float 69.Fn gammaf "float x" 70.Ft float 71.Fn gammaf_r "float x" "int *signgamp" 72.Ft double 73.Fn tgamma "double x" 74.Sh DESCRIPTION 75.Fn lgamma x 76and 77.Fn lgammaf x 78.if t \{\ 79return ln\||\(*G(x)| where 80.Bd -unfilled -offset indent 81\(*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 82.br 83\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. 84.Ed 85.\} 86.if n \ 87return ln\||\(*G(x)|. 88.Pp 89The external integer 90.Fa signgam 91returns the sign of \(*G(x). 92.Pp 93.Fn lgamma_r x signgamp 94and 95.Fn lgammaf_r x signgamp 96provide the same functionality as 97.Fn lgamma x 98and 99.Fn lgammaf x 100but the caller must provide an integer to store the sign of \(*G(x). 101.Pp 102.Fn gamma , 103.Fn gammaf , 104.Fn gamma_r , 105and 106.Fn gammaf_r 107are deprecated aliases for 108.Fn lgamma , 109.Fn lgammaf , 110.Fn lgamma_r , 111and 112.Fn lgammaf_r , 113respectively. 114.Fn tgamma x 115returns \(*G(x), with no effect on 116.Fa signgam . 117.Sh IDIOSYNCRASIES 118Do not use the expression 119.Dq Li signgam\(**exp(lgamma(x)) 120to compute g := \(*G(x). 121Instead use a program like this (in C): 122.Bd -literal -offset indent 123lg = lgamma(x); g = signgam\(**exp(lg); 124.Ed 125.Pp 126Only after 127.Fn lgamma 128or 129.Fn lgammaf 130has returned can signgam be correct. 131.Pp 132For arguments in its range, 133.Fn tgamma 134is preferred, as for positive arguments 135it is accurate to within one unit in the last place. 136Exponentiation of 137.Fn lgamma 138will lose up to 10 significant bits. 139.Sh RETURN VALUES 140.Fn gamma , 141.Fn gamma_r , 142.Fn gammaf , 143.Fn gammaf_r , 144.Fn lgamma , 145.Fn lgamma_r , 146.Fn lgammaf , 147and 148.Fn lgammaf_r 149return appropriate values unless an argument is out of range. 150Overflow will occur for sufficiently large positive values, and 151non-positive integers. 152On the 153.Tn VAX , 154the reserved operator is returned, 155and 156.Va errno 157is set to 158.Er ERANGE . 159For large non-integer negative values, 160.Fn tgamma 161will underflow. 162.Sh SEE ALSO 163.Xr math 3 164.Sh STANDARDS 165The 166.Fn lgamma 167and 168.Fn tgamma 169functions are expected to conform to 170.St -isoC-99 . 171.Sh HISTORY 172The 173.Fn lgamma 174function appeared in 175.Bx 4.3 . 176The 177.Fn gamma 178function appeared in 179.Bx 4.4 180as a function which computed \(*G(x). 181This version was used in 182.Fx 1.1 . 183The name 184.Fn gamma 185was originally dedicated to the 186.Fn lgamma 187function, 188and that usage was restored by switching to Sun's fdlibm in 189.Fx 1.1.5 . 190The 191.Fn tgamma 192function appeared in 193.Fx 5.0 . 194