NAG Library Routine Document
S14AGF returns the value of the logarithm of the gamma function for complex ,
via the function name.
|COMPLEX (KIND=nag_wp) S14AGF
S14AGF evaluates an approximation to the logarithm of the gamma function
is complex. It is extended to the rest of the complex plane by analytic continuation unless
, in which case
is real and each of the points
is a singularity and a branch point.
S14AGF is based on the method proposed by Kölbig (1972)
in which the value of
is computed in the different regions of the
plane by means of the formulae
are Bernoulli numbers (see Abramowitz and Stegun (1972)
is the largest integer
. Note that care is taken to ensure that the imaginary part is computed correctly, and not merely modulo
The routine uses the values
. The remainder term
is discussed in Section 7
To obtain the value of
is real and positive, S14ABF
can be used.
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Kölbig K S (1972) Programs for computing the logarithm of the gamma function, and the digamma function, for complex arguments Comp. Phys. Comm. 4 221–226
- 1: Z – COMPLEX (KIND=nag_wp)Input
On entry: the argument of the function.
must not be ‘too close’ (see Section 6
) to a non-positive integer when
- 2: IFAIL – INTEGERInput/Output
must be set to
. If you are unfamiliar with this parameter you should refer to Section 3.3
in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
|On entry,|| is ‘too close’ to a non-positive integer when . That is, .|
The remainder term
satisfies the following error bound:
and hence in theory the routine is capable of achieving an accuracy of approximately
This example evaluates the logarithm of the gamma function at , and prints the results.
9.1 Program Text
Program Text (s14agfe.f90)
9.2 Program Data
Program Data (s14agfe.d)
9.3 Program Results
Program Results (s14agfe.r)