161309Sbostic.\" Copyright (c) 1985, 1991, 1993 261309Sbostic.\" The Regents of the University of California. All rights reserved. 324694Smckusick.\" 449230Scael.\" %sccs.include.redist.roff% 524694Smckusick.\" 6*65099Smckusick.\" @(#)lgamma.3 8.2 (Berkeley) 12/11/93 748378Scael.\" 849230Scael.Dd 949230Scael.Dt LGAMMA 3 1049230Scael.Os BSD 4.3 1149230Scael.Sh NAME 1249230Scael.Nm lgamma 1356981Sbostic.Nm gamma 1456981Sbostic.Nd log gamma function, gamma function 1549230Scael.Sh SYNOPSIS 1649230Scael.Fd #include <math.h> 1756981Sbostic.Ft extern int 1856981Sbostic.Fa signgam ; 1956981Sbostic.sp 2049230Scael.Ft double 2149230Scael.Fn lgamma "double x" 2256981Sbostic.Ft double 2356981Sbostic.Fn gamma "double x" 2449230Scael.Sh DESCRIPTION 2556981Sbostic.Fn Lgamma x 2624694Smckusick.if t \{\ 2756981Sbosticreturns 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 \ 3556981Sbosticreturns ln\||\(*G(x)|. 3649230Scael.Pp 3749230ScaelThe external integer 3849230Scael.Fa signgam 3956981Sbosticreturns the sign of \(*G(x). 4056981Sbostic.Pp 4156981Sbostic.Fn Gamma x 4256981Sbosticreturns \(*G(x), with no effect on 4356981Sbostic.Fa signgam . 4449230Scael.Sh IDIOSYNCRASIES 4556981SbosticDo not use the expression 4649230Scael.Dq Li signgam\(**exp(lgamma(x)) 4756981Sbosticto compute g := \(*G(x). 4856981SbosticInstead 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 5756981SbosticFor arguments in its range, 5856981Sbostic.Fn gamma 5956981Sbosticis preferred, as for positive arguments 6056981Sbosticit is accurate to within one unit in the last place. 6156981SbosticExponentiation of 6256981Sbostic.Fn lgamma 6356981Sbosticwill lose up to 10 significant bits. 6456981Sbostic.Sh RETURN VALUES 6556981Sbostic.Fn Gamma 6649230Scaeland 6749230Scael.Fn lgamma 68*65099Smckusickreturn appropriate values unless an argument is out of range. 6956981SbosticOverflow will occur for sufficiently large positive values, and 7056981Sbosticnon-positive integers. 7156981SbosticOn the 7256981Sbostic.Tn VAX, 7356981Sbosticthe reserved operator is returned, 7456981Sbosticand 7549230Scael.Va errno 7649230Scaelis set to 7756981Sbostic.Er ERANGE 7856981SbosticFor large non-integer negative values, 7956981Sbostic.Fn gamma 8056981Sbosticwill underflow. 8149230Scael.Sh SEE ALSO 8249230Scael.Xr math 3 , 8349230Scael.Xr infnan 3 8449230Scael.Sh HISTORY 8549230ScaelThe 8656981Sbostic.Nm lgamma 8749230Scaelfunction appeared in 8849230Scael.Bx 4.3 . 8956981SbosticThe 9056981Sbostic.Nm gamma 9156981Sbosticfunction appeared in 9256981Sbostic.Bx 4.4 . 9356981SbosticThe name 9456981Sbostic.Fn gamma 9556981Sbosticwas originally dedicated to the 9656981Sbostic.Fn lgamma 9756981Sbosticfunction, so some old code may no longer be compatible. 98