13a8617a8SJordan K. Hubbard.\" Copyright (c) 1985, 1991 Regents of the University of California. 23a8617a8SJordan K. Hubbard.\" All rights reserved. 33a8617a8SJordan K. Hubbard.\" 43a8617a8SJordan K. Hubbard.\" Redistribution and use in source and binary forms, with or without 53a8617a8SJordan K. Hubbard.\" modification, are permitted provided that the following conditions 63a8617a8SJordan K. Hubbard.\" are met: 73a8617a8SJordan K. Hubbard.\" 1. Redistributions of source code must retain the above copyright 83a8617a8SJordan K. Hubbard.\" notice, this list of conditions and the following disclaimer. 93a8617a8SJordan K. Hubbard.\" 2. Redistributions in binary form must reproduce the above copyright 103a8617a8SJordan K. Hubbard.\" notice, this list of conditions and the following disclaimer in the 113a8617a8SJordan K. Hubbard.\" documentation and/or other materials provided with the distribution. 12fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 133a8617a8SJordan K. Hubbard.\" may be used to endorse or promote products derived from this software 143a8617a8SJordan K. Hubbard.\" without specific prior written permission. 153a8617a8SJordan K. Hubbard.\" 163a8617a8SJordan K. Hubbard.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 173a8617a8SJordan K. Hubbard.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 183a8617a8SJordan K. Hubbard.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 193a8617a8SJordan K. Hubbard.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 203a8617a8SJordan K. Hubbard.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 213a8617a8SJordan K. Hubbard.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 223a8617a8SJordan K. Hubbard.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 233a8617a8SJordan K. Hubbard.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 243a8617a8SJordan K. Hubbard.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 253a8617a8SJordan K. Hubbard.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 263a8617a8SJordan K. Hubbard.\" SUCH DAMAGE. 273a8617a8SJordan K. Hubbard.\" 283a8617a8SJordan K. Hubbard.\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92 297f3dea24SPeter Wemm.\" $FreeBSD$ 303a8617a8SJordan K. Hubbard.\" 31*240076e5SDimitry Andric.Dd December 8, 2017 323a8617a8SJordan K. Hubbard.Dt LGAMMA 3 33a307d598SRuslan Ermilov.Os 343a8617a8SJordan K. Hubbard.Sh NAME 353a8617a8SJordan K. Hubbard.Nm lgamma , 36457f6cd2SWarner Losh.Nm lgamma_r , 377a15a32aSJordan K. Hubbard.Nm lgammaf , 38457f6cd2SWarner Losh.Nm lgammaf_r , 39f7efd14dSSteve Kargl.Nm lgammal , 40f7efd14dSSteve Kargl.Nm lgammal_r , 417a15a32aSJordan K. Hubbard.Nm gamma , 42457f6cd2SWarner Losh.Nm gamma_r , 4346d7c297SBruce Evans.Nm gammaf , 44457f6cd2SWarner Losh.Nm gammaf_r , 4571c11dd5SDavid Schultz.Nm tgamma , 46*240076e5SDimitry Andric.Nm tgammaf , 47*240076e5SDimitry Andric.Nm tgammal , 4846d7c297SBruce Evans.Nd log gamma functions, gamma function 4964890443SBruce Evans.Sh LIBRARY 5064890443SBruce Evans.Lb libm 513a8617a8SJordan K. Hubbard.Sh SYNOPSIS 5232eef9aeSRuslan Ermilov.In math.h 533a8617a8SJordan K. Hubbard.Ft extern int 543a8617a8SJordan K. Hubbard.Fa signgam ; 553a8617a8SJordan K. Hubbard.sp 563a8617a8SJordan K. Hubbard.Ft double 573a8617a8SJordan K. Hubbard.Fn lgamma "double x" 58457f6cd2SWarner Losh.Ft double 593892c300SRuslan Ermilov.Fn lgamma_r "double x" "int *signgamp" 607a15a32aSJordan K. Hubbard.Ft float 617a15a32aSJordan K. Hubbard.Fn lgammaf "float x" 62457f6cd2SWarner Losh.Ft float 633892c300SRuslan Ermilov.Fn lgammaf_r "float x" "int *signgamp" 64f7efd14dSSteve Kargl.Ft "long double" 65f7efd14dSSteve Kargl.Fn lgammal "long double x" 66f7efd14dSSteve Kargl.Ft "long double" 67f7efd14dSSteve Kargl.Fn lgammal_r "long double x" "int *signgamp" 683a8617a8SJordan K. Hubbard.Ft double 693a8617a8SJordan K. Hubbard.Fn gamma "double x" 70457f6cd2SWarner Losh.Ft double 713892c300SRuslan Ermilov.Fn gamma_r "double x" "int *signgamp" 727a15a32aSJordan K. Hubbard.Ft float 73354fb385SBruce Evans.Fn gammaf "float x" 74457f6cd2SWarner Losh.Ft float 753892c300SRuslan Ermilov.Fn gammaf_r "float x" "int *signgamp" 76f7efd14dSSteve Kargl.Ft "long double" 7746d7c297SBruce Evans.Fn tgamma "double x" 7871c11dd5SDavid Schultz.Ft float 7971c11dd5SDavid Schultz.Fn tgammaf "float x" 80*240076e5SDimitry Andric.Ft "long double" 81*240076e5SDimitry Andric.Fn tgammal "long double x" 823a8617a8SJordan K. Hubbard.Sh DESCRIPTION 83f7efd14dSSteve Kargl.Fn lgamma x , 84f7efd14dSSteve Kargl.Fn lgammaf x , 857a15a32aSJordan K. Hubbardand 86f7efd14dSSteve Kargl.Fn lgammal x 873a8617a8SJordan K. Hubbard.if t \{\ 887a15a32aSJordan K. Hubbardreturn ln\||\(*G(x)| where 893a8617a8SJordan K. Hubbard.Bd -unfilled -offset indent 903a8617a8SJordan K. Hubbard\(*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 913a8617a8SJordan K. Hubbard\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. 923a8617a8SJordan K. Hubbard.Ed 933a8617a8SJordan K. Hubbard.\} 943a8617a8SJordan K. Hubbard.if n \ 95354fb385SBruce Evansreturn ln\||\(*G(x)|. 963a8617a8SJordan K. HubbardThe external integer 973a8617a8SJordan K. Hubbard.Fa signgam 983a8617a8SJordan K. Hubbardreturns the sign of \(*G(x). 993a8617a8SJordan K. Hubbard.Pp 100f7efd14dSSteve Kargl.Fn lgamma_r x signgamp , 101f7efd14dSSteve Kargl.Fn lgammaf_r x signgamp , 1027a15a32aSJordan K. Hubbardand 103f7efd14dSSteve Kargl.Fn lgammal_r x signgamp 104457f6cd2SWarner Loshprovide the same functionality as 105f7efd14dSSteve Kargl.Fn lgamma x , 106f7efd14dSSteve Kargl.Fn lgammaf x , 107457f6cd2SWarner Loshand 108f7efd14dSSteve Kargl.Fn lgammal x , 1093892c300SRuslan Ermilovbut the caller must provide an integer to store the sign of \(*G(x). 110457f6cd2SWarner Losh.Pp 11171c11dd5SDavid SchultzThe 112*240076e5SDimitry Andric.Fn tgamma x , 113*240076e5SDimitry Andric.Fn tgammaf x , 11471c11dd5SDavid Schultzand 115*240076e5SDimitry Andric.Fn tgammal x 11671c11dd5SDavid Schultzfunctions return \(*G(x), with no effect on 11771c11dd5SDavid Schultz.Fa signgam . 11871c11dd5SDavid Schultz.Pp 119457f6cd2SWarner Losh.Fn gamma , 120457f6cd2SWarner Losh.Fn gammaf , 121457f6cd2SWarner Losh.Fn gamma_r , 122457f6cd2SWarner Loshand 123457f6cd2SWarner Losh.Fn gammaf_r 124675902aaSBruce Evansare deprecated aliases for 125457f6cd2SWarner Losh.Fn lgamma , 126675902aaSBruce Evans.Fn lgammaf , 127457f6cd2SWarner Losh.Fn lgamma_r , 128457f6cd2SWarner Loshand 129457f6cd2SWarner Losh.Fn lgammaf_r , 130675902aaSBruce Evansrespectively. 1313a8617a8SJordan K. Hubbard.Sh IDIOSYNCRASIES 1323a8617a8SJordan K. HubbardDo not use the expression 1333a8617a8SJordan K. Hubbard.Dq Li signgam\(**exp(lgamma(x)) 1343a8617a8SJordan K. Hubbardto compute g := \(*G(x). 1353a8617a8SJordan K. HubbardInstead use a program like this (in C): 1363a8617a8SJordan K. Hubbard.Bd -literal -offset indent 1373a8617a8SJordan K. Hubbardlg = lgamma(x); g = signgam\(**exp(lg); 1383a8617a8SJordan K. Hubbard.Ed 1393a8617a8SJordan K. Hubbard.Pp 1403a8617a8SJordan K. HubbardOnly after 1413a8617a8SJordan K. Hubbard.Fn lgamma 1427a15a32aSJordan K. Hubbardor 1437a15a32aSJordan K. Hubbard.Fn lgammaf 1443a8617a8SJordan K. Hubbardhas returned can signgam be correct. 14546d7c297SBruce Evans.Pp 14646d7c297SBruce EvansFor arguments in its range, 14746d7c297SBruce Evans.Fn tgamma 14846d7c297SBruce Evansis preferred, as for positive arguments 14946d7c297SBruce Evansit is accurate to within one unit in the last place. 15046d7c297SBruce EvansExponentiation of 15146d7c297SBruce Evans.Fn lgamma 15246d7c297SBruce Evanswill lose up to 10 significant bits. 1533a8617a8SJordan K. Hubbard.Sh RETURN VALUES 1547a15a32aSJordan K. Hubbard.Fn gamma , 1557a15a32aSJordan K. Hubbard.Fn gammaf , 156f7efd14dSSteve Kargl.Fn gammal , 157f7efd14dSSteve Kargl.Fn gamma_r , 158457f6cd2SWarner Losh.Fn gammaf_r , 159f7efd14dSSteve Kargl.Fn gammal_r , 1607a15a32aSJordan K. Hubbard.Fn lgamma , 161457f6cd2SWarner Losh.Fn lgammaf , 162f7efd14dSSteve Kargl.Fn lgammal , 163f7efd14dSSteve Kargl.Fn lgamma_r , 164f7efd14dSSteve Kargl.Fn lgammaf_r , 1653a8617a8SJordan K. Hubbardand 166f7efd14dSSteve Kargl.Fn lgammal_r 1673a8617a8SJordan K. Hubbardreturn appropriate values unless an argument is out of range. 1683a8617a8SJordan K. HubbardOverflow will occur for sufficiently large positive values, and 1693a8617a8SJordan K. Hubbardnon-positive integers. 17046d7c297SBruce EvansFor large non-integer negative values, 17146d7c297SBruce Evans.Fn tgamma 17246d7c297SBruce Evanswill underflow. 173*240076e5SDimitry Andric.Sh BUGS 174*240076e5SDimitry AndricTo conform with newer C/C++ standards, a stub implementation for 175*240076e5SDimitry Andric.Nm tgammal 176*240076e5SDimitry Andricwas committed to the math library, where 177*240076e5SDimitry Andric.Nm tgammal 178*240076e5SDimitry Andricis mapped to 179*240076e5SDimitry Andric.Nm tgammal . 180*240076e5SDimitry AndricThus, the numerical accuracy is at most that of the 53-bit double 181*240076e5SDimitry Andricprecision implementation. 1823a8617a8SJordan K. Hubbard.Sh SEE ALSO 1834bd9ba3cSMike Pritchard.Xr math 3 18446d7c297SBruce Evans.Sh STANDARDS 18546d7c297SBruce EvansThe 18671c11dd5SDavid Schultz.Fn lgamma , 18771c11dd5SDavid Schultz.Fn lgammaf , 188f7efd14dSSteve Kargl.Fn lgammal , 18971c11dd5SDavid Schultz.Fn tgamma , 190*240076e5SDimitry Andric.Fn tgammaf , 19146d7c297SBruce Evansand 192*240076e5SDimitry Andric.Fn tgammal 19346d7c297SBruce Evansfunctions are expected to conform to 19446d7c297SBruce Evans.St -isoC-99 . 1953a8617a8SJordan K. Hubbard.Sh HISTORY 1963a8617a8SJordan K. HubbardThe 197563f6bdeSRuslan Ermilov.Fn lgamma 1983a8617a8SJordan K. Hubbardfunction appeared in 1993a8617a8SJordan K. Hubbard.Bx 4.3 . 2003a8617a8SJordan K. HubbardThe 201563f6bdeSRuslan Ermilov.Fn gamma 2023a8617a8SJordan K. Hubbardfunction appeared in 203a9dbc63dSDavid Malone.Bx 4.4 204a9dbc63dSDavid Maloneas a function which computed \(*G(x). 205675902aaSBruce EvansThis version was used in 206675902aaSBruce Evans.Fx 1.1 . 207675902aaSBruce EvansThe name 2083a8617a8SJordan K. Hubbard.Fn gamma 209675902aaSBruce Evanswas originally dedicated to the 210675902aaSBruce Evans.Fn lgamma 211675902aaSBruce Evansfunction, 212675902aaSBruce Evansand that usage was restored by switching to Sun's fdlibm in 213675902aaSBruce Evans.Fx 1.1.5 . 214a9dbc63dSDavid MaloneThe 215a9dbc63dSDavid Malone.Fn tgamma 21646d7c297SBruce Evansfunction appeared in 21746d7c297SBruce Evans.Fx 5.0 . 218