lgamma Function

Calculates the natural logarithm of the absolute value of gamma of the argument.

Include

<math.h>

Prototype

double lgamma(double x);

Argument

x
value to evaluate gamma of

Return Value

Calculates the natural logarithm of the absolute value of gamma of the argument.

Remarks

A range error occurs if x is too large. A range error might occur if x is less than or equal to zero.

Example

#include <math.h>
#include <stdio.h>
#include <errno.h>

int main(void)
{
  double x, y;

  x = 0.5;
  y = lgamma(x);
  if(errno)
    perror("Error");
  printf("The natural log of gamma of %f is %f\n", x, y);

  x = -0.75;
  y = lgamma(x);
  if(errno)
    perror("Error");
  printf("The natural log of gamma of %f is %f\n", x, y);
}

Example Output

The natural log of gamma of 0.500000 is 0.572365
The natural log of gamma of -0.750000 is 1.575705