tgammaのヘルプ・マニュアル
日本語 英語
tgamma --help
man tgamma
TGAMMA(3) Linux Programmer’s Manual TGAMMA(3)
名前
tgamma, tgammaf, tgammal - 本当のガンマ関数
書式
#include
double tgamma(double x);
float tgammaf(float x);
long double tgammal(long double x);
-lm でリンクする。
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
tgamma(), tgammaf(), tgammal(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE;
or cc -std=c99
説明
ガンマ関数は以下のように定義される:
Gamma(x) = t^(x-1) e^-t dt の 0 から無限大までの積分
この関数は正でない整数を除くすべての実数に対して定義されている。非負 の
整数 m に関して、以下が成立する:
Gamma(m+1) = m!
より一般的には、すべての x に関して以下が成立する:
Gamma(x+1) = x * Gamma(x)
さらに、極を除くすべての x で次式も成立する:
Gamma(x) * Gamma(1 - x) = PI / sin(PI * x)
返り値
成功すると、これらの関数は Gamma(x) を返す。
x が NaN の場合、NaN が返される。
x が正の無限大の場合、正の無限大が返される。
x が 負の整数か負の無限大の場合、領域エラー (domain error) が発生し、
NaN が返される。
結果がオーバーフローする場合、範囲エラー (range error) が発生し、各関数
はそれぞれ HUGE_VAL, HUGE_VALF, HUGE_VALL, を返す。この際、数学的に正し
い符号が付与される。
結果がアンダーフローする場合、範囲エラー (range error) が発生し、関数は
0 をを返す。この際、数学的に正しい符号が付与される。
x が -0 か +0 の場合、極エラー (pole error) が発生し、各関数はそれぞれ
HUGE_VAL, HUGE_VALF, HUGE_VALL, を返す。 0 と同じ符号が付与される。
エラー
これらの関数を呼び出した際にエラーが発生したかの判定方法についての情 報
は math_error(7) を参照のこと。
以下のエラーが発生する可能性がある。
領域エラー: x が負の整数か負の無限大
errno に EDOM が 設 定される。不正 (invalid) 浮動小数点例外
(FE_INVALID) が上がる (「バグ」の節を参照)。
極エラー (pole error): x が +0 か -0
errno に ERANGE が設定される。 0 による除算 (divide-by-zero) 浮
動小数点例外 (FE_DIVBYZERO) が上がる。
範囲エラー (range error): 結果のオーバーフロー
errno に ERANGE が 設定される。オーバーフロー浮動小数点例外
(FE_OVERFLOW) が上がる。
glibc では、C99 や POSIX.1-2001 で規定されていない以下のエラーも起こ り
得る。
範囲エラー (range error): 結果のアンダーフロー
アンダーフロー浮動小数点例外 (FE_UNDERFLOW) が上がる。この場合は
errno は設定されない。
バージョン
これらの関数は glibc バージョン 2.1 で初めて登場した。
準拠
C99, POSIX.1-2001.
注意
この関数を「本当の (true) ガンマ関数」と呼ばなければならなかった。な ぜ
な ら、他の値を返す gamma(3) という関数がすでに存在するからである (詳細
については gamma(3) を参照)。
バグ
x が負の無限大の場合、 errno は設定されない (EDOM が設定されるべきで あ
る)。
glibc バージョン 2.3.3 以前では、引き数に +0 や -0 を渡すと、極エラーで
はなく、領域エラーを間違って発生していた (領域エラーの場合、 errno に
EDOM を設定され、 FE_INVALID 例外が発生する)。
関連項目
gamma(3), lgamma(3)
GNU 2008-08-11 TGAMMA(3)
TGAMMA(3) Linux Programmer’s Manual TGAMMA(3)
NAME
tgamma, tgammaf, tgammal - true gamma function
SYNOPSIS
#include
double tgamma(double x);
float tgammaf(float x);
long double tgammal(long double x);
Link with -lm.
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
tgamma(), tgammaf(), tgammal(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE;
or cc -std=c99
DESCRIPTION
The Gamma function is defined by
Gamma(x) = integral from 0 to infinity of t^(x-1) e^-t dt
It is defined for every real number except for non-positive integers.
For non-negative integral m one has
Gamma(m+1) = m!
and, more generally, for all x:
Gamma(x+1) = x * Gamma(x)
Furthermore, the following is valid for all values of x outside the
poles:
Gamma(x) * Gamma(1 - x) = PI / sin(PI * x)
RETURN VALUE
On success, these functions return Gamma(x).
If x is a NaN, a NaN is returned.
If x is positive infinity, positive infinity is returned.
If x is a negative integer, or is negative infinity, a domain error
occurs, and a NaN is returned.
If the result overflows, a range error occurs, and the functions return
HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the correct math-
ematical sign.
If the result underflows, a range error occurs, and the functions
return 0, with the correct mathematical sign.
If x is -0 or +0, a pole error occurs, and the functions return
HUGE_VAL, HUGE_VALF, or HUGE_VALL, respectively, with the same sign as
the 0.
ERRORS
See math_error(7) for information on how to determine whether an error
has occurred when calling these functions.
The following errors can occur:
Domain error: x is a negative integer, or negative infinity
errno is set to EDOM. An invalid floating-point exception
(FE_INVALID) is raised (but see BUGS).
Pole error: x is +0 or -0
errno is set to ERANGE. A divide-by-zero floating-point excep-
tion (FE_DIVBYZERO) is raised.
Range error: result overflow
errno is set to ERANGE. An overflow floating-point exception
(FE_OVERFLOW) is raised.
glibc also gives the following error which is not specified in C99 or
POSIX.1-2001.
Range error: result underflow
An underflow floating-point exception (FE_UNDERFLOW) is raised.
errno is not set for this case.
VERSIONS
These functions first appeared in glibc in version 2.1.
CONFORMING TO
C99, POSIX.1-2001.
NOTES
This function had to be called "true gamma function" since there is
already a function gamma(3) that returns something else (see gamma(3)
for details).
BUGS
If x is negative infinity, errno is not set (it should be set to EDOM).
In glibc versions 2.3.3 and earlier, an argument of +0 or -0 incor-
rectly produced a domain error (errno set to EDOM and an FE_INVALID
exception raised), rather than a pole error.
SEE ALSO
gamma(3), lgamma(3)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
GNU 2008-08-11 TGAMMA(3)