Harmonic Mean Calculator
When rates apply over the same fixed quantity — equal distances, equal spend, equal work — averaging them arithmetically gives the wrong answer. The harmonic mean gives the right one.
Formula
- xᵢ
- = each rate, all strictly positive
- n
- = the number of rates
- 1/xᵢ
- = the reciprocal — time per unit rather than units per time
The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals. That is exactly what makes it correct for rates: it averages in the domain where the quantities actually add.
How to use this calculator
- Enter your rates, separated by commas or spaces. All must be positive and non-zero.
- Press Calculate. The harmonic mean appears alongside the arithmetic and geometric means for comparison.
- Use this only when the rates apply over the same fixed quantity. If they apply over the same fixed time, the arithmetic mean is correct instead.
- For unequal distances or quantities, weight the values — the harmonic mean assumes each rate applies to an equal share.
Worked example
Driving out at 30 mph and back at 60 mph
The instinct is to average 30 and 60 to get 45 mph. But you spend twice as long at 30 mph as at 60 mph, because the distance is the same and the slow leg takes longer. The slow speed dominates the trip.
Check it directly: over 60 miles each way, the outbound leg takes 2 hours and the return leg 1 hour. That is 120 miles in 3 hours.
- 1/30 + 1/60 = 0.0333 + 0.0167 = 0.05
- 2 ÷ 0.05 = 40
Answer: 40 mph, not 45 — and 120 miles ÷ 3 hours confirms it exactly.
The rule: what is held constant decides the mean
This is the whole idea in one sentence. If each rate applies over the same distance, quantity or amount of work, use the harmonic mean. If each rate applies over the same time, use the arithmetic mean.
Driving 60 miles at 30 mph and 60 miles at 60 mph holds distance constant, so the answer is harmonic: 40 mph. Driving for one hour at 30 mph and one hour at 60 mph holds time constant, so the answer is arithmetic: 45 mph. Same two speeds, different question, different correct answer.
Why slow legs dominate
The harmonic mean is always pulled towards the smallest value, because reciprocals magnify small numbers. Halving one rate roughly doubles its reciprocal and therefore its influence on the sum, while doubling a rate only halves its already-small contribution.
That behaviour matches reality. In a two-leg trip, you can make the fast leg arbitrarily fast without ever getting the average above twice the slow speed — because the time spent on the slow leg does not go away. This is also why a single slow stage dominates a pipeline's throughput, and why one badly-performing component caps overall system speed.
| Rates | Harmonic | Arithmetic | Interpretation |
|---|---|---|---|
| 30, 60 | 40.00 | 45.00 | Equal distances out and back |
| 20, 80 | 32.00 | 50.00 | Slow leg dominates heavily |
| 50, 50 | 50.00 | 50.00 | Identical rates — means coincide |
| 10, 1000 | 19.80 | 505.00 | Fast leg barely helps |
Beyond average speed
Price per unit across equal spend. Spending $100 on shares at $20 and another $100 at $25 gives an average cost per share of the harmonic mean, $22.22 — not $22.50. This is the arithmetic behind dollar-cost averaging, and it is why fixed-amount investing beats fixed-quantity investing on average cost.
Parallel work rates. Combining workers or machines that each complete a fixed job at different rates uses reciprocal arithmetic in the same way.
F1 score. In machine learning, the F1 score is the harmonic mean of precision and recall. It is chosen precisely because the harmonic mean punishes imbalance — a model with 100% precision and 1% recall gets an F1 of about 2%, not the 50.5% an arithmetic mean would report.
Unequal distances need weights
The plain harmonic mean assumes each rate covers an equal share. If you drive 100 miles at 30 mph and 20 miles at 60 mph, the shares are not equal and the simple formula does not apply.
In that case compute it directly: total distance divided by total time. Here that is 120 miles ÷ (3.333 + 0.333) hours = 32.7 mph. Equivalently, use a weighted harmonic mean with the distances as weights. The speed, distance and time calculator handles individual legs directly.
Important considerations
- Every rate must be positive and non-zero; a zero rate has an infinite reciprocal.
- The harmonic mean is always the smallest of the three classical means.
- It assumes each rate applies over an equal share of the fixed quantity.
- For unequal shares, use a weighted harmonic mean or compute total ÷ total directly.
- When time rather than distance is held constant, the arithmetic mean is correct.
Common mistakes to avoid
- Averaging speeds arithmetically over equal distances. This is the single most common error in average-speed problems.
- Using the harmonic mean when time is constant. Equal durations call for the arithmetic mean.
- Applying it to unequal distances. Weight by distance, or divide total distance by total time.
- Including a zero rate. Its reciprocal is undefined and the calculation collapses.
- Using it for additive quantities. The harmonic mean is only for rates and ratios.
Frequently asked questions
What is the harmonic mean?
The number of values divided by the sum of their reciprocals. For 30 and 60: 2 ÷ (1/30 + 1/60) = 2 ÷ 0.05 = 40. It is the reciprocal of the arithmetic mean of the reciprocals.
Why is the average speed 40 mph and not 45?
Because you spend twice as long on the 30 mph leg as on the 60 mph leg when the distances are equal. Over 60 miles each way, that is 2 hours out and 1 hour back — 120 miles in 3 hours, which is exactly 40 mph.
When do I use harmonic versus arithmetic mean?
Ask what is held constant. Equal distances, quantities or amounts of work call for the harmonic mean. Equal time periods call for the arithmetic mean. The same two rates give different correct answers depending on which it is.
Why is the harmonic mean always the smallest?
Reciprocals magnify small values, so low rates carry disproportionate weight in the sum. The ordering harmonic ≤ geometric ≤ arithmetic holds for any set of positive numbers, with equality only when all values are identical.
Can I use it with negative numbers or zero?
No. Zero has an undefined reciprocal, and mixing signs makes the reciprocal sum unstable and the result meaningless. All rates must be strictly positive.
What if my distances are not equal?
The simple formula no longer applies. Divide the total distance by the total time, or use a weighted harmonic mean with the distances as weights.
Related calculators
Tools people usually open alongside this one.
Geometric Mean Calculator
The right average for growth rates and ratios — the nth root of the product.
Open calculator
Average Calculator
Mean, median, mode and range from one list of numbers, with the sorted data shown.
Open calculator
Weighted Average Calculator
Average values that carry different importance — credits, portfolio sizes, category weights.
Open calculator
Median Calculator
The middle value of a data set, with quartiles and the interquartile range.
Open calculator