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. 123a8617a8SJordan K. Hubbard.\" 3. All advertising materials mentioning features or use of this software 133a8617a8SJordan K. Hubbard.\" must display the following acknowledgement: 143a8617a8SJordan K. Hubbard.\" This product includes software developed by the University of 153a8617a8SJordan K. Hubbard.\" California, Berkeley and its contributors. 163a8617a8SJordan K. Hubbard.\" 4. Neither the name of the University nor the names of its contributors 173a8617a8SJordan K. Hubbard.\" may be used to endorse or promote products derived from this software 183a8617a8SJordan K. Hubbard.\" without specific prior written permission. 193a8617a8SJordan K. Hubbard.\" 203a8617a8SJordan K. Hubbard.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 213a8617a8SJordan K. Hubbard.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 223a8617a8SJordan K. Hubbard.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 233a8617a8SJordan K. Hubbard.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 243a8617a8SJordan K. Hubbard.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 253a8617a8SJordan K. Hubbard.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 263a8617a8SJordan K. Hubbard.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 273a8617a8SJordan K. Hubbard.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 283a8617a8SJordan K. Hubbard.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 293a8617a8SJordan K. Hubbard.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 303a8617a8SJordan K. Hubbard.\" SUCH DAMAGE. 313a8617a8SJordan K. Hubbard.\" 323a8617a8SJordan K. Hubbard.\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92 337f3dea24SPeter Wemm.\" $FreeBSD$ 343a8617a8SJordan K. Hubbard.\" 353a8617a8SJordan K. Hubbard.Dd December 3, 1992 363a8617a8SJordan K. Hubbard.Dt LGAMMA 3 37a307d598SRuslan Ermilov.Os 383a8617a8SJordan K. Hubbard.Sh NAME 393a8617a8SJordan K. Hubbard.Nm lgamma , 40457f6cd2SWarner Losh.Nm lgamma_r , 417a15a32aSJordan K. Hubbard.Nm lgammaf , 42457f6cd2SWarner Losh.Nm lgammaf_r , 437a15a32aSJordan K. Hubbard.Nm gamma , 44457f6cd2SWarner Losh.Nm gamma_r , 4546d7c297SBruce Evans.Nm gammaf , 46457f6cd2SWarner Losh.Nm gammaf_r , 4746d7c297SBruce Evans.Nm tgamma 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 59457f6cd2SWarner Losh.Fn lgamma_r "double x, int *signgamp" 607a15a32aSJordan K. Hubbard.Ft float 617a15a32aSJordan K. Hubbard.Fn lgammaf "float x" 62457f6cd2SWarner Losh.Ft float 63457f6cd2SWarner Losh.Fn lgammaf_r "float x, int *signgamp" 643a8617a8SJordan K. Hubbard.Ft double 653a8617a8SJordan K. Hubbard.Fn gamma "double x" 66457f6cd2SWarner Losh.Ft double 67457f6cd2SWarner Losh.Fn gamma_r "double x, int *signgamp" 687a15a32aSJordan K. Hubbard.Ft float 69354fb385SBruce Evans.Fn gammaf "float x" 70457f6cd2SWarner Losh.Ft float 71457f6cd2SWarner Losh.Fn gammaf_r "float x, int *signgamp" 7246d7c297SBruce Evans.Ft double 7346d7c297SBruce Evans.Fn tgamma "double x" 743a8617a8SJordan K. Hubbard.Sh DESCRIPTION 757a15a32aSJordan K. Hubbard.Fn lgamma x 767a15a32aSJordan K. Hubbardand 777a15a32aSJordan K. Hubbard.Fn lgammaf x 783a8617a8SJordan K. Hubbard.if t \{\ 797a15a32aSJordan K. Hubbardreturn ln\||\(*G(x)| where 803a8617a8SJordan K. Hubbard.Bd -unfilled -offset indent 813a8617a8SJordan 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 823a8617a8SJordan K. Hubbard.br 833a8617a8SJordan K. Hubbard\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. 843a8617a8SJordan K. Hubbard.Ed 853a8617a8SJordan K. Hubbard.\} 863a8617a8SJordan K. Hubbard.if n \ 87354fb385SBruce Evansreturn ln\||\(*G(x)|. 883a8617a8SJordan K. Hubbard.Pp 893a8617a8SJordan K. HubbardThe external integer 903a8617a8SJordan K. Hubbard.Fa signgam 913a8617a8SJordan K. Hubbardreturns the sign of \(*G(x). 923a8617a8SJordan K. Hubbard.Pp 93457f6cd2SWarner Losh.Fn lgamma_r x signgamp 947a15a32aSJordan K. Hubbardand 95457f6cd2SWarner Losh.Fn lgammaf_r x signgamp 96457f6cd2SWarner Loshprovide the same functionality as 97457f6cd2SWarner Losh.Fn lgamma x 98457f6cd2SWarner Loshand 99457f6cd2SWarner Losh.Fn lgammaf x 100457f6cd2SWarner Loshbut the caller must provide an integer to store the sign of \(*G(x) 101457f6cd2SWarner Losh.Pp 102457f6cd2SWarner Losh.Fn gamma , 103457f6cd2SWarner Losh.Fn gammaf , 104457f6cd2SWarner Losh.Fn gamma_r , 105457f6cd2SWarner Loshand 106457f6cd2SWarner Losh.Fn gammaf_r 107675902aaSBruce Evansare deprecated aliases for 108457f6cd2SWarner Losh.Fn lgamma , 109675902aaSBruce Evans.Fn lgammaf , 110457f6cd2SWarner Losh.Fn lgamma_r , 111457f6cd2SWarner Loshand 112457f6cd2SWarner Losh.Fn lgammaf_r , 113675902aaSBruce Evansrespectively. 11446d7c297SBruce Evans.Fn tgamma x 11546d7c297SBruce Evansreturns \(*G(x), with no effect on 11646d7c297SBruce Evans.Fa signgam . 1173a8617a8SJordan K. Hubbard.Sh IDIOSYNCRASIES 1183a8617a8SJordan K. HubbardDo not use the expression 1193a8617a8SJordan K. Hubbard.Dq Li signgam\(**exp(lgamma(x)) 1203a8617a8SJordan K. Hubbardto compute g := \(*G(x). 1213a8617a8SJordan K. HubbardInstead use a program like this (in C): 1223a8617a8SJordan K. Hubbard.Bd -literal -offset indent 1233a8617a8SJordan K. Hubbardlg = lgamma(x); g = signgam\(**exp(lg); 1243a8617a8SJordan K. Hubbard.Ed 1253a8617a8SJordan K. Hubbard.Pp 1263a8617a8SJordan K. HubbardOnly after 1273a8617a8SJordan K. Hubbard.Fn lgamma 1287a15a32aSJordan K. Hubbardor 1297a15a32aSJordan K. Hubbard.Fn lgammaf 1303a8617a8SJordan K. Hubbardhas returned can signgam be correct. 13146d7c297SBruce Evans.Pp 13246d7c297SBruce EvansFor arguments in its range, 13346d7c297SBruce Evans.Fn tgamma 13446d7c297SBruce Evansis preferred, as for positive arguments 13546d7c297SBruce Evansit is accurate to within one unit in the last place. 13646d7c297SBruce EvansExponentiation of 13746d7c297SBruce Evans.Fn lgamma 13846d7c297SBruce Evanswill lose up to 10 significant bits. 1393a8617a8SJordan K. Hubbard.Sh RETURN VALUES 1407a15a32aSJordan K. Hubbard.Fn gamma , 141457f6cd2SWarner Losh.Fn gamma_r, 1427a15a32aSJordan K. Hubbard.Fn gammaf , 143457f6cd2SWarner Losh.Fn gammaf_r , 1447a15a32aSJordan K. Hubbard.Fn lgamma , 145457f6cd2SWarner Losh.Fn lgamma_r , 146457f6cd2SWarner Losh.Fn lgammaf, 1473a8617a8SJordan K. Hubbardand 148457f6cd2SWarner Losh.Fn lgammaf_r 1493a8617a8SJordan K. Hubbardreturn appropriate values unless an argument is out of range. 1503a8617a8SJordan K. HubbardOverflow will occur for sufficiently large positive values, and 1513a8617a8SJordan K. Hubbardnon-positive integers. 1523a8617a8SJordan K. HubbardOn the 1533a8617a8SJordan K. Hubbard.Tn VAX , 1543a8617a8SJordan K. Hubbardthe reserved operator is returned, 1553a8617a8SJordan K. Hubbardand 1563a8617a8SJordan K. Hubbard.Va errno 1573a8617a8SJordan K. Hubbardis set to 158c23155a4SRuslan Ermilov.Er ERANGE . 15946d7c297SBruce EvansFor large non-integer negative values, 16046d7c297SBruce Evans.Fn tgamma 16146d7c297SBruce Evanswill underflow. 1623a8617a8SJordan K. Hubbard.Sh SEE ALSO 1634bd9ba3cSMike Pritchard.Xr math 3 16446d7c297SBruce Evans.Sh STANDARDS 16546d7c297SBruce EvansThe 16646d7c297SBruce Evans.Fn lgamma 16746d7c297SBruce Evansand 16846d7c297SBruce Evans.Fn tgamma 16946d7c297SBruce Evansfunctions are expected to conform to 17046d7c297SBruce Evans.St -isoC-99 . 1713a8617a8SJordan K. Hubbard.Sh HISTORY 1723a8617a8SJordan K. HubbardThe 173563f6bdeSRuslan Ermilov.Fn lgamma 1743a8617a8SJordan K. Hubbardfunction appeared in 1753a8617a8SJordan K. Hubbard.Bx 4.3 . 1763a8617a8SJordan K. HubbardThe 177563f6bdeSRuslan Ermilov.Fn gamma 1783a8617a8SJordan K. Hubbardfunction appeared in 179a9dbc63dSDavid Malone.Bx 4.4 180a9dbc63dSDavid Maloneas a function which computed \(*G(x). 181675902aaSBruce EvansThis version was used in 182675902aaSBruce Evans.Fx 1.1 . 183675902aaSBruce EvansThe name 1843a8617a8SJordan K. Hubbard.Fn gamma 185675902aaSBruce Evanswas originally dedicated to the 186675902aaSBruce Evans.Fn lgamma 187675902aaSBruce Evansfunction, 188675902aaSBruce Evansand that usage was restored by switching to Sun's fdlibm in 189675902aaSBruce Evans.Fx 1.1.5 . 190a9dbc63dSDavid MaloneThe 191a9dbc63dSDavid Malone.Fn tgamma 19246d7c297SBruce Evansfunction appeared in 19346d7c297SBruce Evans.Fx 5.0 . 194