NAG Library Routine Document

s14agf (gamma_log_complex)

1
Purpose

s14agf returns the value of the logarithm of the gamma function lnΓz for complex z, via the function name.

2
Specification

Fortran Interface
Function s14agf ( z, ifail)
Complex (Kind=nag_wp):: s14agf
Integer, Intent (Inout):: ifail
Complex (Kind=nag_wp), Intent (In):: z
C Header Interface
#include <nagmk26.h>
Complex  s14agf_ (const Complex *z, Integer *ifail)

3
Description

s14agf evaluates an approximation to the logarithm of the gamma function lnΓz defined for Rez>0 by
lnΓz=ln0e-ttz-1dt  
where z=x+iy is complex. It is extended to the rest of the complex plane by analytic continuation unless y=0, in which case z is real and each of the points z=0,-1,-2, is a singularity and a branch point.
s14agf is based on the method proposed by Kölbig (1972) in which the value of lnΓz is computed in the different regions of the z plane by means of the formulae
lnΓz = z-12lnz-z+12ln2π+zk=1K B2k2k2k-1 z-2k+RKz if ​xx00, = lnΓz+n-lnν=0 n-1z+ν if ​x0>x0, = lnπ-lnΓ1-z-lnsinπz if ​x<0,  
where n=x0-x, B2k are Bernoulli numbers (see Abramowitz and Stegun (1972)) and x is the largest integer x. Note that care is taken to ensure that the imaginary part is computed correctly, and not merely modulo 2π.
The routine uses the values K=10 and x0=7. The remainder term RKz is discussed in Section 7.
To obtain the value of lnΓz when z is real and positive, s14abf can be used.

4
References

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

5
Arguments

1:     z – Complex (Kind=nag_wp)Input
On entry: the argument z of the function.
Constraint: Re(z) must not be ‘too close’ (see Section 6) to a non-positive integer when Im(z)=0.0.
2:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, Rez is ‘too close’ to a non-positive integer when Imz=0.0. That is, absRez-nintRez<machine precision×nintabsRez.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

The remainder term RKz satisfies the following error bound:
RKz B2K 2K-1 z1-2K B2K 2K-1 x1-2Kif ​x0.  
Thus R107<2.5×10-15 and hence in theory the routine is capable of achieving an accuracy of approximately 15 significant digits.

8
Parallelism and Performance

s14agf is not threaded in any implementation.

9
Further Comments

None.

10
Example

This example evaluates the logarithm of the gamma function lnΓz at z=-1.5+2.5i, and prints the results.

10.1
Program Text

Program Text (s14agfe.f90)

10.2
Program Data

Program Data (s14agfe.d)

10.3
Program Results

Program Results (s14agfe.r)