The routine may be called by the names s14agf or nagf_specfun_gamma_log_complex.
s14agf evaluates an approximation to the logarithm of the gamma function defined for by
where 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
where , are Bernoulli numbers (see Abramowitz and Stegun (1972)) and 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 and . The remainder term is discussed in Section 7.
To obtain the value of when 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: – 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: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , 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, .
An unexpected error has been triggered by this routine. Please
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
The remainder term satisfies the following error bound:
Thus and hence in theory the routine is capable of achieving an accuracy of approximately significant digits.
8Parallelism and Performance
s14agf is not threaded in any implementation.
This example evaluates the logarithm of the gamma function at , and prints the results.