Rate This Document
Findability
Accuracy
Completeness
Readability

lgamma

Compute the natural logarithm of the absolute gamma value of x. The input parameter is a real number.

Interface Definition

C interface:

float lgammaf(float x);

double lgamma(double x);

Parameters

Parameter

Type

Description

Input/Output

x

  • For lgammaf, x is of single-precision floating-point type.
  • For lgamma, 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 +∞.

Dependency

C: "km.h"

Example

C interface:
    // print result
    printf("lgamma(0.0) = %.15f\n", lgamma(0.0));
    printf("lgamma(-0.0) = %.15f\n", lgamma(-0.0));
    printf("lgamma(0.25) = %.15f\n", lgamma(0.25));
    printf("lgamma(-0.25) = %.15f\n", lgamma(-0.25));
    printf("lgamma(0.5) = %.15f\n", lgamma(0.5));
    printf("lgamma(-0.5) = %.15f\n", lgamma(-0.5));
    printf("lgamma(1.0) = %.15f\n", lgamma(1.0));
    printf("lgamma(-1.0) = %.15f\n", lgamma(-1.0));
    printf("lgamma(2.0) = %.15f\n", lgamma(2.0));
    printf("lgamma(-2.0) = %.15f\n", lgamma(-2.0));
    printf("lgamma(INFINITY) = %.15f\n", lgamma(INFINITY));
    printf("lgamma(-INFINITY) = %.15f\n", lgamma(-INFINITY));
    printf("lgamma(NAN) = %.15f\n", lgamma(NAN));
    printf("lgamma(-NAN) = %.15f\n", lgamma(-NAN));
    /* 
     * lgamma(0.0) = inf
     * lgamma(-0.0) = inf
     * lgamma(0.25) = 1.288022524698077
     * lgamma(-0.25) = 1.589575312551186
     * lgamma(0.5) = 0.572364942924700
     * lgamma(-0.5) = 1.265512123484645
     * lgamma(1.0) = 0.000000000000000
     * lgamma(-1.0) = inf
     * lgamma(2.0) = 0.000000000000000
     * lgamma(-2.0) = inf
     * lgamma(INFINITY) = inf
     * lgamma(-INFINITY) = inf
     * lgamma(NAN) = nan
     * lgamma(-NAN) = -nan
     * 
     * */