NAG CL Interface
s14agc (gamma_​log_​complex)

Settings help

CL Name Style:

1 Purpose

s14agc returns the value of the logarithm of the gamma function lnΓ(z) for complex z, .

2 Specification

#include <nag.h>
Complex  s14agc (Complex z, NagError *fail)
The function may be called by the names: s14agc, nag_specfun_gamma_log_complex or nag_complex_log_gamma.

3 Description

s14agc evaluates an approximation to the logarithm of the gamma function lnΓ(z) defined for Re(z)>0 by
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.
s14agc 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-12)lnz-z+12ln2π+zk=1K B2k2k(2k-1) z-2k+RK(z) if ​xx00, = lnΓ(z+n)-lnν=0 n-1(z+ν) if ​x0>x0, = lnπ-lnΓ(1-z)-ln(sinπ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 function uses the values K=10 and x0=7. The remainder term RK(z) is discussed in Section 7.
To obtain the value of lnΓ(z) when z is real and positive, s14abc 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 Input
On entry: the argument z of the function.
Constraint: must not be ‘too close’ (see Section 6) to a non-positive integer when
2: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL 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 CL Interface for further information.
On entry, is ‘too close’ to a non-positive integer when, nint(

7 Accuracy

The remainder term RK(z) satisfies the following error bound:
|RK(z)| |B2K| |(2K-1)| z1-2K |B2K| |(2K-1)| x1-2Kif ​x0.  
Thus |R10(7)|<2.5×10-15 and hence in theory the function is capable of achieving an accuracy of approximately 15 significant digits.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
s14agc is not threaded in any implementation.

9 Further Comments


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 (s14agce.c)

10.2 Program Data

Program Data (s14agce.d)

10.3 Program Results

Program Results (s14agce.r)