For n a positive integer the Digamma function Psi(n) = −gamma + 1 + 1/2 + 1/3 + ... + 1/(n−1) = Sum{k=1, n−1}[1/k], where gamma = −Psi(1) = 5.77215,66490,15328,6...E−1 is Euler's constant. Psi is defined for all values of x except for integers <= 0 where it is infinite.
For example, Psi(2) = −0.5772156649... + 1 = 0.422784335... .
Here are some notes from my program XPCalc - Extra Precision Floating-Point Calculator http://www.oocities.org/hjsmithh/download.html#XPCalc :
Psi(x) = DigammaFunction(x):
Psi(x) = logarithmic derivative of the Gamma function d/dx(Ln(Gam(x))) = Gam'(x) / Gam(x). For x >= −5, the asymptotic formula with Bernoulli numbers is used to compute this. If x is an integer <= zero, an alarm is displayed. For non-integer negative x < −5, the reflection formula is used:
For large x (x > n),
where B(2*k) are Bernoulli numbers. For small x,
This is based on Psi(x) = Psi(x+1) − 1/x. n is computed by a heuristic, n = max( (int)((digits^1.5) / 13.0 + 1 − x), 0), where digits is the current decimal digits in a computed mantissa.
Return to Number Theory, Algorithms, and Real Functions
Return to Harry's Home Page