s Chapter Contents
s Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_complex_polygamma (s14afc)

## 1  Purpose

nag_complex_polygamma (s14afc) returns the value of the $k$th derivative of the psi function $\psi \left(z\right)\text{,}$ for complex $z$ and $k=0,1,\dots ,4$.

## 2  Specification

 #include #include
 Complex nag_complex_polygamma (Complex z, Integer k, NagError *fail)

## 3  Description

nag_complex_polygamma (s14afc) evaluates an approximation to the $k$th derivative of the psi function $\psi \left(z\right)$ given by
 $ψ k z = d k dz k ψ z = d k dz k d dz log e ⁡Γ 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$.
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).
nag_complex_polygamma (s14afc) 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, nag_real_polygamma (s14aec) 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:     zComplexInput
On entry: the argument $z$ of the function.
Constraint: ${\mathbf{z}}\mathbf{.}\mathbf{re}$ must not be ‘too close’ (see Section 6) to a non-positive integer when ${\mathbf{z}}\mathbf{.}\mathbf{im}\text{}=0.0$.
2:     kIntegerInput
On entry: the function ${\psi }^{\left(k\right)}\left(z\right)$ to be evaluated.
Constraint: $0\le {\mathbf{k}}\le 4$.
3:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

NE_COMPLEX
On entry, ${\mathbf{z}}=\left(〈\mathit{\text{value}}〉,〈\mathit{\text{value}}〉\right)$.
Constraint: ${\mathbf{z}}\mathbf{.}\mathbf{re}$ must not be ‘too close’ to a non-positive integer when ${\mathbf{z}}\mathbf{.}\mathbf{im}=0.0$. That is, .
NE_INT
On entry, ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: $0\le {\mathbf{k}}\le 4$.
NE_INTERNAL_ERROR
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.
NE_OVERFLOW_LIKELY
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.

None.

## 9  Example

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

### 9.1  Program Text

Program Text (s14afce.c)

### 9.2  Program Data

Program Data (s14afce.d)

### 9.3  Program Results

Program Results (s14afce.r)