# Harmonic number

The term harmonic number has multiple meanings. For other meanings, see harmonic number (disambiguation).
The harmonic number $H_{n,1}$ with $n=\lfloor{x}\rfloor$ (red line) with its asymptotic limit $\gamma+\ln(x)$ (blue line).

In mathematics, the n-th harmonic number is the sum of the reciprocals of the first n natural numbers:

$H_n= 1+\frac{1}{2}+\frac{1}{3}+\cdots+\frac{1}{n} =\sum_{k=1}^n \frac{1}{k}.$

This also equals n times the inverse of the harmonic mean of these natural numbers.

Number n such that the numerator of $H_n$ is prime are

2, 3, 5, 8, 9, 21, 26, 41, 56, 62, 69, 79, 89, 91, 122, 127, 143, 167, 201, 230, 247, 252, 290, 349, 376, 459, 489, 492, 516, 662, 687, 714, 771, 932, 944, 1061, 1281, 1352, 1489, 1730, 1969, ... (sequence A056903 in OEIS)

Harmonic numbers were studied in antiquity and are important in various branches of number theory. They are sometimes loosely termed harmonic series, are closely related to the Riemann zeta function, and appear in the expressions of various special functions.

The associated harmonic series grows without limit, albeit very slowly, roughly approaching the natural logarithm function.[1]:143 In 1737, Leonhard Euler used the divergence of this series to provide a new proof of the infinity of prime numbers. His work was extended into the complex plane by Bernhard Riemann in 1859, leading directly to the celebrated Riemann hypothesis about the distribution of prime numbers.

When the value of a large quantity of items has a Zipf's law distribution, the total value of the n most-valuable items is the n-th harmonic number. This leads to a variety of surprising conclusions in the Long Tail and the theory of network value.

Bertrand's postulate entails that, except for the case n=1, the harmonic numbers are never integers.[2]

## Identities involving harmonic numbers

By definition, the harmonic numbers satisfy the recurrence relation

$H_n = H_{n-1} + \frac{1}{n}.$

They also satisfy the series identity

$\sum_{k=1}^n H_k = (n+1) H_{n+1} - (n + 1).$

The harmonic numbers are connected to the Stirling numbers of the first kind:

$H_n = \frac{1}{n!}\left[{n+1 \atop 2}\right].$

The functions

$f_n(x)=\frac{x^n}{n!}(\log x-H_n)$

satisfy the property

$f_n'(x)=f_{n-1}(x).$

In particular

$f_1(x)=x(\log x-1)$

is a primitive of the logarithmic function.

## Calculation

An integral representation given by Euler[3] is

$H_n = \int_0^1 \frac{1 - x^n}{1 - x}\,dx.$

The equality above is obvious by the simple algebraic identity

$\frac{1-x^n}{1-x}=1+x+\cdots +x^{n-1}.$

Using the simple integral transform x = 1−u, an elegant combinatorial expression for Hn is

\begin{align} H_n &= \int_0^1 \frac{1 - x^n}{1 - x}\,dx \\ &=-\int_1^0\frac{1-(1-u)^n}{u}\,du \\ &= \int_0^1\frac{1-(1-u)^n}{u}\,du \\ &= \int_0^1\left[\sum_{k=1}^n(-1)^{k-1}\binom nk u^{k-1}\right]\,du \\ &= \sum_{k=1}^n (-1)^{k-1}\binom nk \int_0^1u^{k-1}\,du \\ &= \sum_{k=1}^n(-1)^{k-1}\frac{1}{k}\binom nk . \end{align}

The same representation can be produced by using the third Retkes identity by setting $x_1=1,\ldots,x_n=n$ and using the fact that $\Pi_k(1,\ldots,n)=(-1)^{n-k}(k-1)!(n-k)!$

$H_n=H_{n,1}=\sum_{k=1}^n\frac{1}{k}=(-1)^{n-1}n!\sum_{k=1}^n\frac{1}{k^2\Pi_k(1,\ldots,n)}=\sum_{k=1}^n(-1)^{k-1}\frac{1}{k}\binom nk.$

Graph demonstrating a connection between harmonic numbers and the natural logarithm. The harmonic number Hn can be interpreted as a Riemann sum of the integral: $\int_1^{n+1} \frac{1}{x} \mathrm{d}x = \ln(n+1)$

The nth harmonic number is about as large as the natural logarithm of n. The reason is that the sum is approximated by the integral

$\int_1^n {1 \over x}\, dx$

whose value is ln(n).

The values of the sequence Hn - ln(n) decrease monotonically towards the limit

$\lim_{n \to \infty} \left(H_n - \ln n\right) = \gamma,$

where γ ≈ 0.5772156649 is the Euler–Mascheroni constant. The corresponding asymptotic expansion as n → ∞ is

$H_n \sim \ln{n}+\gamma+\frac{1}{2n}-\sum_{k=1}^\infty \frac{B_{2k}}{2k n^{2k}}=\ln{n}+\gamma+\frac{1}{2n}-\frac{1}{12n^2}+\frac{1}{120n^4}-\cdots,$

where $B_k$ are the Bernoulli numbers.

### Special values for fractional arguments

There are the following special analytic values for fractional arguments between 0 and 1, given by the integral

$H_\alpha = \int_0^1\frac{1-x^\alpha}{1-x}\,dx\, .$

More values may be generated from the recurrence relation

$H_\alpha = H_{\alpha-1}+\frac{1}{\alpha}\, ,$

or from the reflection relation

$H_{1-\alpha}-H_\alpha = \pi\cot{(\pi\alpha)}-\frac{1}{\alpha}+\frac{1}{1-\alpha}\, .$

For example:

$H_{\frac{3}{4}} = \tfrac{4}{3}-3\ln{2}+\tfrac{\pi}{2}$
$H_{\frac{2}{3}} = \tfrac{3}{2}(1-\ln{3})+\sqrt{3}\tfrac{\pi}{6}$
$H_{\frac{1}{2}} = 2 -2\ln{2}$
$H_{\frac{1}{3}} = 3-\tfrac{\pi}{2\sqrt{3}} -\tfrac{3}{2}\ln{3}$
$H_{\frac{1}{4}} = 4-\tfrac{\pi}{2} - 3\ln{2}$
$H_{\frac{1}{6}} = 6-\tfrac{\pi}{2} \sqrt{3} -2\ln{2} -\tfrac{3}{2} \ln{3}$
$H_{\frac{1}{8}} = 8-\tfrac{\pi}{2} - 4\ln{2} - \tfrac{1}{\sqrt{2}} \left\{\pi + \ln\left(2 + \sqrt{2}\right) - \ln\left(2 - \sqrt{2}\right)\right\}$
$H_{\frac{1}{12}} = 12-3\left(\ln{2}+\tfrac{\ln{3}}{2}\right)-\pi\left(1+\tfrac{\sqrt{3}}{2}\right)+2\sqrt{3}\ln \left (\sqrt{2-\sqrt{3}} \right )$

For positive integers p and q with p < q, we have:

$H_{\frac{p}{q}} = \frac{q}{p} +2\sum_{k=1}^{\lfloor\frac{q-1}{2}\rfloor} \cos(\frac{2 \pi pk}{q})\ln({\sin (\frac{\pi k}{q})})-\frac{\pi}{2}\cot(\frac{\pi p}{q})-\ln(2q)$

For every x > 0, integer or not, we have:

$H_{x} = x \sum_{k=1}^\infty \frac{1}{k(x+k)}\, .$

Based on this, it can be shown that:

$\int_0^1H_{x}\,dx = \gamma\, ,$

where γ is the Euler–Mascheroni constant or, more generally, for every n we have:

$\int_0^nH_{x}\,dx = n\gamma+\ln{(n!)}\, .$

## Generating functions

A generating function for the harmonic numbers is

$\sum_{n=1}^\infty z^n H_n = \frac {-\ln(1-z)}{1-z},$

where ln(z) is the natural logarithm. An exponential generating function is

$\sum_{n=1}^\infty \frac {z^n}{n!} H_n = -e^z \sum_{k=1}^\infty \frac{1}{k} \frac {(-z)^k}{k!} = e^z \mbox {Ein}(z)$

where Ein(z) is the entire exponential integral. Note that

$\mbox {Ein}(z) = \mbox{E}_1(z) + \gamma + \ln z = \Gamma (0,z) + \gamma + \ln z\,$

where Γ(0, z) is the incomplete gamma function.

## Applications

The harmonic numbers appear in several calculation formulas, such as the digamma function

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

This relation is also frequently used to define the extension of the harmonic numbers to non-integer n. The harmonic numbers are also frequently used to define γ, using the limit introduced in the previous section, although

$\gamma = \lim_{n \to \infty}{\left(H_n - \ln\left(n+{1 \over 2}\right)\right)}$

converges more quickly.

In 2002, Jeffrey Lagarias proved[4] that the Riemann hypothesis is equivalent to the statement that

$\sigma(n) \le H_n + \ln(H_n)e^{H_n},$

is true for every integer n ≥ 1 with strict inequality if n > 1; here σ(n) denotes the sum of the divisors of n.

The eigenvalues of the nonlocal problem

$\lambda \phi(x) = \int_{-1}^{1} \frac{\phi(x)-\phi(y)}{|x-y|} dy$

are given by $\lambda = 2H_n$, where by convention, $H_0 = 0.$

## Generalization

### Generalized harmonic numbers

The generalized harmonic number of order n of m is given by

$H_{n,m}=\sum_{k=1}^n \frac{1}{k^m}.$

The limit as n tends to infinity exists if m > 1.

Other notations occasionally used include

$H_{n,m}= H_n^{(m)} = H_m(n).$

The special case of m = 0 gives $H_{n,0}= n$

The special case of m = 1 is simply called a harmonic number and is frequently written without the superscript, as

$H_n= \sum_{k=1}^n \frac{1}{k}.$

Smallest natural number k such that kn does not divide the denominator of generalized harmonic number H(k, n) nor the denominator of alternating generalized harmonic number H'(k, n) are

77, 20, 94556602, 42, 444, 20, 104, 42, 76, 20, 77, 110, 3504, 20, 903, 42, 1107, 20, 104, 42, 77, 20, 2948, 110, 136, 20, 76, 42, 903, 20, 77, 42, 268, 20, 7004, 110, 1752, 20, 19203, 42, 77, 20, 104, 42, 76, 20, 370, 110, 1107, 20, ... (sequence A128670 in OEIS)

In the limit of n → ∞, the generalized harmonic number converges to the Riemann zeta function

$\lim_{n\rightarrow \infty} H_{n,m} = \zeta(m).$

The related sum $\sum_{k=1}^n k^m$ occurs in the study of Bernoulli numbers; the harmonic numbers also appear in the study of Stirling numbers.

Some integrals of generalized harmonic are

$\int_0^a H_{x,2} \, dx = a \frac {\pi^2}{6}-H_{a}$

and

$\int_0^a H_{x,3} \, dx = a A - \frac {1}{2} H_{a,2},$ where A is the Apéry's constant, i.e. ζ(3).

and

$\sum_{k=1}^n H_{k,m}=(n+1)H_{n,m}- H_{n,m-1}$   for $m \geq 0$

Every generalized harmonic number of order m can be written as a function of harmonic of order m-1 using:

$H_{n,m} = \sum_{k=1}^{n-1} \frac {H_{k,m-1}}{k(k+1)} + \frac {H_{n,m-1}}{n}$   for example: $H_{4,3} = \frac {H_{1,2}}{1 \cdot 2} + \frac {H_{2,2}}{2 \cdot 3} + \frac {H_{3,2}}{3 \cdot 4} + \frac {H_{4,2}}{4}$

A generating function for the generalized harmonic numbers is

$\sum_{n=1}^\infty z^n H_{n,m} = \frac {\mathrm{Li}_m(z)}{1-z},$

where $\mathrm{Li}_m(z)$ is the polylogarithm, and |z| < 1. The generating function given above for m = 1 is a special case of this formula.

Fractional argument for generalized harmonic numbers can be introduced as follows:

For every $p,q>0$ integer, and $m>1$ integer or not, we have from polygamma functions:

$H_{q/p,m}=\zeta(m)-p^m\sum_{k=1}^\infty \frac{1}{(q+pk)^m}$

where $\zeta(m)$ is the Riemann zeta function. The relevant recurrence relation is:

$H_{a,m}=H_{a-1,m}+\frac{1}{a^m}$

Some special values are:

$H_{\frac{1}{4},2}=16-8G-\tfrac{5}{6}\pi^2$ where G is the Catalan's constant
$H_{\frac{1}{2},2}=4-\tfrac{\pi^2}{3}$
$H_{\frac{3}{4},2}=8G+\tfrac{16}{9}-\tfrac{5}{6}\pi^2$
$H_{\frac{1}{4},3}=64-27\zeta(3)-\pi^3$
$H_{\frac{1}{2},3}=8-6\zeta(3)$
$H_{\frac{3}{4},3}={(\tfrac{4}{3})}^3-27\zeta(3)+\pi^3$

### Multiplication formulas

Using polygamma functions, we obtain

$H_{2x}=\frac{1}{2}\left(H_{x}+H_{x-\frac{1}{2}}\right)+\ln{2}$
$H_{3x}=\frac{1}{3}\left(H_{x}+H_{x-\frac{1}{3}}+H_{x-\frac{2}{3}}\right)+\ln{3},$

or, more generally,

$H_{nx}=\frac{1}{n}\left(H_{x}+H_{x-\frac{1}{n}}+H_{x-\frac{2}{n}}+\cdots +H_{x-\frac{n-1}{n}}\right)+\ln{n}.$

For generalized harmonic numbers, we have

$H_{2x,2}=\frac{1}{2}\left(\zeta(2)+\frac{1}{2}\left(H_{x,2}+H_{x-\frac{1}{2},2}\right)\right)$
$H_{3x,2}=\frac{1}{9}\left(6\zeta(2)+H_{x,2}+H_{x-\frac{1}{3},2}+H_{x-\frac{2}{3},2}\right),$

where $\zeta(n)$ is the Riemann zeta function.

### Generalization to the complex plane

Euler's integral formula for the harmonic numbers follows from the integral identity

$\int_a^1 \frac {1-x^s}{1-x} \, dx = - \sum_{k=1}^\infty \frac {1}{k} {s \choose k} (a-1)^k,$

which holds for general complex-valued s, for the suitably extended binomial coefficients. By choosing a = 0, this formula gives both an integral and a series representation for a function that interpolates the harmonic numbers and extends a definition to the complex plane. This integral relation is easily derived by manipulating the Newton series

$\sum_{k=0}^\infty {s \choose k} (-x)^k = (1-x)^s,$

which is just the Newton's generalized binomial theorem. The interpolating function is in fact the digamma function

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

where $\psi(x)$ is the digamma, and γ is the Euler-Mascheroni constant. The integration process may be repeated to obtain

$H_{s,2}=-\sum_{k=1}^\infty \frac {(-1)^k}{k} {s \choose k} H_k.$

### Relation to the Riemann zeta function

Some derivatives of fractional harmonic numbers are given by:

$\frac{d^n H_x}{dx^n} = (-1)^{n+1}n!\left[\zeta(n+1)-H_{x,n+1}\right]$
$\frac{d^n H_{x,2}}{dx^n} = (-1)^{n+1}(n+1)!\left[\zeta(n+2)-H_{x,n+2}\right]$
$\frac{d^n H_{x,3}}{dx^n} = (-1)^{n+1}\frac{1}{2}(n+2)!\left[\zeta(n+3)-H_{x,n+3}\right].$

And using Maclaurin series, we have for x < 1:

$H_x = \sum_{n=1}^{\infin}(-1)^{n+1}x^n\zeta(n+1)$
$H_{x,2} = \sum_{n=1}^{\infin}(-1)^{n+1}(n+1)x^n\zeta(n+2)$
$H_{x,3} = \frac{1}{2}\sum_{n=1}^{\infin}(-1)^{n+1}(n+1)(n+2)x^n\zeta(n+3).$

For fractional arguments between 0 and 1, and for a > 1:

$H_{\frac{1}{a}} = \frac{1}{a}\left(\zeta(2)-\frac{1}{a}\zeta(3)+\frac{1}{a^2}\zeta(4)-\frac{1}{a^3}\zeta(5)+\cdots\right)$
$H_{\frac{1}{a}, 2} = \frac{1}{a}\left(2\zeta(3)-\frac{3}{a}\zeta(4)+\frac{4}{a^2}\zeta(5)-\frac{5}{a^3}\zeta(6)+\cdots\right)$
$H_{\frac{1}{a}, 3} = \frac{1}{2a}\left(2\cdot3\zeta(4)-\frac{3\cdot4}{a}\zeta(5)+\frac{4\cdot5}{a^2}\zeta(6)-\frac{5\cdot6}{a^3}\zeta(7)+\cdots\right).$

### Hyperharmonic numbers

The next generalization was discussed by J. H. Conway and R. K. Guy in their 1995 book The Book of Numbers.[1]:258 Let

$H_n^{(0)} = \frac1n.$

Then the nth hyperharmonic number of order r (r>0) is defined recursively as

$H_n^{(r)} = \sum_{k=1}^n H_k^{(r-1)}.$

In special, $H_n=H_n^{(1)}$.