POLYGAMMA
The polygamma family generalizes the digamma function to higher derivatives of the logarithm of the gamma function. It is useful in advanced approximation theory, statistical inference, and special-function series expansions.
For nonnegative integer order n, it is:
\psi^{(n)}(x)=\frac{d^{n+1}}{dx^{n+1}}\ln\Gamma(x)
This wrapper evaluates \psi^{(n)}(x) for real x and integer derivative order.
Excel Usage
=POLYGAMMA(n, x)
n(int, required): Nonnegative derivative order.x(float, required): Real input value.
Returns (float): Polygamma value of the specified order at the input.
Example 1: Zeroth-order polygamma equals digamma
Inputs:
| n | x |
|---|---|
| 0 | 3 |
Excel formula:
=POLYGAMMA(0, 3)
Expected output:
0.922784
Example 2: First-order polygamma at moderate input
Inputs:
| n | x |
|---|---|
| 1 | 3 |
Excel formula:
=POLYGAMMA(1, 3)
Expected output:
0.394934
Example 3: Second-order polygamma at larger input
Inputs:
| n | x |
|---|---|
| 2 | 10 |
Excel formula:
=POLYGAMMA(2, 10)
Expected output:
-0.0110498
Example 4: First-order polygamma at fractional input
Inputs:
| n | x |
|---|---|
| 1 | 2.5 |
Excel formula:
=POLYGAMMA(1, 2.5)
Expected output:
0.490358
Python Code
from scipy.special import polygamma as scipy_polygamma
def polygamma(n, x):
"""
Compute the n-th derivative of the digamma function.
See: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.polygamma.html
This example function is provided as-is without any representation of accuracy.
Args:
n (int): Nonnegative derivative order.
x (float): Real input value.
Returns:
float: Polygamma value of the specified order at the input.
"""
try:
if n < 0:
return "Error: n must be nonnegative"
return float(scipy_polygamma(n, x))
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Nonnegative derivative order.
Real input value.