[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

lgamma, lgammal, or gamma Subroutine

Purpose

Computes the natural logarithm of the gamma function.

Libraries

lgamma, lgammal, and gamma:
IEEE Math Library (libm.a)
or System V Math Library (libmsaa.a)

Syntax

#include <math.h>
extern int signgam;
double lgamma (x)
double x;
long double lgammal (x)
long double x;

double gamma (x)
double x;

Description

The subroutine names lgamma and gamma are different names for the same function. The lgammal subroutine provides the same function for numbers in long double format.

The lgamma subroutine returns the natural logarithm of the absolute value of the gamma function of the x parameter.

G(x) = integral [0 to INF] of ((e**(-t) * t**(x-1) dt)

The sign of lgamma of x is stored in the external integer variable signgam. The x parameter may not be a non-positive integer.

Do not use the expression:

g = exp(lgamma(x)) * signgam

to compute g = G(x). Instead, use a sequence such as:

lg = lgamma(x);
g = exp(lg) * signgam;
Note: Compile any routine that uses subroutines from the libm.a with the -lm flag. To compile the lgamma.c file, enter:
cc lgamma.c -lm

Parameters

x For the lgamma and gamma subroutines, specifies a double-precision floating-point value. For the lgammal subroutine, specifies a long double-precision floating-point value.

Error Codes

When using the libmsaa.a library with the -lmsaa flag:

Note: These error-handling procedures may be changed with the matherr subroutine when using libmsaa.a (-lmsaa).

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The exp, expm1, log, log10, log1p or pow subroutine, matherr subroutine.

Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.

128-Bit long double Floating-Point Format in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]