161f28255Scgd.\" Copyright (c) 1985, 1991 Regents of the University of California. 261f28255Scgd.\" All rights reserved. 361f28255Scgd.\" 461f28255Scgd.\" Redistribution and use in source and binary forms, with or without 561f28255Scgd.\" modification, are permitted provided that the following conditions 661f28255Scgd.\" are met: 761f28255Scgd.\" 1. Redistributions of source code must retain the above copyright 861f28255Scgd.\" notice, this list of conditions and the following disclaimer. 961f28255Scgd.\" 2. Redistributions in binary form must reproduce the above copyright 1061f28255Scgd.\" notice, this list of conditions and the following disclaimer in the 1161f28255Scgd.\" documentation and/or other materials provided with the distribution. 12eb7c1594Sagc.\" 3. Neither the name of the University nor the names of its contributors 1361f28255Scgd.\" may be used to endorse or promote products derived from this software 1461f28255Scgd.\" without specific prior written permission. 1561f28255Scgd.\" 1661f28255Scgd.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1761f28255Scgd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1861f28255Scgd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1961f28255Scgd.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2061f28255Scgd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2161f28255Scgd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2261f28255Scgd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2361f28255Scgd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2461f28255Scgd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2561f28255Scgd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2661f28255Scgd.\" SUCH DAMAGE. 2761f28255Scgd.\" 28d441c2dbSmycroft.\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92 29*56b14ee0Swiz.\" $NetBSD: lgamma.3,v 1.23 2017/07/03 21:32:50 wiz Exp $ 3061f28255Scgd.\" 318eea2598Schristos.Dd May 4, 2012 3261f28255Scgd.Dt LGAMMA 3 3338c96853Sgarbled.Os 3461f28255Scgd.Sh NAME 356be07a67Smrg.Nm lgamma , 36f8173630Skleink.Nm lgammaf , 3772c8365cSkleink.Nm lgamma_r , 3872c8365cSkleink.Nm lgammaf_r , 39f8173630Skleink.Nm gamma , 4072c8365cSkleink.Nm gammaf , 4172c8365cSkleink.Nm gamma_r , 428eea2598Schristos.Nm gammaf_r , 438eea2598Schristos.Nm tgamma , 448eea2598Schristos.Nm tgammaf 45df8b005fSjtc.Nd log gamma function 46312aca53Sperry.Sh LIBRARY 47312aca53Sperry.Lb libm 4861f28255Scgd.Sh SYNOPSIS 49472351e1Swiz.In math.h 50d441c2dbSmycroft.Ft extern int 51d441c2dbSmycroft.Fa signgam ; 52d441c2dbSmycroft.sp 5361f28255Scgd.Ft double 5461f28255Scgd.Fn lgamma "double x" 55df8b005fSjtc.Ft float 56df8b005fSjtc.Fn lgammaf "float x" 57f8173630Skleink.Ft double 5872c8365cSkleink.Fn lgamma_r "double x" "int *sign" 5972c8365cSkleink.Ft float 6072c8365cSkleink.Fn lgammaf_r "float x" "int *sign" 6172c8365cSkleink.Ft double 62f8173630Skleink.Fn gamma "double x" 63f8173630Skleink.Ft float 64f8173630Skleink.Fn gammaf "float x" 6572c8365cSkleink.Ft double 6672c8365cSkleink.Fn gamma_r "double x" "int *sign" 6772c8365cSkleink.Ft float 6872c8365cSkleink.Fn gammaf_r "float x" "int *sign" 698eea2598Schristos.Ft double 708eea2598Schristos.Fn tgamma "double x" 718eea2598Schristos.Ft float 728eea2598Schristos.Fn tgammaf "float x" 7361f28255Scgd.Sh DESCRIPTION 74ce83c69eSlukem.Fn lgamma x 7561f28255Scgd.if t \{\ 76d441c2dbSmycroftreturns ln\||\(*G(x)| where 7761f28255Scgd.Bd -unfilled -offset indent 78*56b14ee0Swiz\(*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 7961f28255Scgd.br 80*56b14ee0Swiz\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. 8161f28255Scgd.Ed 82d441c2dbSmycroft.\} 8361f28255Scgd.if n \ 84d441c2dbSmycroftreturns ln\||\(*G(x)|. 8561f28255Scgd.Pp 8661f28255ScgdThe external integer 8761f28255Scgd.Fa signgam 88d441c2dbSmycroftreturns the sign of \(*G(x). 89d441c2dbSmycroft.Pp 9072c8365cSkleink.Fn lgamma_r 9172c8365cSkleinkis a reentrant interface that performs identically to 9272c8365cSkleink.Fn lgamma , 9372c8365cSkleinkdiffering in that the sign of \(*G(x) is stored in the location 9472c8365cSkleinkpointed to by the 9572c8365cSkleink.Fa sign 9672c8365cSkleinkargument and 9772c8365cSkleink.Fa signgam 9872c8365cSkleinkis not modified. 998eea2598Schristos.Pp 1008eea2598SchristosThe 1018eea2598Schristos.Fn tgamma x 1028eea2598Schristosand 1038eea2598Schristos.Fn tgammaf x 1048eea2598Schristosfunctions return \(*G(x), with no effect on 1058eea2598Schristos.Fa signgam . 1068eea2598Schristos.Pp 1078eea2598Schristos.Fn gamma , 1088eea2598Schristos.Fn gammaf , 1098eea2598Schristos.Fn gamma_r , 1108eea2598Schristosand 1118eea2598Schristos.Fn gammaf_r 1128eea2598Schristosare deprecated aliases for 1138eea2598Schristos.Fn lgamma , 1148eea2598Schristos.Fn lgammaf , 1158eea2598Schristos.Fn lgamma_r , 1168eea2598Schristosand 1178eea2598Schristos.Fn lgammaf_r , 1188eea2598Schristosrespectively. 11961f28255Scgd.Sh IDIOSYNCRASIES 120d441c2dbSmycroftDo not use the expression 12161f28255Scgd.Dq Li signgam\(**exp(lgamma(x)) 122d441c2dbSmycroftto compute g := \(*G(x). 123d441c2dbSmycroftInstead use a program like this (in C): 12461f28255Scgd.Bd -literal -offset indent 12561f28255Scgdlg = lgamma(x); g = signgam\(**exp(lg); 12661f28255Scgd.Ed 12761f28255Scgd.Pp 12861f28255ScgdOnly after 12961f28255Scgd.Fn lgamma 13061f28255Scgdhas returned can signgam be correct. 131d441c2dbSmycroft.Sh RETURN VALUES 132ce83c69eSlukem.Fn lgamma 13390888266Sjtcreturns appropriate values unless an argument is out of range. 134d441c2dbSmycroftOverflow will occur for sufficiently large positive values, and 135d441c2dbSmycroftnon-positive integers. 1368eea2598SchristosFor large non-integer negative values, 1378eea2598Schristos.Fn tgamma 1388eea2598Schristoswill underflow. 139d441c2dbSmycroftOn the 140d441c2dbSmycroft.Tn VAX , 141d441c2dbSmycroftthe reserved operator is returned, 142d441c2dbSmycroftand 14361f28255Scgd.Va errno 14461f28255Scgdis set to 14590888266Sjtc.Er ERANGE . 14661f28255Scgd.Sh SEE ALSO 1473bf9d01bSjtc.Xr math 3 14861f28255Scgd.Sh HISTORY 14961f28255ScgdThe 150d441c2dbSmycroft.Nm lgamma 15161f28255Scgdfunction appeared in 15261f28255Scgd.Bx 4.3 . 1538eea2598SchristosThe 1548eea2598Schristos.Fn tgamma 1558eea2598Schristosfunction appeared in 1568eea2598Schristos.Nx 6.0 . 157