# (j3.2006) 13.7.64 GAMMA has incomplete mathematical definition

Fred J. Tydeman tydeman
Fri Oct 3 12:41:44 EDT 2008

```On Fri, 03 Oct 2008 08:31:32 -0700, Aleksandar Donev wrote:

>> 2. Restrict the arguments of GAMMA and LOG_GAMMA to positive values?
>What does C's math library and common implementations do?
>We should not do more than what is already common---the point was not to

C99 defines GAMMA and LOG_GAMMA for all real values.
There are no such functions for complex values.

C99, main body

7.12.8.3 The lgamma functions
Synopsis
1 #include <math.h>
double lgamma(double x);
float lgammaf(float x);
long double lgammal(long double x);
Description
2 The lgamma functions compute the natural logarithm of the absolute
value of gamma of x.  A range error occurs if x is too large. A range
error may occur if x is a negative integer or zero.
Returns
3 The lgamma functions return log|G(x)|.

7.12.8.4 The tgamma functions
Synopsis
1 #include <math.h>
double tgamma(double x);
float tgammaf(float x);
long double tgammal(long double x);
Description
2 The tgamma functions compute the gamma function of x.A domain error
or range error may occur if x is a negative integer or zero. A range
error may occur if the magnitude of x is too large or too small.
Returns
3 The tgamma functions return G(x).

C99, Annex F (the IEEE-754 one)

F.9.5.3 The lgamma functions

1 -- lgamma(1) returns +0.

-- lgamma(2) returns +0.

-- lgamma(x) returns + INF and raises the "divide-by-zero"
floating-point exception for x a negative integer or zero.

-- lgamma(- INF ) returns + INF .

-- lgamma(+ INF ) returns + INF .

F.9.5.4 The tgamma functions

1 -- tgamma(+/-0) returns +/- INF and raises the "divide-by-zero"
floating-point exception.

-- tgamma(x) returns a NaN and raises the "invalid" floating-point
exception for x a negative integer.

-- tgamma(- INF ) returns a NaN and raises the "invalid"
floating-point exception.

-- tgamma(+ INF ) returns + INF .

---
Fred J. Tydeman        Tydeman Consulting
tydeman at tybor.com      Testing, numerics, programming
+1 (775) 358-9748      Vice-chair of PL22.11 (ANSI "C")
Sample C99+FPCE tests: http://www.tybor.com
Savers sleep well, investors eat well, spenders work forever.

```