Harmonic Mean Calculator
Find the harmonic mean of up to 8 positive numbers, the right average for speeds, rates and ratios, and compare it with the arithmetic and geometric means.
Enter 2 to 8 positive values:
How to Use
- Enter at least two positive values: type them into Value 1 and Value 2. Zero and negative numbers are not accepted, and the calculator tells you why.
- Add more values if you have them: up to eight values are supported. Leave unused fields blank.
- Read the harmonic mean: the result updates as you type, with the arithmetic mean, geometric mean, count and sum of reciprocals shown beside it.
- Check the fit: the harmonic mean is the right average when each value covers the same amount of the quantity in the denominator, such as equal distances for speeds.
What You'll Discover
- Harmonic mean: the headline result, n divided by the sum of the reciprocals. It always sits between your smallest and largest value.
- Arithmetic mean: the ordinary average, shown so you can see how far the harmonic mean falls below it.
- Geometric mean: the nth root of the product. For positive values that are not all equal, harmonic < geometric < arithmetic.
- Number of values: how many fields were filled in, which is the n in the formula.
- Sum of reciprocals: the denominator of the formula, 1/x₁ + 1/x₂ + …, useful for checking a hand calculation.
If any value is zero, the harmonic mean is undefined because 1/0 cannot be calculated. If any value is negative, the calculator stops and asks for positive values. In both cases it shows a short explanation instead of a number.
Harmonic Mean Formula
The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals:
HM = n / (1/x₁ + 1/x₂ + … + 1/xₙ)
To do it by hand, take the reciprocal of each value, add them up, and divide the number of values by that sum. For 2, 4 and 8 the reciprocals are 0.5, 0.25 and 0.125, which add to 0.875, so HM = 3 ÷ 0.875 ≈ 3.43.
Shortcut for two numbers
With only two values a and b the formula simplifies to:
HM(a, b) = 2ab / (a + b)
For 60 and 40 that is (2 × 60 × 40) ÷ 100 = 48. For two numbers there is also a neat link between the three averages: HM = GM² ÷ AM. Using 2 and 8, GM = 4 and AM = 5, so HM = 16 ÷ 5 = 3.2.
Harmonic Mean Examples
Example 1: Average speed on a round trip
You drive 120 miles to a destination at 60 mph and 120 miles back at 40 mph. The outbound leg takes 120 ÷ 60 = 2 hours and the return takes 120 ÷ 40 = 3 hours. The total is 240 miles in 5 hours, so your average speed is 240 ÷ 5 = 48 mph. That is exactly HM(60, 40). The simple average, 50 mph, overstates it because you spent more time at the slower speed.
Example 2: Fuel economy over equal distances
A car gets 25 mpg on one 100-mile stretch and 40 mpg on another 100-mile stretch. The first uses 100 ÷ 25 = 4 gallons and the second uses 100 ÷ 40 = 2.5 gallons. That is 200 miles on 6.5 gallons, or about 30.77 mpg, which matches HM(25, 40). The arithmetic mean, 32.5 mpg, is too high.
Example 3: Average P/E ratio with equal money in each stock
Suppose you put $100 into each of three stocks with P/E ratios of 10, 20 and 40. The earnings behind your money are $10, $5 and $2.50, which total $17.50 on $300 invested. The portfolio P/E is 300 ÷ 17.5 ≈ 17.14, which equals HM(10, 20, 40). The arithmetic mean, 23.33, would overstate it.
Harmonic Mean vs Arithmetic Mean vs Geometric Mean
The arithmetic, geometric and harmonic means are the three Pythagorean means. They answer different questions, and for positive values that are not all equal they always rank the same way: harmonic < geometric < arithmetic. When every value is identical, all three are equal.
| Values | Harmonic | Geometric | Arithmetic |
|---|---|---|---|
| 5, 5, 5 | 5 | 5 | 5 |
| 2, 8 | 3.2 | 4 | 5 |
| 2, 4, 8 | 3.43 | 4 | 4.67 |
| 1, 2, 3, 4, 5 | 2.19 | 2.61 | 3 |
| 10, 20, 30 | 16.36 | 18.17 | 20 |
| 1, 1, 1, 1000 | 1.33 | 5.62 | 250.75 |
The arithmetic mean adds values and suits quantities that combine by addition, like test scores. The geometric mean multiplies values and suits quantities that combine by growth factors; the geometric mean calculator covers that case. The harmonic mean averages reciprocals and suits rates where equal amounts of the denominator are involved, such as equal distances at different speeds.
The harmonic mean is pulled strongly toward the smallest values. In the last row of the table, one value of 1,000 barely moves it, while the arithmetic mean jumps to 250.75. If you simply want the ordinary average, the average calculator is the quicker tool.
A simple way to choose: if the real-world quantities are added together, such as money or scores, use the arithmetic mean. If they are multiplied together, such as growth factors, use the geometric mean. If they are "per" quantities measured over equal amounts of the denominator, use the harmonic mean.
When to Use the Harmonic Mean
Use the harmonic mean when you are averaging rates, meaning "something per something", and each value applies to the same amount of the thing on the bottom. If the amounts differ, a weighted version is needed instead. The table shows how the choice depends on what is held equal.
| Situation | What is equal | Correct average |
|---|---|---|
| Average speed over several legs | Distance of each leg | Harmonic |
| Average speed over several legs | Time spent on each leg | Arithmetic |
| Fuel economy (mpg) over several trips | Distance of each trip | Harmonic |
| Fuel economy (mpg) over several trips | Fuel used on each trip | Arithmetic |
| Average P/E of a portfolio | Money invested in each stock | Harmonic |
| Growth over several periods | Nothing; factors multiply | Geometric |
F1 score in machine learning
The F1 score is the harmonic mean of precision and recall, 2PR ÷ (P + R). With precision 0.8 and recall 0.5 it is 0.62. Because the harmonic mean is dragged toward the lower value, a model cannot hide poor recall behind excellent precision: 0.9 and 0.1 give an F1 of only 0.18, even though their arithmetic mean is 0.5.
Resistors in parallel
For n resistors in parallel, 1/Rtotal = 1/R₁ + 1/R₂ + …, so Rtotal equals the harmonic mean divided by n. For 100, 200 and 300 ohms, HM ≈ 163.64, and 163.64 ÷ 3 ≈ 54.55 ohms.
Weighted Harmonic Mean, Zeros and Outliers
When the weights are not equal
The calculator gives each value the same weight. If the legs of a trip have different lengths, use the weighted harmonic mean: the sum of the weights divided by the sum of weight over value, or W / Σ(w/x). For 60 km at 30 km/h and 120 km at 60 km/h, that is 180 ÷ (60/30 + 120/60) = 180 ÷ 4 = 45 km/h.
You can get the same answer here when the weights are small whole numbers. Weights of 1 and 2 mean entering 30 once and 60 twice: HM(30, 60, 60) = 45. This works up to eight entries in total. The weighted average calculator handles weights for the ordinary arithmetic average, which is a different calculation.
Zeros and negative numbers
A zero makes the formula divide by zero, so the harmonic mean is undefined. As a value shrinks toward zero, the harmonic mean shrinks toward zero too, but at exactly zero there is no valid result. Negative values break the logic of averaging rates: reciprocals of opposite signs can cancel, so the sum of reciprocals can be zero or tiny and produce a meaningless answer. This calculator therefore requires every value to be greater than zero.
Outliers
The harmonic mean is insensitive to very large values but very sensitive to small ones. Take 10, 12, 14 and 1,000: the harmonic mean is 15.64 against an arithmetic mean of 259. Replace the 1,000 with 0.5 and the harmonic mean collapses to 1.77 while the arithmetic mean is 9.13. Check small values in your data before relying on the result.
What Is the Harmonic Mean If...
What is the harmonic mean if I drive 60 mph one way and 40 mph back?
If both legs cover the same distance, the harmonic mean of 60 and 40 is 48, which is your true average speed. The formula 2ab ÷ (a + b) gives (2 × 60 × 40) ÷ 100 = 48. The usual average of 50 mph is wrong here because the slower leg takes longer.
What is the harmonic mean if my two numbers are 2 and 8?
The harmonic mean of 2 and 8 is 3.2. Using HM = 2ab ÷ (a + b), that is 32 ÷ 10 = 3.2. For comparison, the geometric mean is 4 and the arithmetic mean is 5.
What is the harmonic mean if all my values are equal?
If every value is the same, the harmonic mean equals that value. For 5, 5 and 5, the reciprocals add to 0.6 and 3 ÷ 0.6 = 5. In this one case the harmonic, geometric and arithmetic means all coincide.
What is the harmonic mean if my values are 1, 2, 3, 4 and 5?
The harmonic mean of 1, 2, 3, 4 and 5 is about 2.19. The reciprocals sum to 2.2833, and 5 ÷ 2.2833 ≈ 2.19. That is well below the arithmetic mean of 3 because the small values weigh heavily.
What is the harmonic mean if one value is very small?
A very small value pulls the harmonic mean close to itself. For 0.01 and 100, HM = 2 × 0.01 × 100 ÷ 100.01 ≈ 0.02, while the arithmetic mean is about 50. The tiny value dominates because its reciprocal, 100, dwarfs the other reciprocal, 0.01.
What is the harmonic mean if one value is a huge outlier?
A huge value barely changes the harmonic mean. For 1, 1, 1 and 1,000, the harmonic mean is about 1.33, while the arithmetic mean is 250.75. The large value's reciprocal is almost zero, so it adds nearly nothing to the sum of reciprocals.
What is the harmonic mean if one value is zero?
The harmonic mean is undefined if any value is zero, because the formula needs 1/0. The calculator shows "Undefined" and a short explanation. If a zero is a real observation, such as a leg where you did not move, the harmonic mean is not the right average for that data.
What is the harmonic mean if a value is negative?
The calculator does not compute it, and it asks for positive values. Rates such as speed, price-to-earnings and mpg are positive, so negative inputs usually mean a typing or sign error. Mixing positive and negative reciprocals can also make the sum of reciprocals cancel out, giving a meaningless result.
What is the harmonic mean if the trip legs are different lengths?
Use the weighted harmonic mean, with each leg's distance as its weight. For 60 km at 30 km/h and 120 km at 60 km/h, the average speed is 180 ÷ (2 + 2) = 45 km/h. Entering 30, 60 and 60 in the calculator reproduces that, because 60 appears twice for the leg that is twice as long.
What is the harmonic mean if I have more than 8 values?
Calculate the harmonic mean of each group, then combine the groups using their counts as weights. The combined result is (n₁ + n₂) ÷ (n₁/HM₁ + n₂/HM₂). With groups (2, 4, 8) and (1, 2), HM₁ ≈ 3.4286 and HM₂ ≈ 1.3333, giving 5 ÷ (0.875 + 1.5) ≈ 2.105. Keep unrounded group results to avoid drift.
People Also Search For
Harmonic mean formula for two numbers
For two numbers a and b, the harmonic mean is 2ab ÷ (a + b). It comes from the general formula n ÷ (1/a + 1/b) after simplifying. For 30 and 60 it gives (2 × 30 × 60) ÷ 90 = 40.
Harmonic mean vs arithmetic mean
The arithmetic mean averages the values themselves; the harmonic mean averages their reciprocals and then flips the result back. Use the arithmetic mean for ordinary quantities and the harmonic mean for rates over equal amounts of the denominator. For positive values that are not all equal, the harmonic mean is always the smaller of the two.
How to calculate the harmonic mean in Excel
Use the HARMEAN function, for example =HARMEAN(A1:A5). Microsoft's documentation notes that HARMEAN returns the #NUM! error if any data point is zero or less, the same restriction this calculator applies. See the HARMEAN function reference for details.
Harmonic mean of precision and recall (F1 score)
The F1 score is the harmonic mean of precision and recall, 2PR ÷ (P + R). Because the harmonic mean sits close to the smaller input, F1 is low whenever either precision or recall is low. Enter your precision and recall as two values (for example 0.8 and 0.5) to get 0.62.
Why is the harmonic mean always smaller than the arithmetic mean?
For positive values that are not all equal, HM < GM < AM, a result known as the AM-GM-HM inequality. Taking reciprocals gives extra weight to small values, which pulls the average down. For 2 and 8 the three means are 3.2, 4 and 5.
Harmonic progression and the harmonic mean
A harmonic progression is a sequence whose reciprocals form an arithmetic progression, and the harmonic mean of two terms is the term between them. In the sequence 6, 4, 3 the reciprocals 1/6, 1/4 and 1/3 rise by 1/12 each step. The harmonic mean of 6 and 3 is (2 × 18) ÷ 9 = 4, the middle term.
Frequently Asked Questions
What is the harmonic mean?
The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals: n divided by the sum of 1/x for each value. It is one of the three Pythagorean means, alongside the arithmetic and geometric means, and it is the right average for rates such as speed over equal distances.
When should I use the harmonic mean?
Use it when averaging rates ("X per Y") and each value applies to the same amount of Y. Typical cases are average speed over legs of equal distance, fuel economy over equal distances, and the P/E ratio of a portfolio with equal money in each stock. If the amounts of Y differ, use a weighted harmonic mean.
Why is the average speed not just (60 + 40) / 2 = 50 mph?
Because you spend more time at the slower speed. If each leg is 120 miles, 60 mph takes 2 hours and 40 mph takes 3 hours. Total distance is 240 miles in 5 hours, so the average speed is 48 mph. The simple average of speeds is only correct when equal time, not equal distance, is spent at each speed.
Is the harmonic mean always less than the arithmetic mean?
Yes, for positive values that are not all equal. The order is harmonic < geometric < arithmetic. The three are equal only when every value is identical. The harmonic mean is also never smaller than your smallest value or larger than your largest.
How is the harmonic mean used in finance?
It is used to average ratios such as price-to-earnings (P/E) across holdings. If you invest equal amounts of money in each stock, the harmonic mean of their P/E ratios equals the portfolio's P/E. For unequal amounts, use a weighted harmonic mean with the amounts as weights. This page is for general calculation and is not investment advice.
What happens if one value is zero?
The harmonic mean is undefined, because the formula needs 1/0. The calculator shows "Undefined" with a short explanation rather than a number. Some tools return 0 by convention, since the harmonic mean approaches zero as a value shrinks toward zero, but this calculator reports it as undefined.
Can I enter negative numbers?
No. This calculator asks for values greater than zero. The harmonic mean is meant for positive quantities such as speeds and prices, and negative reciprocals can cancel positive ones and make the result meaningless.
How many values can I enter?
Between 2 and 8. For more, find the harmonic mean of each group and combine the groups with their counts as weights: (n₁ + n₂) divided by (n₁/HM₁ + n₂/HM₂).
How do I calculate the harmonic mean by hand?
Take the reciprocal of each value, add the reciprocals, then divide the number of values by that sum. For 2, 4 and 8 the reciprocals total 0.875 and 3 ÷ 0.875 ≈ 3.43. For two values you can use 2ab ÷ (a + b).
Does the order of the values matter?
No. The formula adds reciprocals, and addition does not depend on order, so entering 60 and 40 gives the same result as 40 and 60.
What does the sum of reciprocals mean?
It is 1/x₁ + 1/x₂ + … for your values, the denominator in the harmonic mean formula. Dividing the number of values by it gives the harmonic mean. It is shown so you can check a hand calculation.
Why does the calculator also show the arithmetic and geometric means?
Comparing them shows how much the choice of average matters. The gap between the harmonic and arithmetic means grows as your values spread out. If you simply need the ordinary average, the average calculator is a quicker option.
Is my data stored or sent anywhere?
No. All calculations run in your browser. Nothing you type is sent to a server or saved, and no account is needed.
Last reviewed: November 2026 — formulas and worked examples verified.