gamma
Compute the natural logarithm of the absolute gamma value of x. The input parameter is a real number.
Interface Definition
C interface:
float gammaf(float x);
double gamma(double x);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data |
Input |
Return Value
- The natural logarithm of the absolute gamma value of x is returned.
- If the input is NaN, the return value is NaN.
- If the input is +∞, the return value is +∞.
- If the input is –∞, the return value is +∞.
- If the input is +0, the return value is +∞.
- If the input is –0, the return value is +∞.
Dependencies
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | // print result printf("gamma(0.0) = %.15f\n", gamma(0.0)); printf("gamma(-0.0) = %.15f\n", gamma(-0.0)); printf("gamma(0.25) = %.15f\n", gamma(0.25)); printf("gamma(-0.25) = %.15f\n", gamma(-0.25)); printf("gamma(0.5) = %.15f\n", gamma(0.5)); printf("gamma(-0.5) = %.15f\n", gamma(-0.5)); printf("gamma(1.0) = %.15f\n", gamma(1.0)); printf("gamma(-1.0) = %.15f\n", gamma(-1.0)); printf("gamma(2.0) = %.15f\n", gamma(2.0)); printf("gamma(-2.0) = %.15f\n", gamma(-2.0)); printf("gamma(INFINITY) = %.15f\n", gamma(INFINITY)); printf("gamma(-INFINITY) = %.15f\n", gamma(-INFINITY)); printf("gamma(NAN) = %.15f\n", gamma(NAN)); printf("gamma(-NAN) = %.15f\n", gamma(-NAN)); /* * gamma(0.0) = inf * gamma(-0.0) = inf * gamma(0.25) = 1.288022524698077 * gamma(-0.25) = 1.589575312551186 * gamma(0.5) = 0.572364942924700 * gamma(-0.5) = 1.265512123484645 * gamma(1.0) = 0.000000000000000 * gamma(-1.0) = inf * gamma(2.0) = 0.000000000000000 * gamma(-2.0) = inf * gamma(INFINITY) = inf * gamma(-INFINITY) = inf * gamma(NAN) = nan * gamma(-NAN) = -nan * * */ |
Parent topic: Special Functions