Rate This Document
Findability
Accuracy
Completeness
Readability

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

  • For gammaf, x is of single-precision floating-point type.
  • For gamma, x is of double-precision floating-point type.

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:
    // 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
     * 
     * */