Special functions
Digamma function
special.digammaAlso called digamma, psi function, psi, polygamma 0
The logarithmic derivative Γ′(x)/Γ(x), written as an absolutely convergent series; γ is the Euler–Mascheroni constant. ψ(n) = Hn−1 − γ for whole n, with H the harmonic numbers.
Notation
the argument
x > 0
Result: the digamma function
scalar
Worked examples
Each result is solved exactly and confirmed by two independent computations.
Given
Result
≈ -0.577215664902
Given
Result
≈ 0.422784335098
Given
Result
≈ -1.96351002602
Given
Result
≈ -3.13203378002
Common mistakes
Uses ln x as the value
ln x is the leading term of the large-x expansion; the next term is −1/(2x), so the error stays visible at every moderate x.
Fix: Use a library digamma, or apply ψ(x) = ψ(x + 1) − 1/x until x is large and then the asymptotic series.
Drops the −γ term
The series alone is ψ(x) + γ, off by the constant 0.5772….
Fix: Subtract the Euler–Mascheroni constant.
Returns ln Γ(x) instead of its derivative
ln Γ(x) is the antiderivative of ψ(x), a different function.
Fix: Differentiate: ψ(x) = d/dx ln Γ(x).
Sources
DLMF, eq. 5.7.6
NIST Digital Library of Mathematical Functions. https://dlmf.nist.gov/ Release 1.2.8 of 2026-09-15. F. W. J. Olver, A. B. Olde Daalhuis, D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller, B. V. Saunders, H. S. Cohl, and M. A. McClain, eds.
DLMF, eq. 5.2.2
NIST Digital Library of Mathematical Functions. https://dlmf.nist.gov/ Release 1.2.8 of 2026-09-15. F. W. J. Olver, A. B. Olde Daalhuis, D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller, B. V. Saunders, H. S. Cohl, and M. A. McClain, eds.