The harmonic numbers are defined by

Harmonic numbers are sort of a discrete analog of logarithms since

As *n* goes to infinity, the difference between *H _{n}* and log

*n*is Euler’s constant γ = 0.57721… [1]

How would you compute *H _{n}*? For small

*n*, simply use the definition. But if

*n*is very large, there’s a way to approximate

*H*without having to do a large sum.

_{n}Since in the limit *H _{n}* – log

*n*goes to γ, a crude approximation would be

But we could do much better by adding a couple terms to the approximation above. [2] That is,

The error in the approximation above is between 0 and 1/120*n*^{4}.

So if you used this to compute the 1000th harmonic number, the error would be less than one part in 120,000,000,000,000. Said another way, for *n* = 1000 the approximation differs from the exact value in the 15th significant digit, approximately the resolution of floating point numbers (i.e. IEEE 754 double precision).

And the formula is even more accurate for larger *n*. If we wanted to compute the millionth harmonic number, the error in our approximation would be somewhere around the 26th decimal place.

**Related**: Posts on special numbers

* * *

[1] See Julian Havil’s excellent Gamma: Exploring Euler’s Constant. It’s popular-level book, but more sophisticated than most such books.

[2] There’s a sequence of increasingly accurate approximations that keep adding reciprocals of even powers of *n, *based on truncating an asymptotic series. See Concrete Mathematics for details.

As you talk about “log” above you mean Log_e (log base ‘e’) correct?

To put it another way, you actually man natural log throughout… or ‘ln’.

Correct?

It is not the normal assumption with log, being log_10.

By “log” I always mean natural log. Here’s why.