Harmonic Mean Calculator

The harmonic mean is the count of numbers divided by the sum of their reciprocals. For 20 and 30 it is 2 ÷ (1/20 + 1/30) = 24 (see the steps). Use it to average rates, such as speeds over equal distances.

Find the harmonic mean

Type or paste two or more positive numbers. The answer updates as you type.

Commas, spaces or new lines between numbers. Decimals and fractions such as 3/4 work. Ctrl + Enter calculates.

Optional. For grouped data or a weighted harmonic mean.

Examples:

How to Use This Calculator

  1. Type or paste numbers

    Separate them with commas, spaces or new lines. Decimals and fractions such as 3/4 work.

  2. Add weights if needed

    Tick Weights or counts for a frequency table, or for speeds over different distances.

  3. Read the answer

    You get the exact harmonic mean with the working, and the geometric and arithmetic means to compare.

What is the harmonic mean?

The harmonic mean is an average worked out through reciprocals. Flip every number (20 becomes 1/20), take the ordinary average of those flipped values, then flip the result back. For 20 and 30, the reciprocals 1/20 and 1/30 average to 1/24, so the harmonic mean is 24.

It is one of the three classic averages, along with the arithmetic mean and the geometric mean, and it is always the smallest of the three. Small numbers have large reciprocals, so they pull the harmonic mean down much harder than large numbers pull it up. The harmonic mean of 1 and 100 is about 1.98, while the arithmetic mean is 50.5.

The harmonic mean formula

HM = n ÷ (1/x₁ + 1/x₂ + … + 1/xₙ)
two numbers:  HM = 2ab ÷ (a + b)
three numbers:  HM = 3abc ÷ (ab + bc + ca)

Here n is how many numbers you have and x1 to xn are the numbers themselves. The two shortcuts come from putting the fractions over a common denominator, and they are the quickest way to do the sum by hand. Every number has to be positive, because a 0 has no reciprocal.

How to calculate the harmonic mean

  1. Count the numbers. Call the count n.
  2. Write the reciprocal of each one: 1 divided by the number.
  3. Add the reciprocals together.
  4. Divide n by that sum.

For 2, 3 and 4, n is 3. The reciprocals are 1/2, 1/3 and 1/4. Over the common denominator 12 they are 6/12, 4/12 and 3/12, which add up to 13/12. Then 3 ÷ (13/12) = 36/13, about 2.7692. Keeping the fractions until the last step gives an exact answer; rounding each reciprocal to a decimal first can shift the last digits.

Show 2, 3 and 4 in the calculator

Harmonic mean of two numbers: examples

For two numbers a and b the harmonic mean is 2ab ÷ (a + b): twice the product over the sum. It is a whole number only when a + b divides 2ab evenly; otherwise it is a fraction, shown here with its decimal. Each pair opens in the calculator.

Harmonic means of common pairs of numbers
Numbers 2ab ÷ (a + b) Harmonic mean Decimal
1 and 2 4 ÷ 3 4/3≈ 1.3333 ≈ 1.3333
2 and 6 24 ÷ 8 3
3 and 6 36 ÷ 9 4
4 and 9 72 ÷ 13 72/13≈ 5.5385 ≈ 5.5385
4 and 12 96 ÷ 16 6
5 and 20 200 ÷ 25 8
10 and 15 300 ÷ 25 12
10 and 40 800 ÷ 50 16
12 and 24 576 ÷ 36 16
20 and 30 1,200 ÷ 50 24
40 and 60 4,800 ÷ 100 48
60 and 30 3,600 ÷ 90 40

Why average speed is a harmonic mean

You drive 60 km to a town at 60 km/h and drive the same 60 km back at 30 km/h. The average of the two speeds is 45 km/h, yet the way out takes 1 hour and the way back takes 2 hours, so you cover 120 km in 3 hours: 40 km/h. That 40 is the harmonic mean of 60 and 30.

The reason is that a speed is distance per hour, and the distances were equal while the hours were not. You spend more time at the slow speed, so the slow speed counts for more. Adding reciprocals (1/60 and 1/30 of an hour per kilometer) adds up the time per kilometer, which is what really happened. The same rule holds for any rate whose top part stays fixed: prices per item when you spend the same amount each time, or pages per hour when each person prints the same number of pages.

Average 60 and 30 km/h

If you drive for equal times instead, say 1 hour at 60 and 1 hour at 30, the ordinary average of 45 is right. And if the distances differ, use the weighted harmonic mean below with the distances as weights.

Weighted harmonic mean and grouped data

When the values do not count equally, give each one a weight w. The total weight goes on top and each weight is divided by its value underneath:

HM = (w₁ + w₂ + … + wₙ) ÷ (w₁/x₁ + w₂/x₂ + … + wₙ/xₙ)

Average speed over different distances

You drive 100 km at 50 km/h and then 60 km at 80 km/h. With the distances as weights, the harmonic mean is 160 ÷ (100/50 + 60/80) = 160 ÷ 2.75 ≈ 58.18 km/h. That is the total distance divided by the total time (2 hours plus 45 minutes), so it is the true average speed.

Show the two-leg trip in the calculator

Grouped data

In a frequency table, the frequencies are the weights. Each value is divided into its frequency, the results are added, and the total frequency is divided by that sum.

Harmonic mean of a frequency table
Value x Frequency f f ÷ x
2 3 1.5
4 2 0.5
8 1 0.125
Total 6 2.125

The harmonic mean is 6 ÷ 2.125 = 48/17, about 2.8235. With class intervals such as 10 to 20, use the midpoint of each class as its value.

Show the frequency table in the calculator

Harmonic vs geometric vs arithmetic mean

For positive numbers the three classic means (the Pythagorean means) always come in the same order, AM ≥ GM ≥ HM, and they are equal only when every number is the same. Which one is right depends on how the numbers combine.

Arithmetic, geometric and harmonic means compared
Mean How Use it for 20 and 30
Arithmetic Add, divide by n Amounts that add up: scores, prices, heights 25
Geometric Multiply, take the nth root Growth rates, ratios, values that multiply ≈ 24.4949
Harmonic n divided by the sum of 1/x Rates over equal amounts: speeds, prices per item 24

For two numbers the three are tied together by GM² = AM × HM. With 20 and 30, 25 × 24 = 600, and √600 ≈ 24.4949 is the geometric mean. The gap between the means grows as the numbers spread out, so a big gap tells you the choice of average matters. Our average calculator and geometric mean calculator cover the other two.

Zeros, negatives and Excel

The harmonic mean needs positive numbers. A 0 has no reciprocal, so the formula stops working; some software reports 0 in that case, since the harmonic mean heads toward 0 as any value does. Negative numbers are worse, because a positive and a negative reciprocal can cancel: 1 and −1 add up to 0, and the formula would divide by 0.

=HARMEAN(A2:A20)
=SUM(B2:B20)/SUMPRODUCT(B2:B20/A2:A20)

HARMEAN works in Excel and Google Sheets and returns #NUM! for a 0 or a negative value. The second line is the weighted version, with the values in column A and the weights in column B.

Frequently Asked Questions

What is the harmonic mean of 20 and 30?

The harmonic mean of 20 and 30 is 24. For two numbers, use 2ab ÷ (a + b): 2 × 20 × 30 = 1,200, and 1,200 ÷ 50 = 24. The long way gives the same answer: 1/20 + 1/30 = 1/12, and 2 ÷ (1/12) = 24.

Show 20 and 30 in the calculator

How do you calculate the harmonic mean?

Take the reciprocal of each number, add the reciprocals up, and divide the count by that sum. For 2, 3 and 4: 1/2 + 1/3 + 1/4 = 13/12, and 3 ÷ (13/12) = 36/13, which is about 2.7692.

Show 2, 3 and 4 step by step

What is the harmonic mean formula?

HM = n ÷ (1/x₁ + 1/x₂ + … + 1/xₙ), where n is how many numbers there are. For two numbers this simplifies to 2ab ÷ (a + b), and for three to 3abc ÷ (ab + bc + ca).

When should you use the harmonic mean instead of the arithmetic mean?

Use it to average rates when the thing on top of the rate stays fixed: speeds over equal distances, prices per item when you spend the same amount each time, or work rates for the same amount of work. If you drive 60 km at 60 km/h and 60 km back at 30 km/h, your average speed is the harmonic mean, 40 km/h, not 45.

Show 60 and 30 km/h in the calculator

What is the relationship between AM, GM and HM?

For positive numbers, AM ≥ GM ≥ HM, and all three are equal only when every number is the same. For two numbers there is also an exact link: GM² = AM × HM. With 20 and 30, AM = 25, HM = 24 and GM = √600, and 25 × 24 = 600.

How do you calculate the harmonic mean in Excel?

Use =HARMEAN(A1:A10) for numbers in cells A1 to A10; Google Sheets has the same function. HARMEAN returns #NUM! if any value is 0 or negative. For a weighted harmonic mean, use =SUM(B1:B10)/SUMPRODUCT(B1:B10/A1:A10) with the weights in column B.

Can the harmonic mean be zero or negative?

No. The harmonic mean is defined for positive numbers only. A 0 breaks the formula because 1/0 has no value, and with negative numbers the reciprocals can cancel out, so the result means nothing.