# tgamma Function

Calculates the gamma function of a double precision floating-point argument.

Attention: This function is not implemented by MPLAB XC8 C compilers.

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

If x is negative or if the result cannot be represented with x is zero, a domain error will occur and errno will be set to EDOM.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#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