Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

gamma(3m) [ultrix man page]

gamma(3m)																 gamma(3m)

Name
       gamma, lgamma, signgam - log gamma function

Syntax
       #include <math.h>

       double gamma(x)
       double x;

       double lgamma(x)
       double x;

       extern int

Description			 _			_
       The fu_ction returns ln || (|x|)|.  The sign of | (|x|) is returned in the external integer The following C program might be used to calcu-
       late | :

       y = gamma(x);
       if (y > 88.0)
	    error();
       y = exp(y);
       if(signgam)
	    y = -y;

       The function is another name for the function.

Return Values
       The and functions return NaN when x is NaN or when it is an integer value less than or equal to zero.  On  overflow  and  functions  return
       HUGE_VAL.

Environment
       When your program is compiled using the System V environment for nonpositive integer values, HUGE is returned, and errno is set to EDOM.  A
       message indicating DOMAIN error is printed on the standard error output.

       If the correct value would overflow, returns HUGE and sets errno to ERANGE.

       These error-handling procedures may be changed with the function

See Also
       matherr(3m)

								       RISC								 gamma(3m)

Check Out this Related Man Page

LGAMMA(3M)																LGAMMA(3M)

NAME
lgamma - log gamma function SYNOPSIS
#include <math.h> double lgamma(x) double x; DESCRIPTION
_ Lgamma returns ln|| (x)|. _ The external integer signgam returns the sign of | (x) . IDIOSYNCRASIES
_ Do not use the expression signgam*exp(lgamma(x)) to compute g := | (x). Instead use a program like this (in C): lg = lgamma(x); g = signgam*exp(lg); _ Only after lgamma has returned can signgam be correct. Note too that | (x) must overflow when x is large enough, underflow when -x is large enough, and spawn a division by zero when x is a nonpositive integer. _ Only in the UNIX m_th library for C was the na_e gamma ever attached to ln| . Elsewhere, for instance in IBM's FORTRAN library, the name GAMMA belongs to | and the name ALGAMA to ln| in single precision; in double the names are DGAMMA and DLGAMA. Why should C be different? _ Archaeological records suggest that C's gamma originally delivered ln(| (|x|)). Later, the program gamma was changed to cope with negative arguments x in a more conventional way, but the documentation did _ot reflect that change correctly. The most recent change corrects inac- curate values when x is almost a negative integer, and lets | (x) be computed without conditional expressions. Programmers should not assume that lgamma has settled down. At some time in the future, the name gamma will be rehabilitated and used for the gamma function, just as is done in FORTRAN. The reason for this is not so much compatibility with FORTRAN as a desire to achieve greater speed for smaller values of |x| and greater accuracy for larger values. Meanwhile, programmers who have to use the name gamma in its former sense, for what is now lgamma, have two choices: 1) Use the old math library, libom. 2) Add the following program to your others: #include <math.h> double gamma(x) double x; { return (lgamma(x)); } DIAGNOSTICS
The reserved operand is returned on a VAX for negative integer arguments, errno is set to ERANGE; for very large arguments over/underflows will occur inside the lgamma routine. SEE ALSO
math(3M), infnan(3M) 4.3 Berkeley Distribution May 12, 1986 LGAMMA(3M)
Man Page

We Also Found This Discussion For You

1. Programming

Javascript: gamma approximation

Here is some javascript code that implements the Lanczos approximation to the gamma function (http://en.wikipedia.org/wiki/Lanczos_approximation): <script type="text/javascript"> // Gamma approximation; coefficients used by the GNU Scientific Library function gamma(z) { var p = ; if z... (2 Replies)
Discussion started by: figaro
2 Replies