On this page you will find a harmonic number calculator. It will also calculate the inverse harmonic numbers. I suggest you run this in Chrome or Edge. Firefox is about 10 times slower. As a ballpark estimation of time, it takes my (rather old) laptop about 2 s to find the number of terms to get to the sum 10000 using Chrome (ver 97.0.4692.71), but about 20 s on Firefox (ver 95.0.2). It takes just shy of 1 s on chrome on my Samsung Note 9.
The calculations are done using between 1000 to 10000 decimals, or about 1000 to 20000 digits, dependent on the inputs.
The calculator works fine up to sums about 23000 because beyond that the denominator will be less than 10-10000, that will be rounded to 0.
To find the harmonic numbers it will use the so called DeTemple–Wang approximation. I found it here,
in a paper by Mark B. Villarino.
We have that
where lambda is the Euler–Mascheroni constant. I have written the formula in a slightly different form than is given in the source – actually as I have calculated it. The error is then in the order of
I will cut, and round, the result at the corresponding position. All shown digits, except possibly the last, will thus be correct. I have checked the results against Mathematica 126.96.36.199 for some various values.
For the calculations we will use the fact that
If z is fairly close to one, then w will be close to 0, and our series will converge quickly.
We can calculate ln(z) by first calculating an approximate logarithm, here called y, using the ordinary JS-function, Math.log. This will give us an answer with about 16 correct digits. We may then calculate A=z/ey. This will be a value very close to one. If x is a value approximately equal to z, and y=ln(x) and thus x= ey, then
We can now calculate ln(A) efficiently using the previously described algorithm. The input is scaled down before the calculations. We have that
The logarithm of m is calculated using the above algorithm, and ln(10) is stored as a constant with 10100 significant figures.
The inverse is calculated using an algorithm (by David W. Cantrell) that I found here: https://oeis.org/A118050.
We have that if z is the searched for sum and
This might be off by one, but you can always copy the value to the harmonic number calculator, and test the result there, and then adjust it by one if necessary.Up a level : The Harmonic seriesLast modified: