伽玛 ()- 伽玛函数

格式

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

语言级别

ILE C 扩展

线程安全

描述

gamma() 函数计算 G (x) (ln (| G (x) |)) 的绝对值的自然对数,其中

γ () 函数

自变量 x 必须是正实数值。

返回值

gamma() 函数返回 ln (| G (x) |)的值。 如果 x 为负值,那么 errno 设置为 EDOM。 如果结果导致溢出,那么 gamma() 将返回 HUGE_VAL 并将 errno 设置为 ERANGE

示例

此示例使用 gamma() 来计算 ln (| G (x) |),其中 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
*/

示例