NAG Library Function Document
nag_real_polygamma (s14aec) returns the value of the th derivative of the psi function for real and .
||nag_real_polygamma (double x,
nag_real_polygamma (s14aec) evaluates an approximation to the
th derivative of the psi function
is real with
. For negative non-integer values of
, the recurrence relationship
is used. The value of
is obtained by a call to a function based on PSIFN in Amos (1983)
is also known as the polygamma
is often referred to as the digamma
as the trigamma
function in the literature. Further details can be found in Abramowitz and Stegun (1972)
Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Amos D E (1983) Algorithm 610: A portable FORTRAN subroutine for derivatives of the psi function ACM Trans. Math. Software 9 494–502
x – doubleInput
On entry: the argument of the function.
must not be ‘too close’ (see Section 6
) to a non-positive integer.
k – IntegerInput
On entry: the function to be evaluated.
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
On entry, .
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
The evaluation has been abandoned due to the likelihood of overflow. The result is returned as zero.
must not be ‘too close’ to a non-positive integer. That is, machine precision
The evaluation has been abandoned due to the likelihood of underflow. The result is returned as zero.
All constants in the underlying functions are given to approximately 18 digits of precision. If
denotes the number of digits of precision in the floating point arithmetic being used, then clearly the maximum number in the results obtained is limited by
. Empirical tests by Amos (1983)
have shown that the maximum relative error is a loss of approximately two decimal places of precision. Further tests with the function
have shown somewhat improved accuracy, except at points near the positive zero of
, where only absolute accuracy can be obtained.
The example program evaluates at , and prints the results.
9.1 Program Text
Program Text (s14aece.c)
9.2 Program Data
Program Data (s14aece.d)
9.3 Program Results
Program Results (s14aece.r)