# Digamma function

Digamma function $\psi(s)$ in the complex plane. The color of a point $s$ encodes the value of $\psi(s)$. Strong colors denote values close to zero and hue encodes the value's argument.

In mathematics, the digamma function is defined as the logarithmic derivative of the gamma function:[1][2]

$\psi(x) =\frac{d}{dx} \ln{\Gamma(x)}= \frac{\Gamma'(x)}{\Gamma(x)}.$

It is the first of the polygamma functions.

## Relation to harmonic numbers

The digamma function, often denoted also as ψ0(x), ψ0(x) or $\digamma$ (after the shape of the archaic Greek letter Ϝ digamma), is related to the harmonic numbers in that

$\psi(n) = H_{n-1}-\gamma\!$

where Hn is the nth harmonic number, and γ is the Euler-Mascheroni constant. For half-integer values, it may be expressed as

$\psi\left(n+{\frac{1}{2}}\right) = -\gamma - 2\ln 2 + \sum_{k=1}^n \frac{2}{2k-1}$

## Integral representations

If the real part of $x$ is positive then the digamma function has the following integral representation

$\psi(x) = \int_0^{\infty}\left(\frac{e^{-t}}{t} - \frac{e^{-xt}}{1 - e^{-t}}\right)\,dt$.

This may be written as

$\psi(s+1)= -\gamma + \int_0^1 \frac {1-x^s}{1-x} dx$

which follows from Euler's integral formula for the harmonic numbers.

## Series formula

Digamma can be computed in the complex plane outside negative integers (Abramowitz and Stegun 6.3.16),[1] using

$\psi(z+1)= -\gamma +\sum_{n=1}^\infty \frac{z}{n(n+z)} \qquad z \neq -1, -2, -3, \ldots$

or

$\psi(z)=-\gamma+\sum_{n=0}^{\infty}\frac{z-1}{(n+1)(n+z)}=-\gamma+\sum_{n=0}^{\infty}\left(\frac{1}{n+1}-\frac{1}{n+z}\right)\qquad z\neq0,-1,-2,-3,\ldots$

This can be utilized to evaluate infinite sums of rational functions, i.e., $\sum_{n=0}^{\infty}u_{n}=\sum_{n=0}^{\infty}\frac{p(n)}{q(n)}$, where p(n) and q(n) are polynomials of n.

Performing partial fraction on un in the complex field, in the case when all roots of q(n) are simple roots,

$u_{n} =\frac{p(n)}{q(n)}=\sum_{k=1}^{m}\frac{a_{k}}{n+b_{k}}.$

For the series to converge,

$\lim_{n\to\infty}nu_{n}=0,$

or otherwise the series will be greater than harmonic series and thus diverges.

Hence

$\sum_{k=1}^{m}a_{k}=0,$

and

$\sum_{n=0}^{\infty}u_{n}=\sum_{n=0}^{\infty}\sum_{k=1}^{m}\frac{a_{k}}{n+b_{k}}=\sum_{n=0}^{\infty}\sum_{k=1}^{m}a_{k}\left(\frac{1}{n+b_{k}}-\frac{1}{n+1}\right)=$
$=\sum_{k=1}^{m}\left(a_{k}\sum_{n=0}^{\infty}\left(\frac{1}{n+b_{k}}-\frac{1}{n+1}\right)\right)=-\sum_{k=1}^{m}a_{k}\left(\psi(b_{k})+\gamma\right)=-\sum_{k=1}^{m}a_{k}\psi(b_{k}).$

With the series expansion of higher rank polygamma function a generalized formula can be given as

$\sum_{n=0}^{\infty}u_{n}=\sum_{n=0}^{\infty}\sum_{k=1}^{m}\frac{a_{k}}{(n+b_{k})^{r_{k}}}=\sum_{k=1}^{m}\frac{(-1)^{r_{k}}}{(r_{k}-1)!}a_{k}\psi^{(r_{k}-1)}(b_{k}),$

provided the series on the left converges.

## Taylor series

The digamma has a rational zeta series, given by the Taylor series at z=1. This is

$\psi(z+1)= -\gamma -\sum_{k=1}^\infty \zeta (k+1)\;(-z)^k$,

which converges for |z|<1. Here, $\zeta(n)$ is the Riemann zeta function. This series is easily derived from the corresponding Taylor's series for the Hurwitz zeta function.

## Newton series

The Newton series for the digamma follows from Euler's integral formula:

$\psi(s+1)=-\gamma-\sum_{k=1}^\infty \frac{(-1)^k}{k} {s \choose k}$

where $\textstyle{s \choose k}$ is the binomial coefficient.

## Reflection formula

The digamma function satisfies a reflection formula similar to that of the Gamma function,

$\psi(1 - x) - \psi(x) = \pi\,\!\cot{ \left ( \pi x \right ) }$

## Recurrence formula and characterization

The digamma function satisfies the recurrence relation

$\psi(x + 1) = \psi(x) + \frac{1}{x}.$

Thus, it can be said to "telescope" 1/x, for one has

$\Delta [\psi] (x) = \frac{1}{x}$

where Δ is the forward difference operator. This satisfies the recurrence relation of a partial sum of the harmonic series, thus implying the formula

$\psi(n)\ =\ H_{n-1} - \gamma$

where $\gamma\,$ is the Euler-Mascheroni constant.

More generally, one has

$\psi(x+1) = -\gamma + \sum_{k=1}^\infty \left( \frac{1}{k}-\frac{1}{x+k} \right).$

Actually, $\psi$ is the only solution of the functional equation $F(x + 1) = F(x) + \frac{1}{x}$ that is monotone on $\R^+$ and satisfies $F(1)=-\gamma$. This fact follows immediately from the uniqueness of the $\Gamma$ function given its recurrence equation and convexity-restriction. This implies the useful difference equation :

$\psi(x+N) - \psi(x) = \sum_{k=0}^{N-1} \frac{1}{x+k}$

## Gaussian sum

The digamma has a Gaussian sum of the form

$\frac{-1}{\pi k} \sum_{n=1}^k \sin \left( \frac{2\pi nm}{k}\right) \psi \left(\frac{n}{k}\right) = \zeta\left(0,\frac{m}{k}\right) = -B_1 \left(\frac{m}{k}\right) = \frac{1}{2} - \frac{m}{k}$

for integers $0. Here, ζ(s,q) is the Hurwitz zeta function and $B_n(x)$ is a Bernoulli polynomial. A special case of the multiplication theorem is

$\sum_{n=1}^k \psi \left(\frac{n}{k}\right) =-k(\gamma+\log k),$

and a neat generalization of this is

$\sum_{p=0}^{q-1}\psi(a+p/q)=q(\psi(qa)-\log(q)),$

where q must be a natural number, but 1-qa not.

## Gauss's digamma theorem

For positive integers m and k (with m < k), the digamma function may be expressed in finite many terms of elementary functions as

$\psi\left(\frac{m}{k}\right) = -\gamma -\ln(2k) -\frac{\pi}{2}\cot\left(\frac{m\pi}{k}\right) +2\sum_{n=1}^{\lfloor (k-1)/2\rfloor} \cos\left(\frac{2\pi nm}{k} \right) \ln\left(\sin\left(\frac{n\pi}{k}\right)\right)$

and because of its recurrence equation for all rational arguments.

## Computation and approximation

According to the Euler Maclaurin formula applied for $\sum_{n=1}^x \tfrac1 n$ [3] the digamma function for x, also a real number, can be approximated by

$\psi(x) = \ln(x) - \frac{1}{2x} - \frac{1}{12x^2} + \frac{1}{120x^4} - \frac{1}{252x^6} + \frac{1}{240x^8} - \frac{5}{660x^{10}} + \frac{691}{32760x^{12}} - \frac{1}{12x^{14}} + O\left(\frac{1}{x^{16}}\right)$

which is the beginning of the asymptotical expansion of $\psi(x)$. The full asymptotic series of this expansions is

$\psi(x) = \ln(x) - \frac{1}{2x} + \sum_{n=1}^\infty \frac{\zeta(1-2n)}{x^{2n}} = \ln(x) - \frac{1}{2x} - \sum_{n=1}^\infty \frac{B_{2n}}{2n\, x^{2n}}$

where $B_k$ is the kth Bernoulli number and $\zeta$ is the Riemann zeta function. Although the infinite sum converges for no x, this expansion becomes more accurate for larger values of x and any finite partial sum cut off from the full series. To compute $\psi(x)$ for small x, the recurrence relation

$\psi(x+1) = \frac{1}{x} + \psi(x)$

can be used to shift the value of x to a higher value. Beal[4] suggests using the above recurrence to shift x to a value greater than 6 and then applying the above expansion with terms above $x^{14}$ cut off, which yields "more than enough precision" (at least 12 digits except near the zeroes).

$\psi(x) \in [\ln(x-1), \ln x]$
$\exp(\psi(x)) \approx \begin{cases} \frac{x^2}{2} &: x\in[0,1] \\ x - \frac{1}{2} &: x>1 \end{cases}$

From the above asymptotic series for $\psi$ you can derive asymptotic series for $\exp \circ\, \psi$ that contain only rational functions and constants. The first series matches the overall behaviour of $\exp \circ\, \psi$ well, that is, it behaves asymptotically identically for large arguments and has a zero of unbounded multiplicity at the origin, too. It can be considered a Taylor expansion of $\exp(-\psi(1/y))$ at $y=0$.

$\frac{1}{\exp(\psi(x))} = \frac{1}{x}+\frac{1}{2\cdot x^2}+\frac{5}{4\cdot3!\cdot x^3}+\frac{3}{2\cdot4!\cdot x^4}+\frac{47}{48\cdot5!\cdot x^5} - \frac{5}{16\cdot6!\cdot x^6} + \dots$

The other expansion is more precise for large arguments and saves computing terms of even order.

$\exp(\psi(x+\tfrac{1}{2})) = x + \frac{1}{4!\cdot x} - \frac{37}{8\cdot6!\cdot x^3} + \frac{10313}{72\cdot8!\cdot x^5} - \frac{5509121}{384\cdot10!\cdot x^7} + O\left(\frac{1}{x^9}\right)\quad\mbox{for } x>1$

## Special values

The digamma function has values in closed form for rational numbers, as a result of Gauss's digamma theorem. Some are listed below:

$\psi(1) = -\gamma\,\!$
$\psi\left(\frac{1}{2}\right) = -2\ln{2} - \gamma$
$\psi\left(\frac{1}{3}\right) = -\frac{\pi}{2\sqrt{3}} -\frac{3}{2}\ln{3} - \gamma$
$\psi\left(\frac{1}{4}\right) = -\frac{\pi}{2} - 3\ln{2} - \gamma$
$\psi\left(\frac{1}{6}\right) = -\frac{\pi}{2}\sqrt{3} -2\ln{2} -\frac{3}{2}\ln(3) - \gamma$
$\psi\left(\frac{1}{8}\right) = -\frac{\pi}{2} - 4\ln{2} - \frac{1}{\sqrt{2}} \left\{\pi + \ln(2 + \sqrt{2}) - \ln(2 - \sqrt{2})\right\} - \gamma$

The roots of the digamma function are the saddle points of the complex-valued gamma function. Thus they lie all on the real axis. The only one on the positive real axis is the unique minimum of the real-valued gamma function on $\R^+$ at $x_0 = 1.461632144968\ldots$. All others occur single between the pols on the negative axis: $x_1 = -0.504083008\ldots, x_2= -1.573498473\ldots, x_3= -2.610720868\ldots, x_4= -3.635293366\ldots, \ldots$. Already 1881 Hermite observed that $x_n = -n +\frac{1}{\ln n} + o\left(\frac{1}{\ln^2 n}\right)$ holds asymptotically . A better approximation of the location of the roots is given by

$x_n \approx -n + \frac{1}{\pi}\arctan\left(\frac{\pi}{\ln n}\right)\qquad n \ge 2$

and using a further term it becomes still better

$x_n \approx -n + \frac{1}{\pi}\arctan\left(\frac{\pi}{\ln n + \frac{1}{8n}}\right)\qquad n \ge 1$

which both spring off the reflection formula via $0 = \psi(1-x_n) = \psi(x_n) + \frac{\pi}{\tan(\pi x_n)}$ and substituting $\psi(x_n)$ by its not convergent asymptotic expansion. The correct 2nd term of this expansion is of course $\tfrac1 {2n}$, where the given one works good to approximate roots with small index n.

## Regularization

the Digamma function appears in the regularization of divergent integrals $\int_{0}^{\infty} \frac{dx}{x+a}$, this integral can be approximated by a divergent general Harmonic series, but the following value can be attached to the series $\sum_{n=0}^{\infty} \frac{1}{n+a}= - \psi (a)$