hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_specfun_psi_deriv_real (s14ae)

Purpose

nag_specfun_psi_deriv_real (s14ae) returns the value of the kkth derivative of the psi function ψ(x)ψ(x) for real xx and k = 0,1,,6k=0,1,,6, via the function name.

Syntax

[result, ifail] = s14ae(x, k)
[result, ifail] = nag_specfun_psi_deriv_real(x, k)

Description

nag_specfun_psi_deriv_real (s14ae) evaluates an approximation to the kkth derivative of the psi function ψ(x)ψ(x) given by
ψ(k)(x) = (dk)/(dxk)ψ(x) = (dk)/(dxk) (d/(dx)logeΓ(x)) ,
ψ (k) (x)=dkdxk ψ(x)=dkdxk (ddx logeΓ(x) ) ,
where xx is real with x0,1,2,x0,-1,-2, and k = 0,1,,6k=0,1,,6. For negative noninteger values of xx, the recurrence relationship
ψ(k)(x + 1) = ψ(k)(x) + (dk)/(dxk) (1/x)
ψ (k) (x+1)=ψ (k) (x)+dkdxk (1x)
is used. The value of ((1)k + 1ψ(k)(x))/(k ! ) (-1)k+1ψ (k) (x) k!  is obtained by a call to nag_specfun_polygamma_deriv (s14ad), which is based on the function PSIFN in Amos (1983).
Note that ψ(k)(x)ψ (k) (x) is also known as the polygamma function. Specifically, ψ(0)(x)ψ (0) (x) is often referred to as the digamma function and ψ(1)(x)ψ (1) (x) as the trigamma function in the literature. Further details can be found in Abramowitz and Stegun (1972).

References

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

Parameters

Compulsory Input Parameters

1:     x – double scalar
The argument xx of the function.
Constraint: xx must not be ‘too close’ (see Section [Error Indicators and Warnings]) to a non-positive integer.
2:     k – int64int32nag_int scalar
The function ψ(k)(x)ψ(k)(x) to be evaluated.
Constraint: 0k60k6.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     result – double scalar
The result of the function.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,k < 0k<0,
ork > 6k>6,
orx is ‘too close’ to a non-positive integer. That is, abs(xnint(x)) < machine precision × nint(abs(x)) abs( x - nint(x) ) < machine precision × nint(abs(x)) .
  ifail = 2ifail=2
The evaluation has been abandoned due to the likelihood of underflow. The result is returned as zero.
  ifail = 3ifail=3
The evaluation has been abandoned due to the likelihood of overflow. The result is returned as zero.

Accuracy

All constants in nag_specfun_polygamma_deriv (s14ad) are given to approximately 1818 digits of precision. If tt 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 p = min (t,18)p=min(t,18). 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 ψ(0)(x)-ψ (0) (x) have shown somewhat improved accuracy, except at points near the positive zero of ψ(0)(x)ψ (0) (x) at x = 1.46x=1.46, where only absolute accuracy can be obtained.

Further Comments

None.

Example

function nag_specfun_psi_deriv_real_example
x = 2.5;
k = int64(2);
[result, ifail] = nag_specfun_psi_deriv_real(x, k)
 

result =

   -0.2362


ifail =

                    0


function s14ae_example
x = 2.5;
k = int64(2);
[result, ifail] = s14ae(x, k)
 

result =

   -0.2362


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013