tgamma Function

Calculates the gamma function of the argument.

Include

<math.h>

Prototype

double tgamma(double x);

Argument

x
value for which to evaluate the gamma function

Return Value

Calculates the gamma function of the argument.

Remarks

A domain error occurs if x is negative or if the result cannot be represented with x is zero. A range error might occur if the value of x is too large or too small.

Example

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

int main(void)
{
  double x, y;

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

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

Example Output

The gamma function of 0.500000 is 1.772454
The gamma function of -0.750000 is -4.834147