NAG FL Interface
s14aff (psi_​deriv_​complex)

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

Fortran Interface
Function s14aff ( z, k, ifail)
Complex (Kind=nag_wp) :: s14aff
Integer, Intent (In) :: k
Integer, Intent (Inout) :: ifail
Complex (Kind=nag_wp), Intent (In) :: z
C Header Interface
#include <nag.h>
Complex  s14aff_ (const Complex *z, const Integer *k, Integer *ifail)
The routine may be called by the names s14aff or nagf_specfun_psi_deriv_complex.

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 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: k Integer Input
On entry: the function ψkz to be evaluated.
Constraint: 0k4.
3: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 4 in the Introduction to the NAG Library FL Interface 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, k=value.
Constraint: k4.
On entry, k=value.
Constraint: k0.
On entry, Re(z) is ‘too close’ to a non-positive integer when Im(z)=0.0: Re(z)=value, nintRe(z)=value.
ifail=2
Evaluation abandoned due to likelihood of overflow.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

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

8 Parallelism and Performance

s14aff is not threaded in any implementation.

9 Further Comments

None.

10 Example

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

10.1 Program Text

Program Text (s14affe.f90)

10.2 Program Data

Program Data (s14affe.d)

10.3 Program Results

Program Results (s14affe.r)