Harmonic Number Calculator

Calculate Hn = 1 + 1/2 + 1/3 + ... + 1/n with partial sums and asymptotic estimates.

Enter n

Result

Harmonic Number H10
0
exact sum
Exact Hn
ln(n) + γ estimate
Approximation error
ln(n)
γ (Euler-Mascheroni)

Step-by-Step Solution

H_n = 1 + 1/2 + 1/3 + ... + 1/n
k1/kHk (partial sum)

Understanding Harmonic Numbers

The n-th harmonic number, denoted Hn, is defined as the sum of the reciprocals of the first n positive integers: Hn = 1 + 1/2 + 1/3 + ... + 1/n. The harmonic series (the sum as n approaches infinity) diverges, meaning Hn grows without bound, though it does so very slowly.

Key Formulas and Approximations

Exact Definition

The sum of the first n reciprocals.

H_n = Σ(k=1 to n) 1/k

Asymptotic Approximation

For large n, H_n is approximated by the natural logarithm plus the Euler-Mascheroni constant.

H_n ≈ ln(n) + γ

Better Approximation

Adding correction terms improves accuracy.

H_n ≈ ln(n) + γ + 1/(2n)

Euler-Mascheroni Constant

The limiting difference between H_n and ln(n).

γ ≈ 0.5772156649...

Properties of Harmonic Numbers

  • Divergence: The harmonic series diverges (Hn grows to infinity), but extremely slowly. H10 ≈ 2.93, H100 ≈ 5.19, H1000 ≈ 7.49.
  • Rate of growth: Hn grows as O(ln n), making it one of the slowest diverging series.
  • Non-integer: For n ≥ 2, Hn is never an integer.
  • Recursion: Hn = Hn-1 + 1/n, with H1 = 1.

Applications of Harmonic Numbers

  • Algorithm analysis: The expected number of comparisons in randomized quicksort involves harmonic numbers.
  • Coupon collector problem: The expected number of items to collect before getting all n types is n * Hn.
  • Number theory: Harmonic numbers appear in results about prime numbers and the Riemann zeta function.
  • Physics: Used in quantum mechanics, electrostatics, and the study of overtones in musical instruments.
  • Computer science: Running time of hash table operations, skip lists, and many randomized algorithms involves Hn.

The Euler-Mascheroni Constant

The Euler-Mascheroni constant γ ≈ 0.5772156649 is defined as the limit of Hn - ln(n) as n approaches infinity. It is one of the most important constants in mathematics, appearing in number theory, analysis, and combinatorics. Whether γ is rational or irrational remains one of the major open questions in mathematics.