A harmonic series calculator lets you add up the first n terms of the harmonic series — the sum 1 + 1/2 + 1/3 + 1/4 + … — and tells you the partial sum for any number of terms you choose. You enter the number of terms (n), and the calculator returns the cumulative sum, often alongside the nth term and the natural-log approximation. Below is a working calculator that does exactly that, followed by the math behind it, common pitfalls, and answers to frequent questions.
Formula
The harmonic series is defined as the infinite sum:
H(n) = 1 + 1/2 + 1/3 + 1/4 + … + 1/n
where H(n) is the n-th partial sum (also called the n-th harmonic number), and n is a positive integer (the number of terms you add). Each term is the reciprocal of an integer: 1/1, 1/2, 1/3, and so on.
There is no simple closed-form formula for H(n) using only elementary operations. The exact value is always a rational number (a fraction), but the denominator grows extremely fast. For practical computation, you add the fractions directly, or use the very accurate approximation:
H(n) ≈ ln(n) + γ + 1/(2n) – 1/(12n²) + 1/(120n⁴) – …
where ln(n) is the natural logarithm of n, and γ (gamma) is the Euler–Mascheroni constant, approximately 0.5772156649. The extra terms (1/(2n), –1/(12n²), …) are corrections that make the approximation more accurate for small n. For n ≥ 10, even just ln(n) + γ is within about 0.05 of the true value; the calculator above uses that simple version so you can see the difference.
Worked Example
Let’s use the default value from the calculator: n = 10.
Step 1: Write out the terms:
- 1/1 = 1
- 1/2 = 0.5
- 1/3 ≈ 0.333333
- 1/4 = 0.25
- 1/5 = 0.2
- 1/6 ≈ 0.166667
- 1/7 ≈ 0.142857
- 1/8 = 0.125
- 1/9 ≈ 0.111111
- 1/10 = 0.1
Step 2: Add them up:
1 + 0.5 + 0.333333 + 0.25 + 0.2 + 0.166667 + 0.142857 + 0.125 + 0.111111 + 0.1 = 2.928968
Step 3: The approximation using ln(10) + γ:
ln(10) ≈ 2.302585, plus γ ≈ 0.577216 gives 2.879801.
Step 4: The difference is 2.928968 – 2.879801 = 0.049167.
So for n = 10, the exact partial sum is about 2.928968, and the simple approximation is off by roughly 0.049. The calculator shows all three values: the exact sum, the approximation, and the difference.
Why the Harmonic Series Matters
The harmonic series is one of the most famous in mathematics because it diverges — as n goes to infinity, H(n) grows without bound, but extremely slowly. To reach H(n) = 10, you need n = 12,367 terms. To reach H(n) = 20, you need about 272 million terms. This slow growth is counterintuitive because the terms themselves shrink to zero.
The series appears in many real-world contexts:
- Music and acoustics: The harmonic series (overtones) is the basis of musical harmonics — a vibrating string produces frequencies that are integer multiples of the fundamental. The wavelengths are 1, 1/2, 1/3, 1/4, … of the fundamental wavelength.
- Computer science: The expected number of comparisons in quicksort, and the average number of steps in certain hash-table operations, involve harmonic numbers.
- Mathematics: The harmonic numbers are connected to the Riemann zeta function, the Euler–Mascheroni constant, and the digamma function.
- Physics: The energy levels of the hydrogen atom (the Rydberg formula) involve differences of reciprocals of squares, a related series.
For most practical purposes, you rarely need more than a few hundred terms, but the calculator handles up to a million so you can see the slow growth firsthand.
How to Use the Calculator
Enter any positive integer for n. The calculator sums the reciprocals from 1 to n. The default is 10, which gives a nice, round result. If you enter a very large n (like 1,000,000), the calculator will take a moment but will return the sum accurately to 6 decimal places.
Reading the results:
- Partial sum H(n): The exact sum of the first n terms. This is the main answer.
- ln(n) + γ: The natural-log approximation. It is always slightly less than the true sum for n ≥ 1.
- Difference: How far off the approximation is. For n = 10, it’s about 0.049; for n = 100, it drops to about 0.005; for n = 1,000,000, it’s about 0.0000005.
If you need the exact rational fraction, that’s not shown here because the denominator grows astronomically (for n = 20, the denominator has about 19 digits). The decimal value is what you’ll use in practice.
Common Mistakes and Misconceptions
One frequent error is confusing the harmonic series with the alternating harmonic series (1 – 1/2 + 1/3 – 1/4 + …), which converges to ln(2) ≈ 0.693. The plain harmonic series diverges; the alternating one does not.
Another mistake is thinking that because the terms approach zero, the sum must converge. That’s false — the harmonic series is the classic counterexample. The terms shrink, but not fast enough.
When computing by hand, people often round each term too early. For example, rounding 1/3 to 0.33 and 1/7 to 0.14 introduces errors that accumulate. Use full precision until the final step, as the calculator does.
Also, be careful with n = 0. The harmonic series starts at n = 1. The calculator’s minimum is 1, so entering 0 is rejected. If you see a formula like H(0) = 0, that’s a convention, but it’s not part of the series itself.
Limits of the Formula and Approximation
The exact sum is only computable by direct addition, which is what the calculator does. The approximation ln(n) + γ is excellent for large n — the error is about 1/(2n). For n = 100, the error is about 0.005; for n = 10,000, it’s about 0.00005. If you need more precision, add the 1/(2n) term:
H(n) ≈ ln(n) + γ + 1/(2n)
That brings the error down to about 1/(12n²). For n = 10, the error becomes about 0.0008 instead of 0.049.
The calculator’s approximation uses only ln(n) + γ, so the difference column shows exactly how much accuracy you gain by using the full sum. For n up to a million, the difference is negligible for most purposes.
One limitation: the calculator uses floating-point arithmetic, so for n beyond about 10^15, rounding errors would dominate. But that’s far beyond any realistic use — even n = 10^6 is already extreme.
Related Series and Extensions
If you’re exploring harmonic numbers, you might also encounter:
- The p-series: Sum of 1/n^p. If p > 1, it converges; if p ≤ 1, it diverges. The harmonic series is the p = 1 case.
- The alternating harmonic series: Converges to ln(2).
- The generalized harmonic numbers: H(n, r) = 1 + 1/2^r + 1/3^r + … + 1/n^r. For r = 1, it’s the classic harmonic series.
- The digamma function: ψ(n) = H(n-1) – γ, which connects harmonic numbers to calculus.
These are beyond the scope of this calculator, but they show that the harmonic series is just one member of a larger family.
Frequently Asked Questions
Does the harmonic series converge?
No. The infinite sum 1 + 1/2 + 1/3 + … grows without bound, though very slowly. To reach a sum of 100, you’d need about 1.5 × 10^43 terms. This is a famous result proven in the 14th century by Nicole Oresme, who showed that you can group terms to make the sum larger than any finite number.
What is the Euler–Mascheroni constant?
It’s the limit of the difference between the harmonic sum and the natural logarithm: γ = lim (H(n) – ln(n)) as n → ∞. Its value is about 0.5772156649. It appears in many areas of mathematics, but it’s not known whether it’s rational or irrational — that’s an open problem.
How many terms do I need to reach a certain sum?
There’s no exact formula, but a good approximation is n ≈ e^(H – γ), where H is the target sum and e is Euler’s number (≈ 2.718). For H = 10, that gives n ≈ e^(10 – 0.577) ≈ 12,367, which matches the exact value. For H = 20, it gives about 272 million.
Why is the harmonic series important in music?
Musical harmonics (overtones) are frequencies that are integer multiples of a fundamental frequency. The wavelengths are proportional to 1, 1/2, 1/3, 1/4, …, which is exactly the harmonic series. This is why a vibrating string or air column produces a rich tone — the sum of these harmonics creates the timbre.
Can I use this calculator for the alternating harmonic series?
No, this calculator only sums the positive reciprocals. For the alternating series (1 – 1/2 + 1/3 – 1/4 + …), you’d need a different tool. That series converges to ln(2) ≈ 0.693147, and it converges much faster.
What is the difference between H(n) and ln(n)?
H(n) is always slightly larger than ln(n). The difference approaches the Euler–Mascheroni constant γ as n grows. For example, H(10) ≈ 2.93 while ln(10) ≈ 2.30, a difference of about 0.63. For n = 1,000,000, the difference is about 0.577, very close to γ.
Related
Formula used
in n | Number of terms (n) | - | 10 | 1 | 1000000 out sum | Partial sum H(n) | - | sum(1 / i, i=1, n) | 6 out approx | ln(n) + gamma | - | ln(n) + 0.5772156649 | 6 out diff | Difference (exact - approx) | - | (sum(1 / i, i=1, n)) - (ln(n) + 0.5772156649) | 6
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
- 2 x 2 Inches in cm: Quick Conversion & Uses
- 50mm to Inches: Quick Answer & Conversion Guide
- 6ft in Inches? Quick Height Conversion
- 5 Foot 6 in Inches: Quick Conversion & Guide
- 70x100cm to Inches: Exact Size & Easy Conversion
- 1.96 Inches to mm: Exact Conversion