Chapter Contents

Previous

Next
gamma

gamma



Compute the Logarithm of the Gamma Function

Portability: UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
DIAGNOSTICS
PORTABILITY
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <lcmath.h>

double gamma(double x);


DESCRIPTION

gamma computes the logarithm of the gamma function of its argument x . The value returned by gamma is defined by this equation:

[IMAGE]


RETURN VALUE

gamma returns the logarithm of the gamma function of its argument.


DIAGNOSTICS

The run-time library writes an error message to the standard error file ( stderr ) if x is a negative number or 0. In this case, the function returns HUGE_VAL , the largest positive floating-point number that can be represented. Also, the run-time library writes an error message to the standard error file ( stderr ) if x is greater than 0.42686124520937873e74 in scientific notation. In this case, the function returns HUGE_VAL , the largest positive floating-point number that can be represented.

If an error occurs in gamma , the _matherr routine is called. You can supply your own version of _matherr to suppress the diagnostic message or modify the value returned.


PORTABILITY

gamma is portable to many, but not all, non UNIX C implementations.


EXAMPLE

This example computes the logarithm of the gamma function using gamma :

#include <stdio.h>
#include <lcmath.h
#define SVECTOR .7854

main()
{
   double lgamv;
   lgamv = gamma(SVECTOR);
   printf("gamma(%f) = %f\n", SVECTOR, lgamv);
}


RELATED FUNCTIONS

_matherr


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.