ALGAMS
Returns the logarithm of the absolute value of the gamma function and the sign of gamma.
Required Arguments
X — Argument for which the logarithm of the absolute value of the gamma function is desired. (Input)
ALGM — Result of the calculation. (Output)
S — Sign of gamma(X). (Output)
If gamma(X) is greater than or equal to zero, S = 1.0. If gamma(X) is less than zero, S = ‑1.0.
FORTRAN 90 Interface
Generic: CALL ALGAMS (X, ALGM, S)
Specific: The specific interface names are S_ALGAMS and D_ALGAMS.
FORTRAN 77 Interface
Single: CALL ALGAMS (X, ALGM, S)
Double: The double precision function name is DLGAMS.
Description
The function
ALGAMS computes ln
∣Γ(
x)
∣ and the sign of
Γ(
x). See
GAMMA for the definition of
Γ(
x).
The result overflows if ∣x∣ is too large. The accuracy is worse than half precision if x is too close to a negative integer.
Comments
Informational Error
Type | Code | Description |
---|
3 | 2 | Result of ALGAMS is accurate to less than one‑half precision because X is too near a negative integer. |
Example
In this example, ln ∣Γ(1.85)∣ and the sign of Γ(1.85) are computed and printed.
USE ALGAMS_INT
USE UMACH_INT
IMPLICIT NONE
! Declare variables
INTEGER NOUT
REAL VALUE, S, X
! Compute
X = 1.85
CALL ALGAMS(X, VALUE, S)
! Print the results
CALL UMACH (2, NOUT)
WRITE (NOUT,99998) X, VALUE
99998 FORMAT (' Log Abs(Gamma(', F6.3, ')) = ', F6.3)
WRITE (NOUT,99999) X, S
99999 FORMAT (' Sign(Gamma(', F6.3, ')) = ', F6.2)
END
Output
Log Abs(Gamma( 1.850)) = -0.056
Sign(Gamma( 1.850)) = 1.00