S14AFF (PDF version)
S Chapter Contents
S Chapter Introduction
NAG Library Manual

NAG Library Routine Document

S14AFF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

S14AFF returns the value of the kth derivative of the psi function ψz for complex z and k=0,1,,4, via the function name.

2  Specification

FUNCTION S14AFF ( Z, K, IFAIL)
COMPLEX (KIND=nag_wp) S14AFF
INTEGER  K, IFAIL
COMPLEX (KIND=nag_wp)  Z

3  Description

S14AFF evaluates an approximation to the kth derivative of the psi function ψz given by
ψ k z=dkdzk ψz=dkdzk ddz logeΓz ,
where z=x+iy is complex provided y0 and k=0,1,,4. If y=0, z is real and thus ψ k z is singular when z=0,-1,-2,.
Note that ψ k z is also known as the polygamma function. Specifically, ψ 0 z is often referred to as the digamma function and ψ 1 z as the trigamma function in the literature. Further details can be found in Abramowitz and Stegun (1972).
S14AFF is based on a modification of the method proposed by Kölbig (1972).
To obtain the value of ψ k z when z is real, S14AEF 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  Parameters

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:     K – INTEGERInput
On entry: the function ψkz to be evaluated.
Constraint: 0K4.
3:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. 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 -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 parameter, 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,K<0,
orK>4,
orReZ is ‘too close’ to a non-positive integer when ImZ=0.0. That is, abs ReZ - nintReZ < machine precision × nint absReZ .
IFAIL=2
The evaluation has been abandoned due to the likelihood of overflow. The result is returned as zero.

7  Accuracy

Empirical tests have shown that the maximum relative error is a loss of approximately two decimal places of precision.

8  Further Comments

None.

9  Example

This example evaluates the psi (trigamma) function ψ 1 z at z=-1.5+2.5i, and prints the results.

9.1  Program Text

Program Text (s14affe.f90)

9.2  Program Data

Program Data (s14affe.d)

9.3  Program Results

Program Results (s14affe.r)


S14AFF (PDF version)
S Chapter Contents
S Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012