1.\" $OpenBSD: lgamma.3,v 1.16 2008/06/12 15:51:42 jmc 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: June 12 2008 $ 32.Dt LGAMMA 3 33.Os 34.Sh NAME 35.Nm lgamma , 36.Nm lgammaf , 37.Nm tgamma , 38.Nm tgammaf 39.Nd log gamma functions 40.Sh SYNOPSIS 41.Fd #include <math.h> 42.Ft extern int 43.Fa signgam ; 44.sp 45.Ft double 46.Fn lgamma "double x" 47.Ft float 48.Fn lgammaf "float x" 49.Ft double 50.Fn tgamma "double x" 51.Ft float 52.Fn tgammaf "float x" 53.Sh DESCRIPTION 54.Fn lgamma x 55.if t \{\ 56returns ln\||\(*G(x)| where 57.Bd -unfilled -offset indent 58\(*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 59.br 60\(*G(x) = \(*p/(\(*G(1\-x)\|sin(\(*px)) for x < 1. 61.Ed 62.\} 63.if n \ 64returns ln\||\(*G(x)|. 65.Pp 66The external integer 67.Fa signgam 68returns the sign of \(*G(x). 69The 70.Fn lgammaf 71function is a single precision version of 72.Fn lgamma . 73.Pp 74The 75.Fn tgamma x 76and 77.Fn tgammaf x 78functions return \(*G(x), with no effect on 79.Fa signgam . 80.Sh IDIOSYNCRASIES 81Do not use the expression 82.Sq Li signgam\(**exp(lgamma(x)) 83to compute g := \(*G(x). 84Instead use a program like this (in C): 85.Bd -literal -offset indent 86lg = lgamma(x); g = signgam\(**exp(lg); 87.Ed 88.Pp 89Only after 90.Fn lgamma 91has returned can signgam be correct. 92.Pp 93For arguments in its range, 94.Fn tgamma 95is preferred, as for positive arguments 96it is accurate to within one unit in the last place. 97.Sh RETURN VALUES 98.Fn lgamma 99returns appropriate values unless an argument is out of range. 100Overflow will occur for sufficiently large positive values, and 101non-positive integers. 102For large non-integer negative values, 103.Fn tgamma 104will underflow. 105On the 106.Tn VAX , 107the reserved operator is returned, 108and 109.Va errno 110is set to 111.Er ERANGE . 112.Sh SEE ALSO 113.Xr infnan 3 , 114.Xr math 3 115.Sh STANDARDS 116The 117.Fn lgamma , 118.Fn lgammaf , 119.Fn tgamma , 120and 121.Fn tgammaf 122functions are expected to conform to 123.St -isoC-99 . 124.Pp 125.Fn gamma 126and 127.Fn gammaf 128are deprecated aliases for 129.Fn lgamma 130and 131.Fn lgammaf , 132respectively. 133.Sh HISTORY 134The 135.Fn lgamma 136function first appeared in 137.Bx 4.3 . 138The 139.Fn tgamma 140function first appeared in 141.Ox 4.4 , 142and is based on the 143.Fn gamma 144function that appeared in 145.Bx 4.4 146as a function to compute \(*G(x). 147