gamma() — Gamma Function

Format

#include <math.h>
double gamma(double x);

Language Level: ILE C Extension

Threadsafe: Yes.

Description

The gamma() function computes the natural logarithm of the absolute value of G(x) (ln(|G(x)|)), where

The argument x must be a positive real value.

Return Value

The gamma() function returns the value of ln(|G(x)|). If x is a negative value, errno is set to EDOM. If the result causes an overflow, gamma() returns HUGE_VAL and sets errno to ERANGE.

Example that uses gamma()

This example uses gamma() to calculate ln(|G(x)|), where x = 42.

#include <math.h>
#include <stdio.h>
 
int main(void)
{
   double x=42, g_at_x;
 
   g_at_x = exp(gamma(x));       /* g_at_x = 3.345253e+49 */
   printf ("The value of G(%4.2lf) is %7.2e\n", x, g_at_x);
}
 
/************************  Output should be similar to: **********
 
The value of G(42.00) is 3.35e+49
*/

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]