NAG Library Routine Document
S14AEF returns the value of the th derivative of the psi function for real and , via the function name.
|REAL (KIND=nag_wp) S14AEF
S14AEF evaluates an approximation to the
th derivative of the psi function
is real with
. For negative noninteger values of
, the recurrence relationship
is used. The value of
is obtained by a call to S14ADF
, which is based on the routine 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
- 1: X – REAL (KIND=nag_wp)Input
On entry: the argument of the function.
must not be ‘too close’ (see Section 6
) to a non-positive integer.
- 2: K – INTEGERInput
On entry: the function to be evaluated.
- 3: IFAIL – INTEGERInput/Output
must be set to
. If you are unfamiliar with this parameter you should refer to Section 3.3
in the Essential Introduction 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
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
. When the value is used it is essential to test the value of IFAIL on exit.
unless the routine detects an error or a warning has been flagged (see Section 6
6 Error Indicators and Warnings
If on entry
, explanatory error messages are output on the current error message unit (as defined by X04AAF
Errors or warnings detected by the routine:
|or||X is ‘too close’ to a non-positive integer. That is, .|
The evaluation has been abandoned due to the likelihood of underflow. The result is returned as zero.
The evaluation has been abandoned due to the likelihood of overflow. The result is returned as zero.
All constants in S14ADF
are given to approximately
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.
This example evaluates at , and prints the results.
9.1 Program Text
Program Text (s14aefe.f90)
9.2 Program Data
Program Data (s14aefe.d)
9.3 Program Results
Program Results (s14aefe.r)