Harmonic Mean Calculator
The harmonic mean is the reciprocal of the average of the reciprocals: n ÷ Σ(1/x). For 40 and 60 it is 48, below the arithmetic mean of 50. It gives the correct average speed when you travel equal distances at different speeds.
Last updated · By S. Dilshan · Runs in your browser, nothing is uploaded
Step-by-Step Solution
What Is the Harmonic Mean?
The harmonic mean is an average designed for rates and ratios, such as speed, price per unit or work per hour. It is calculated by averaging the reciprocals of the values and then taking the reciprocal of that average. Because reciprocals weight small values heavily, the harmonic mean is pulled toward the smallest numbers, and it is always the smallest of the three classic means.
The classic puzzle: you drive a route at 40 km/h on the way out and 60 km/h on the way back. What is your average speed for the whole trip? Many people say 50 km/h, but the answer is 48 km/h. You spend more time at the slower speed, so it counts for more. The harmonic mean accounts for that automatically.
Which Mean for Which Job?
| Situation | Right average | Why |
|---|---|---|
| Test scores of five students | Arithmetic | Values simply add |
| Investment returns over several years | Geometric | Values compound |
| Speed over equal distances | Harmonic | Time, not distance, is what adds |
| Combining precision and recall (F1 score) | Harmonic | Penalises a weak component |
Harmonic Mean Formula
x₁ … xₙare the positive values.nis the number of values.Σ(1/x)is the sum of the reciprocals.
For exactly two numbers a and b the formula simplifies to 2ab ÷ (a + b). Every value must be positive, and none can be zero, because 1/0 is undefined. See also the geometric mean and the ordinary arithmetic mean.
Worked Example: Average Speed
A car covers equal distances at 40 km/h and 60 km/h.
- Reciprocals: 1/40 = 0.025 and 1/60 = 0.016667.
- Sum of reciprocals: 0.041667.
- Harmonic mean: 2 ÷ 0.041667 = 48 km/h.
- Shortcut: 2 × 40 × 60 ÷ (40 + 60) = 4,800 ÷ 100 = 48.
Proof with Real Distances
Say each leg is 120 km. The outward leg takes 120 ÷ 40 = 3 hours and the return takes 120 ÷ 60 = 2 hours. The total is 240 km in 5 hours, an average speed of exactly 48 km/h, not 50.
Example: The F1 Score
In machine learning, the F1 score is the harmonic mean of precision and recall. With precision 0.8 and recall 0.6 it is 2 × 0.8 × 0.6 ÷ (0.8 + 0.6) = 0.6857, below the arithmetic mean of 0.70. The harmonic mean punishes the weaker figure, so a model cannot score well by excelling at only one measure.
How to Use This Harmonic Mean Calculator
- Enter your positive numbers separated by commas or spaces.
- Read the harmonic mean, the sum of reciprocals, the arithmetic mean for comparison and the count.
- Open the steps to see each reciprocal.
Make sure every value is a rate measured over the same quantity, such as the same distance or the same amount of work. If the denominators differ, a weighted harmonic mean is needed.
Real-World Uses of the Harmonic Mean
- Travel and logistics: average speed over equal distances.
- Finance: averaging price multiples such as price-to-earnings ratios across a portfolio.
- Machine learning: the F1 score combines precision and recall.
- Physics and electronics: parallel resistors, lenses and combined rates behave like harmonic means.
- Work problems: if two people finish a job in different times, the harmonic mean describes the typical rate.
Example: Averaging Price-to-Earnings Ratios
You invest the same amount in two stocks with P/E ratios of 10 and 20. The average earnings yield is the mean of 10% and 5%, which is 7.5%, so the portfolio’s P/E is 1 ÷ 0.075 = 13.33. That is the harmonic mean of 10 and 20 (2 ÷ (0.1 + 0.05) = 13.33), whereas the arithmetic mean of 15 overstates it.
Parallel Resistors
Two resistors of 6 Ω and 3 Ω in parallel give an equivalent resistance of 1 ÷ (1/6 + 1/3) = 2 Ω, which is half of their harmonic mean of 4 Ω.
What Are the Most Common Mistakes With the Harmonic Mean Calculator?
- Using it when the arithmetic mean is correct. If you spend equal time at each speed, the arithmetic mean gives the average speed.
- Including zero. A zero value makes the reciprocal undefined.
- Negative values. Mixed signs can give meaningless results.
- Ignoring weights. Unequal distances or amounts need a weighted harmonic mean.
- Forgetting to take the final reciprocal. The sum of reciprocals alone is not the mean.
- Being dominated by small values. One tiny number can pull the harmonic mean down sharply.
Where Can You Verify These Formulas?
The definitions and formulas on this page follow standard references. Check them against these sources:
Built and maintained by S. Dilshan. Found a mistake? Email [email protected] with the page address.
Frequently Asked Questions
What is the harmonic mean formula?
n ÷ (1/x₁ + 1/x₂ + … + 1/xₙ). For two numbers it equals 2ab ÷ (a + b).
When do I use the harmonic mean?
Use it to average rates or ratios over equal amounts of the underlying quantity, such as speeds over equal distances, or to combine measures like precision and recall.
Why is the average speed 48 and not 50?
You spend more time at the slower speed, so it carries more weight. The harmonic mean reflects total distance divided by total time.
Is the harmonic mean always the smallest mean?
Yes. For positive numbers, harmonic ≤ geometric ≤ arithmetic, with equality only if all values are equal.
Can I use zero in a harmonic mean?
No. The reciprocal of zero is undefined, so every value must be positive.
What is the harmonic mean of 40 and 60?
It is 48. The calculation is 2 × 40 × 60 ÷ (40 + 60) = 4,800 ÷ 100.