nag_real_polygamma (s14aec) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_real_polygamma (s14aec)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_real_polygamma (s14aec) returns the value of the kth derivative of the psi function ψx for real x and k=0,1,,6.

2  Specification

#include <nag.h>
#include <nags.h>
double  nag_real_polygamma (double x, Integer k, NagError *fail)

3  Description

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

4  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

5  Arguments

1:     xdoubleInput
On entry: the argument x of the function.
Constraint: x must not be ‘too close’ (see Section 6) to a non-positive integer.
2:     kIntegerInput
On entry: the function ψkx to be evaluated.
Constraint: 0k6.
3:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_INT
On entry, k=value.
Constraint: k6.
On entry, k=value.
Constraint: k0.
NE_INTERNAL_ERROR
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 for assistance.
NE_OVERFLOW_LIKELY
Evaluation abandoned due to likelihood of overflow.
NE_REAL
On entry, x is ‘too close’ to a non-positive integer: x=value and nintx=value.
NE_UNDERFLOW_LIKELY
Evaluation abandoned due to likelihood of underflow.

7  Accuracy

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

8  Parallelism and Performance

Not applicable.

9  Further Comments

None.

10  Example

This example evaluates ψ 2 x at x=2.5, and prints the results.

10.1  Program Text

Program Text (s14aece.c)

10.2  Program Data

Program Data (s14aece.d)

10.3  Program Results

Program Results (s14aece.r)


nag_real_polygamma (s14aec) (PDF version)
s Chapter Contents
s Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2014