hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_specfun_gamma_log_complex (s14ag)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_specfun_gamma_log_complex (s14ag) returns the value of the logarithm of the gamma function lnΓz for complex z, via the function name.

Syntax

[result, ifail] = s14ag(z)
[result, ifail] = nag_specfun_gamma_log_complex(z)

Description

nag_specfun_gamma_log_complex (s14ag) 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.
nag_specfun_gamma_log_complex (s14ag) 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 function uses the values K=10 and x0=7. The remainder term RKz is discussed in Accuracy.
To obtain the value of lnΓz when z is real and positive, nag_specfun_gamma_log_real (s14ab) can be used.

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

Parameters

Compulsory Input Parameters

1:     z – complex scalar
The argument z of the function.
Constraint: Re(z) must not be ‘too close’ (see Error Indicators and Warnings) to a non-positive integer when Im(z)=0.0.

Optional Input Parameters

None.

Output Parameters

1:     result – complex scalar
The result of the function.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   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.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

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 function is capable of achieving an accuracy of approximately 15 significant digits.

Further Comments

None.

Example

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


fprintf('s14ag example results\n\n');

z =  -1.5 + 2.5i;
[lgz, ifail] = s14ag(z);

disp('      z           ln(Gamma(z))');
fprintf('%5.1f%+5.1fi', real(z), imag(z));
fprintf('  %12.4e%+12.4ei\n', real(lgz), imag(lgz));


s14ag example results

      z           ln(Gamma(z))
 -1.5 +2.5i   -5.0140e+00 -4.0718e+00i

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015