naginterfaces.library.specfun.polygamma

naginterfaces.library.specfun.polygamma(x)[source]

polygamma returns a value of the function , where is the psi function .

For full information please refer to the NAG Library document for s14ac

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/s/s14acf.html

Parameters
xfloat

The argument of the function.

Returns
pgxfloat

The value of the function , where is the psi function .

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

Computation halted due to likelihood of underflow. may be too large. .

(errno )

Computation halted due to likelihood of overflow. may be too small. .

Notes

polygamma returns a value of the function . The psi function is computed without the logarithmic term so that when is large, sums or differences of psi functions may be computed without unnecessary loss of precision, by analytically combining the logarithmic terms. For example, the difference has an asymptotic behaviour for large given by .

Computing directly would amount to subtracting two large numbers which are close to and to produce a small number close to , resulting in a loss of significant digits. However, using this function to compute , we can compute , and the dominant logarithmic term may be computed accurately from its power series when is large. Thus we avoid the unnecessary loss of precision.

The function is derived from the function PSIFN in Amos (1983).

References

NIST Digital Library of Mathematical Functions

Amos, D E, 1983, Algorithm 610: A portable FORTRAN subroutine for derivatives of the psi function, ACM Trans. Math. Software (9), 494–502