149230Scael.\" Copyright (c) 1985, 1991 Regents of the University of California. 248378Scael.\" All rights reserved. 324694Smckusick.\" 449230Scael.\" %sccs.include.redist.roff% 524694Smckusick.\" 6*56981Sbostic.\" @(#)lgamma.3 6.6 (Berkeley) 12/03/92 748378Scael.\" 849230Scael.Dd 949230Scael.Dt LGAMMA 3 1049230Scael.Os BSD 4.3 1149230Scael.Sh NAME 1249230Scael.Nm lgamma 13*56981Sbostic.Nm gamma 14*56981Sbostic.Nd log gamma function, gamma function 1549230Scael.Sh SYNOPSIS 1649230Scael.Fd #include <math.h> 17*56981Sbostic.Ft extern int 18*56981Sbostic.Fa signgam ; 19*56981Sbostic.sp 2049230Scael.Ft double 2149230Scael.Fn lgamma "double x" 22*56981Sbostic.Ft double 23*56981Sbostic.Fn gamma "double x" 2449230Scael.Sh DESCRIPTION 25*56981Sbostic.Fn Lgamma x 2624694Smckusick.if t \{\ 27*56981Sbosticreturns ln\||\(*G(x)| where 2849230Scael.Bd -unfilled -offset indent 2949230Scael\(*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 3024694Smckusick.br 3150713Scael\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. 3249230Scael.Ed 3350713Scael.\} 3424694Smckusick.if n \ 35*56981Sbosticreturns ln\||\(*G(x)|. 3649230Scael.Pp 3749230ScaelThe external integer 3849230Scael.Fa signgam 39*56981Sbosticreturns the sign of \(*G(x). 40*56981Sbostic.Pp 41*56981Sbostic.Fn Gamma x 42*56981Sbosticreturns \(*G(x), with no effect on 43*56981Sbostic.Fa signgam . 4449230Scael.Sh IDIOSYNCRASIES 45*56981SbosticDo not use the expression 4649230Scael.Dq Li signgam\(**exp(lgamma(x)) 47*56981Sbosticto compute g := \(*G(x). 48*56981SbosticInstead use a program like this (in C): 4949230Scael.Bd -literal -offset indent 5024694Smckusicklg = lgamma(x); g = signgam\(**exp(lg); 5149230Scael.Ed 5249230Scael.Pp 5349230ScaelOnly after 5449230Scael.Fn lgamma 5549230Scaelhas returned can signgam be correct. 5649230Scael.Pp 57*56981SbosticFor arguments in its range, 58*56981Sbostic.Fn gamma 59*56981Sbosticis preferred, as for positive arguments 60*56981Sbosticit is accurate to within one unit in the last place. 61*56981SbosticExponentiation of 62*56981Sbostic.Fn lgamma 63*56981Sbosticwill lose up to 10 significant bits. 64*56981Sbostic.Sh RETURN VALUES 65*56981Sbostic.Fn Gamma 6649230Scaeland 6749230Scael.Fn lgamma 68*56981Sbosticreturn appropriate values unless an arguent is out of range. 69*56981SbosticOverflow will occur for sufficiently large positive values, and 70*56981Sbosticnon-positive integers. 71*56981SbosticOn the 72*56981Sbostic.Tn VAX, 73*56981Sbosticthe reserved operator is returned, 74*56981Sbosticand 7549230Scael.Va errno 7649230Scaelis set to 77*56981Sbostic.Er ERANGE 78*56981SbosticFor large non-integer negative values, 79*56981Sbostic.Fn gamma 80*56981Sbosticwill underflow. 8149230Scael.Sh SEE ALSO 8249230Scael.Xr math 3 , 8349230Scael.Xr infnan 3 8449230Scael.Sh HISTORY 8549230ScaelThe 86*56981Sbostic.Nm lgamma 8749230Scaelfunction appeared in 8849230Scael.Bx 4.3 . 89*56981SbosticThe 90*56981Sbostic.Nm gamma 91*56981Sbosticfunction appeared in 92*56981Sbostic.Bx 4.4 . 93*56981SbosticThe name 94*56981Sbostic.Fn gamma 95*56981Sbosticwas originally dedicated to the 96*56981Sbostic.Fn lgamma 97*56981Sbosticfunction, so some old code may no longer be compatible. 98