ToolNimba Browse

🎵 Harmonic Mean Calculator

By ToolNimba Math Team · Updated 2026-06-19

Harmonic mean
-
Geometric mean
-
Arithmetic mean
-
Count (n)
-
Sum of reciprocals
-
Product of values
-

The harmonic mean is the right average to use when your numbers are rates: speeds, prices per unit, ratios or any "per something" quantity. Enter a list of positive numbers and this calculator returns the harmonic mean using HM = n / sum(1/x), and it also shows the arithmetic and geometric means so you can compare the three side by side. All three are computed in your browser, nothing is sent anywhere.

What is the Harmonic Mean Calculator?

The harmonic mean is one of the three classical Pythagorean means, alongside the arithmetic mean (the plain average you already know) and the geometric mean. You find it by taking the reciprocal of each value, averaging those reciprocals, and then taking the reciprocal of that result. Written as a formula it is HM = n / (1/x1 + 1/x2 + ... + 1/xn), where n is how many numbers you have. Because it relies on reciprocals, every value must be greater than zero, a single zero would make a reciprocal infinite and break the calculation.

The reason it matters is that it gives the correct answer when you average rates over a fixed base. The classic case is average speed: if you drive a fixed distance at 40 km/h and the same distance back at 60 km/h, your average speed for the whole trip is the harmonic mean (48 km/h), not the arithmetic mean (50 km/h). You spent more time at the slower speed, so the slow leg pulls the true average down. The same logic applies to averaging price-to-earnings ratios across stocks, computing the F1 score in machine learning (the harmonic mean of precision and recall), and combining resistors in parallel.

For any set of positive numbers that are not all identical, the three means always line up in the same order: harmonic mean is the smallest, geometric mean sits in the middle, and arithmetic mean is the largest (HM ≤ GM ≤ AM). They are equal only when every number is the same. The harmonic mean is pulled hardest toward the smallest values in your data, which is exactly why it resists being skewed upward by a few large outliers and why it suits rates where small values represent slow or expensive cases that deserve more weight.

When to use it

  • Finding true average speed when equal distances are covered at different speeds.
  • Averaging rates such as price per litre, cost per unit, or items produced per hour.
  • Computing the F1 score in data science, the harmonic mean of precision and recall.
  • Averaging financial multiples like price-to-earnings ratios across a portfolio.
  • Combining values in parallel, for example the total resistance of resistors wired in parallel.

How to use the Harmonic Mean Calculator

  1. Type or paste your positive numbers, separated by commas, spaces, or new lines.
  2. Make sure every value is greater than zero, the harmonic mean is undefined for zero or negative numbers.
  3. Read off the harmonic mean in the highlighted box.
  4. Compare it with the geometric and arithmetic means shown alongside to see how skewed your data is.

Formula & method

HM = n / (1/x1 + 1/x2 + ... + 1/xn), where n is the count of values and each x must be greater than 0. For two numbers a and b this simplifies to HM = 2ab / (a + b).

Worked examples

Find the harmonic mean of 1, 2 and 4.

  1. n = 3
  2. Sum of reciprocals = 1/1 + 1/2 + 1/4 = 1 + 0.5 + 0.25 = 1.75
  3. HM = n / sum = 3 / 1.75 = 1.714286
  4. For comparison: arithmetic mean = (1 + 2 + 4) / 3 = 2.333333
  5. Geometric mean = (1 x 2 x 4)^(1/3) = 8^(1/3) = 2

Result: Harmonic mean ≈ 1.714286 (note HM < GM < AM: 1.714 < 2 < 2.333)

A car covers equal distances at 40 km/h and 60 km/h. What is its average speed?

  1. Use the two-number shortcut HM = 2ab / (a + b)
  2. HM = (2 x 40 x 60) / (40 + 60)
  3. HM = 4800 / 100 = 48
  4. The arithmetic mean would be (40 + 60) / 2 = 50, which is too high

Result: Average speed = 48 km/h, lower than the naive 50 km/h because more time is spent at 40 km/h

The three Pythagorean means compared on the same data sets

Data setHarmonic meanGeometric meanArithmetic mean
2, 83.245
1, 2, 41.71428622.333333
40, 604848.989850
5, 5, 5555

When to reach for each mean

MeanBest forExample
HarmonicRates over a fixed baseAverage speed, price per unit
GeometricGrowth rates and ratiosAverage annual return, index numbers
ArithmeticAdditive quantitiesTest scores, heights, ordinary totals

Common mistakes to avoid

  • Using the plain (arithmetic) average for rates. Averaging two speeds over equal distances with the arithmetic mean overstates the result. Equal distances mean more time is spent at the slower speed, so the harmonic mean is the correct figure.
  • Including zero or negative values. The harmonic mean depends on reciprocals, so a value of 0 makes 1/0 undefined and negatives produce meaningless results. This tool only accepts numbers greater than zero.
  • Confusing the harmonic mean with the geometric mean. They are different means. The harmonic mean averages reciprocals, the geometric mean multiplies values and takes the nth root. For the same positive data the harmonic mean is always the smaller of the two.
  • Forgetting the fixed-base condition for average speed. The harmonic mean gives average speed only when the distances are equal. If equal times are spent at each speed instead, the arithmetic mean of the speeds is the correct average.

Glossary

Harmonic mean
The reciprocal of the average of the reciprocals: n divided by the sum of 1/x. Best for averaging rates.
Reciprocal
One divided by a number. The reciprocal of x is 1/x, so the reciprocal of 4 is 0.25.
Arithmetic mean
The ordinary average: add the values and divide by how many there are.
Geometric mean
The nth root of the product of n values, used for growth rates and ratios.
Pythagorean means
The trio of classical means (arithmetic, geometric, harmonic) that always satisfy HM ≤ GM ≤ AM.

Frequently asked questions

What is the harmonic mean?

The harmonic mean is an average defined as n divided by the sum of the reciprocals of your values: HM = n / (1/x1 + 1/x2 + ... + 1/xn). It is the most appropriate average for rates and ratios, because it correctly weights smaller values more heavily than the ordinary arithmetic mean does.

When should I use the harmonic mean instead of the average?

Use the harmonic mean when your numbers are rates measured over a fixed base, such as speeds over equal distances, price per unit, or items per hour. In those situations the plain arithmetic mean overstates the true average, while the harmonic mean gives the correct result.

How do I calculate the harmonic mean of two numbers?

For two values a and b there is a simple shortcut: HM = 2ab / (a + b). For example, the harmonic mean of 40 and 60 is (2 x 40 x 60) / (40 + 60) = 4800 / 100 = 48. This is the same answer the full reciprocal formula gives.

Why can the harmonic mean not handle zero or negative numbers?

The formula divides by each value through its reciprocal, so a value of zero gives 1/0, which is undefined, and negative values make the result lose its meaning as an average of rates. For that reason this calculator only accepts numbers greater than zero.

Is the harmonic mean always smaller than the arithmetic mean?

Yes, for any set of positive numbers that are not all identical the harmonic mean is the smallest of the three Pythagorean means, the geometric mean is in the middle, and the arithmetic mean is the largest (HM ≤ GM ≤ AM). The three are equal only when every value in the set is the same.

How is the harmonic mean used in the F1 score?

In machine learning the F1 score is the harmonic mean of precision and recall: F1 = 2 x (precision x recall) / (precision + recall). The harmonic mean is used because it punishes a low value in either metric, so a model only scores well if both precision and recall are reasonably high.