1.\" $OpenBSD: lgamma.3,v 1.21 2013/08/07 22:20:25 millert Exp $ 2.\" Copyright (c) 1985, 1991 Regents of the University of California. 3.\" All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 3. Neither the name of the University nor the names of its contributors 14.\" may be used to endorse or promote products derived from this software 15.\" without specific prior written permission. 16.\" 17.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27.\" SUCH DAMAGE. 28.\" 29.\" from: @(#)lgamma.3 6.6 (Berkeley) 12/3/92 30.\" 31.Dd $Mdocdate: August 7 2013 $ 32.Dt LGAMMA 3 33.Os 34.Sh NAME 35.Nm lgamma , 36.Nm lgammaf , 37.Nm lgammal , 38.Nm lgamma_r , 39.Nm lgammaf_r , 40.Nm lgammal_r , 41.Nm tgamma , 42.Nm tgammaf , 43.Nm tgammal 44.Nd log gamma functions 45.Sh SYNOPSIS 46.In math.h 47.Ft extern int 48.Fa signgam ; 49.sp 50.Ft double 51.Fn lgamma "double x" 52.Ft float 53.Fn lgammaf "float x" 54.Ft long double 55.Fn lgammal "long double x" 56.Ft double 57.Fn lgamma_r "double x" "int *signgamp" 58.Ft float 59.Fn lgammaf_r "float x" "int *signgamp" 60.Ft long double 61.Fn lgammal_r "long double x" "int *signgamp" 62.Ft double 63.Fn tgamma "double x" 64.Ft float 65.Fn tgammaf "float x" 66.Ft long double 67.Fn tgammal "long double x" 68.Sh DESCRIPTION 69.Fn lgamma x 70.if t \{\ 71returns ln\||\(*G(x)| where 72.Bd -unfilled -offset indent 73\(*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 74.br 75\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. 76.Ed 77.\} 78.if n \ 79returns ln\||\(*G(x)|. 80.Pp 81The external integer 82.Fa signgam 83returns the sign of \(*G(x). 84The 85.Fn lgammaf 86function is a single precision version of 87.Fn lgamma . 88The 89.Fn lgammal 90function is an extended precision version of 91.Fn lgamma . 92.Pp 93The 94.Fn lgamma_r , 95.Fn lgammaf_r , 96and 97.Fn lgammal_r 98functions are thread-safe versions of 99.Fn lgamma , 100.Fn lgammaf , 101and 102.Fn lgammal 103that return the sign via the 104.Fa signgamp 105pointer instead of modifying 106.Fa signgam . 107.Pp 108The 109.Fn tgamma x , 110.Fn tgammaf x 111and 112.Fn tgammal x 113functions return \(*G(x), with no effect on 114.Fa signgam . 115.Sh IDIOSYNCRASIES 116Do not use the expression 117.Sq Li signgam\(**exp(lgamma(x)) 118to compute g := \(*G(x). 119Instead use a program like this (in C): 120.Bd -literal -offset indent 121lg = lgamma(x); g = signgam\(**exp(lg); 122.Ed 123.Pp 124Only after 125.Fn lgamma 126has returned can signgam be correct. 127.Pp 128For arguments in its range, 129.Fn tgamma 130is preferred, as for positive arguments 131it is accurate to within one unit in the last place. 132.Sh RETURN VALUES 133.Fn lgamma 134returns appropriate values unless an argument is out of range. 135Overflow will occur for sufficiently large positive values, and 136non-positive integers. 137For large non-integer negative values, 138.Fn tgamma 139will underflow. 140On the 141.Tn VAX , 142the reserved operator is returned, 143and 144.Va errno 145is set to 146.Er ERANGE . 147.Sh SEE ALSO 148.Xr infnan 3 149.Sh STANDARDS 150The 151.Fn lgamma , 152.Fn lgammaf , 153.Fn lgammal , 154.Fn tgamma , 155.Fn tgammaf , 156and 157.Fn tgammal 158functions are expected to conform to 159.St -isoC-99 . 160.Pp 161The 162.Fn lgamma_r , 163.Fn lgammaf_r , 164and 165.Fn lgammal_r 166functions are 167.Bx 168extensions. 169.Pp 170.Fn gamma 171and 172.Fn gammaf 173are deprecated aliases for 174.Fn lgamma 175and 176.Fn lgammaf , 177respectively. 178.Sh HISTORY 179A 180.Fn gamma 181function first appeared in 182.At v5 . 183The 184.Fn lgamma 185function first appeared in 186.Bx 4.3 . 187The 188.Fn tgamma 189function first appeared in 190.Ox 4.4 , 191and is based on the 192.Fn gamma 193function that appeared in 194.Bx 4.4 195as a function to compute \(*G(x). 196