DPSIFN(3)

SYNOPSIS
SUBROUTINE DPSIFN (X, N, KODE, M, ANS, NZ, IERR)

NAME
dpsifn - Compute derivatives of the Psi function.

LIBRARY
SLATEC

CATEGORY
C7C

TYPE
DOUBLE PRECISION (PSIFN-S, DPSIFN-D)

KEYWORDS
DERIVATIVES OF THE GAMMA FUNCTION, POLYGAMMA FUNCTION, PSI FUNCTION

AUTHOR
Amos, D. E., (SNLA)

DESCRIPTION
The following definitions are used in DPSIFN: Definition 1 PSI(X) = d/dx (ln(GAMMA(X)), the first derivative of the log GAMMA function. Definition 2 K K PSI(K,X) = d /dx (PSI(X)), the K-th derivative of PSI(X). ___________________________________________________________________ DPSIFN computes a sequence of SCALED derivatives of the PSI function; i.e. for fixed X and M it computes the M-member sequence ((-1)**(K+1)/GAMMA(K+1))*PSI(K,X) for K = N,...,N+M-1 where PSI(K,X) is as defined above. For KODE=1, DPSIFN returns the scaled derivatives as described. KODE=2 is operative only when K=0 and in that case DPSIFN returns -PSI(X) + LN(X). That is, the logarithmic behavior for large X is removed when KODE=2 and K=0. When sums or differences of PSI functions are computed the logarithmic terms can be combined analytically and computed separately to help retain significant digits. Note that CALL DPSIFN(X,0,1,1,ANS) results in ANS = -PSI(X) Input X is DOUBLE PRECISION X - Argument, X .gt. 0.0D0 N - First member of the sequence, 0 .le. N .le. 100 N=0 gives ANS(1) = -PSI(X) for KODE=1 -PSI(X)+LN(X) for KODE=2 KODE - Selection parameter KODE=1 returns scaled derivatives of the PSI function. KODE=2 returns scaled derivatives of the PSI function EXCEPT when N=0. In this case, ANS(1) = -PSI(X) + LN(X) is returned. M - Number of members of the sequence, M.ge.1 Output ANS is DOUBLE PRECISION ANS - A vector of length at least M whose first M components contain the sequence of derivatives scaled according to KODE. NZ - Underflow flag NZ.eq.0, A normal return NZ.ne.0, Underflow, last NZ components of ANS are set to zero, ANS(M-K+1)=0.0, K=1,...,NZ IERR - Error flag IERR=0, A normal return, computation completed IERR=1, Input error, no computation IERR=2, Overflow, X too small or N+M-1 too large or both IERR=3, Error, N too large. Dimensioned array TRMR(NMAX) is not large enough for N The nominal computational accuracy is the maximum of unit roundoff (=D1MACH(4)) and 1.0D-18 since critical constants are given to only 18 digits. PSIFN is the single precision version of DPSIFN. *Long Description: The basic method of evaluation is the asymptotic expansion for large X.ge.XMIN followed by backward recursion on a two term recursion relation W(X+1) + X**(-N-1) = W(X). This is supplemented by a series SUM( (X+K)**(-N-1) , K=0,1,2,... ) which converges rapidly for large N. Both XMIN and the number of terms of the series are calculated from the unit roundoff of the machine environment.

REFERENCES
Handbook of Mathematical Functions, National Bureau of Standards Applied Mathematics Series 55, edited by M. Abramowitz and I. A. Stegun, equations 6.3.5, 6.3.18, 6.4.6, 6.4.9 and 6.4.10, pp.258-260, 1964. D. E. Amos, A portable Fortran subroutine for derivatives of the Psi function, Algorithm 610, ACM Transactions on Mathematical Software 9, 4 (1983), pp. 494-502.

ROUTINES CALLED
D1MACH, I1MACH

REVISION HISTORY (YYMMDD)
820601 DATE WRITTEN
890531 Changed all specific intrinsics to generic. (WRB)
890911 Removed unnecessary intrinsics. (WRB)
891006 Cosmetic changes to prologue. (WRB)
891006 REVISION DATE from Version 3.2
891214 Prologue converted to Version 4.0 format. (BAB)
920501 Reformatted the REFERENCES section. (WRB)