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