Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC Numerics / Part 2 - The PowerPC Numerics C Implementation
Chapter 10 - Transcendental Functions / Error and Gamma Functions


lgamma

You can use the lgamma function to compute the natural logarithm of the absolute value of Gamma(x) .

double_t lgamma (double_t x);
x
Any positive floating-point number.
DESCRIPTION
The lgamma function computes the natural logarithm of the absolute value of Gamma(x) .

lgamma(x) = loge(|Gamma(x)|) = ln(|Gamma(x)|)

EXCEPTIONS
When x is finite and nonzero, either the result of lgamma(x) is exact or it raises one of the following exceptions:

  • inexact (if the result must be rounded or an overflow occurs)
  • overflow (if the result is outside the range of the data type)
  • invalid (if x 0)

SPECIAL CASES
Table 10-38 shows the results when the argument to the lgamma function is a zero, a NaN, or an Infinity, plus other special cases for the lgamma function.
Special cases for the lgamma function
OperationResultExceptions raised
lgamma(x) for x < 0NaN Invalid
lgamma(+0) NaNInvalid
lgamma(-0) NaNInvalid
lgamma(NaN) NaNNone[62]
lgamma(+ ) + Overflow
lgamma(- ) NaNInvalid

EXAMPLES
z = lgamma(-1.0);    /* z = NAN. The invalid exception is 
                        raised. */
z = lgamma(3.41);    /* z = 1.10304. The inexact exception is 
                        raised. */

[62] If the NaN is a signaling NaN, the invalid exception is raised.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996