NAG Library Routine Document

1Purpose

s14aff returns the value of the $k$th derivative of the psi function $\psi \left(z\right)$ for complex $z$ and $k=0,1,\dots ,4$, via the function name.

2Specification

Fortran Interface
 Function s14aff ( z, k,
 Complex (Kind=nag_wp) :: s14aff Integer, Intent (In) :: k Integer, Intent (Inout) :: ifail Complex (Kind=nag_wp), Intent (In) :: z
#include <nagmk26.h>
 Complex s14aff_ (const Complex *z, const Integer *k, Integer *ifail)

3Description

s14aff evaluates an approximation to the $k$th derivative of the psi function $\psi \left(z\right)$ given by
 $ψ k z=dkdzk ψz=dkdzk ddz loge⁡Γz ,$
where $z=x+iy$ is complex provided $y\ne 0$ and $k=0,1,\dots ,4$. If $y=0$, $z$ is real and thus ${\psi }^{\left(k\right)}\left(z\right)$ is singular when $z=0,-1,-2,\dots \text{}$.
Note that ${\psi }^{\left(k\right)}\left(z\right)$ is also known as the polygamma function. Specifically, ${\psi }^{\left(0\right)}\left(z\right)$ is often referred to as the digamma function and ${\psi }^{\left(1\right)}\left(z\right)$ 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 ${\psi }^{\left(k\right)}\left(z\right)$ when $z$ is real, s14aef can be used.

4References

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

5Arguments

1:     $\mathbf{z}$ – Complex (Kind=nag_wp)Input
On entry: the argument $z$ of the function.
Constraint: $\mathrm{Re}\left({\mathbf{z}}\right)$ must not be ‘too close’ (see Section 6) to a non-positive integer when $\mathrm{Im}\left({\mathbf{z}}\right)=0.0$.
2:     $\mathbf{k}$ – IntegerInput
On entry: the function ${\psi }^{\left(k\right)}\left(z\right)$ to be evaluated.
Constraint: $0\le {\mathbf{k}}\le 4$.
3:     $\mathbf{ifail}$ – IntegerInput/Output
On entry: ifail must be set to $0$, . 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  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  is used it is essential to test the value of ifail on exit.
On exit: ${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

6Error Indicators and Warnings

If on entry ${\mathbf{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:
${\mathbf{ifail}}=1$
On entry, ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{k}}\le 4$.
On entry, ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{k}}\ge 0$.
On entry, $\mathrm{Re}\left({\mathbf{z}}\right)$ is ‘too close’ to a non-positive integer when $\mathrm{Im}\left({\mathbf{z}}\right)=0.0$: $\mathrm{Re}\left({\mathbf{z}}\right)=〈\mathit{\text{value}}〉$, $\mathrm{nint}\left(\mathrm{Re}\left({\mathbf{z}}\right)\right)=〈\mathit{\text{value}}〉$.
${\mathbf{ifail}}=2$
Evaluation abandoned due to likelihood of overflow.
${\mathbf{ifail}}=-99$
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
${\mathbf{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.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7Accuracy

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

8Parallelism and Performance

s14aff is not threaded in any implementation.

None.

10Example

This example evaluates the psi (trigamma) function ${\psi }^{\left(1\right)}\left(z\right)$ at $z=-1.5+2.5i$, and prints the results.

10.1Program Text

Program Text (s14affe.f90)

10.2Program Data

Program Data (s14affe.d)

10.3Program Results

Program Results (s14affe.r)