# The harmonic series, the "prime harmonic series", and their difference

## Harmonic series

Consider the harmonic series $1 + \frac12 + \frac13 + \dots$ . Apparently, it was Donald Knuth who in 1968 (vol 1 of TAOCP, section 1.2.7 “Harmonic numbers”) gave the name “harmonic number” and the notation $H_n$ to the partial sums of this series: $H_n = 1 + \frac12 + \frac13 + \dots + \frac1n$

It turns out that $H_n = \ln{n} + \gamma + \frac{1}{2n} - \frac{1}{12n^2} + \frac{1}{120n^4} + \dots$ where the terms for powers $k \ge 2$ are $\dfrac{B_k}{k n^k}$ .

## Prime harmonic series

What about adding only the reciprocals of the prime numbers, namely

$\sum_{p\text{ prime}}\frac1p = \frac12 + \frac13 + \frac15 + \frac17 + \frac1{11} + \frac1{13} + \frac1{17} + \cdots$

where we sum reciprocals of primes under some value $x$ ?

This too diverges, though very slowly: it follows from the second theorem of Mertens that

$\sum_{p\le x} \frac1p = \ln \ln x + M + \epsilon,$

where $M$ is the Meissel–Mertens constant 0.26149721…. Here, for the error term $\epsilon$ , Mertens proved that $|\epsilon| \le \dfrac 4{\ln(x+1)} +\dfrac 2{x\ln x}$ ; this paper (see also this math.SE question and this MO question) shows that $\epsilon$ changes sign infinitely often; and this 2016 paper by Pierre Dusart shows (its Theorem 5.6) that $|\epsilon| \le \dfrac{0.2}{\ln^3 n}$ for $n \ge 2\,278\,383$ .

## The non-prime harmonic series

We can also take their difference, and consider

$1 + \frac14 + \frac16 + \frac18 + \frac19 + \frac1{10} + \frac1{12} + \frac1{14} + \frac1{15} + \cdots$

where we sum the reciprocals of non-prime integers under some value $x$ .

Being the difference of the two, this will grow like

$\ln x - \ln \ln x + (\gamma - M) + O\left(\frac{1}{\ln^3 n}\right)$

## Further questions

What if we take the above “prime harmonic series” and “composite harmonic series” to $n$ terms, instead of using values up to $x$ ? (We’ll need estimates for the $n$ th prime and $n$ th composite number respectively.)

What about

*inverting*these functions, i.e. given some $x$ , finding value of $n$ at which $H_n$ (or the prime harmonic series, or composite harmonic series) attains (or, first exceeds) the value $x$ ? Can we estimate the asymptotics of*that*function?

Some of these questions are answered in this Colab notebook.