Skip to content
Math

Harmonic Mean Calculator

Find the harmonic mean of any set of positive numbers, with or without weights. The calculator shows the full step-by-step working and compares the result to the arithmetic and geometric means so you can see at a glance which average is right for your data.

Your details

Enter two or more positive numbers separated by commas.
Turn on to assign a weight to each value. Useful for P/E ratios across unequal position sizes.
Controls how many decimal places are shown in every result.
Harmonic meanHarmonic mean computed
40
Arithmetic mean45
Geometric mean42.4264
Count of values2
Sum of reciprocals0.05
Sum of weights2
Harmonic mean40
Geometric mean42.4264
Arithmetic mean45

Harmonic mean of your 2 values is 40.

  • Harmonic mean = 40, arithmetic mean = 45, geometric mean = 42.4264.
  • The classic inequality holds: H (40) <= G (42.4264) <= A (45).
  • Use the harmonic mean when averaging rates over a fixed unit, such as miles per hour across equal distances or P/E ratios across equal dollar investments.
  • Two-value shortcut confirms: 2 * 30 * 60 / (30 + 60) = 40.

Next stepToggle "Weighted harmonic mean" to assign different importance to each value.

Formula

H=ni=1n1xi,Hw=i=1nwii=1nwixi,HGAH = \dfrac{n}{\displaystyle\sum_{i=1}^{n}\frac{1}{x_i}}, \qquad H_w = \dfrac{\displaystyle\sum_{i=1}^{n}w_i}{\displaystyle\sum_{i=1}^{n}\frac{w_i}{x_i}}, \qquad H \leq G \leq A

Worked example

Speed example: driving 1 mile at 30 mph then 1 mile at 60 mph. H = 2*30*60/(30+60) = 3600/90 = 40 mph, not the arithmetic 45 mph. The harmonic mean is correct because each leg covers the same distance (fixed unit). G = sqrt(30*60) = 42.43 mph, and A = 45 mph, confirming H <= G <= A.

How the harmonic mean works

The harmonic mean is found by dividing the number of values by the sum of their reciprocals. Flip every number to one-over-itself, add those fractions, then divide the count by that total. Because reciprocals inflate small numbers, the harmonic mean sits closer to the smallest values in your dataset and is always less than or equal to both the geometric mean and arithmetic mean of the same positive numbers. The three means share an elegant inequality: H <= G <= A, with equality holding only when every value is identical.

Weighted harmonic mean

When each value in your set carries a different importance, use the weighted form: divide the total weight by the sum of each weight divided by its corresponding value. This matters most in finance: averaging P/E ratios across an index should use position sizes as weights because a larger holding has more influence on the portfolio return. Using a plain (unweighted) average of P/E ratios systematically overstates the true portfolio-level ratio when valuations differ widely. Toggle the weighted mode, enter one weight per value in the same order as your values, and the calculator switches the formula automatically.

When to use the harmonic mean instead of a plain average

Reach for the harmonic mean whenever you are averaging rates or ratios defined per unit of something fixed. Classic examples: average speed over equal distances, average fuel efficiency over equal distance legs, average price per unit across equal-size purchases, and P/E ratios across equal-dollar investments. In machine learning, the F1 score is the harmonic mean of precision and recall, which penalises models that sacrifice one for the other. In geometry, the harmonic mean appears in the altitude-on-hypotenuse theorem and in the crossed-ladders problem. The arithmetic mean is correct when values simply add up (total hours worked by a team); the geometric mean is correct for compounding growth rates. When in doubt, ask whether a doubling of one value should halve the average, as it does for speeds. If yes, use the harmonic mean.

Two-value and three-value shortcuts

For exactly two values x and y, the harmonic mean simplifies to 2xy / (x + y), a formula that also defines the harmonic mean in geometry. For three values x, y, z, it becomes 3xyz / (xy + yz + zx). These shortcuts are useful for quick mental checks. A related identity connects all three Pythagorean means: for any two positive numbers, G squared equals H times A, or G = sqrt(H * A). This means the geometric mean is the square root of the product of the harmonic and arithmetic means, which is a handy cross-check when you already know two of the three.

Why every value must be positive

The formula divides one by each value, so a zero creates division by zero and the harmonic mean is undefined. Negative numbers can produce reciprocals that cancel one another and give a result that is meaningless for rate-averaging. The harmonic mean is defined only for strictly positive numbers. If your data includes zeros or negatives, the arithmetic mean or a trimmed mean is the right tool instead.

When to use each Pythagorean mean

MeanFormulaBest forClassic example
Harmonic (H)n / sum(1/xi)Rates over a fixed unitAverage speed over equal distances
Geometric (G)nth root of productGrowth and compoundingCompound annual growth rate
Arithmetic (A)sum / nQuantities that add upAverage temperature over days

For positive data, the inequality H <= G <= A always holds. Equality holds only when all values are identical.

Frequently asked questions

How is the harmonic mean different from the regular average?

The arithmetic mean adds the values and divides by the count. The harmonic mean divides the count by the sum of the reciprocals. The harmonic mean is always smaller (or equal when all values match) and is the correct average for rates such as speed over equal distances or P/E ratios across equal investments. Using the arithmetic mean in those situations overstates the true result.

When should I use the weighted harmonic mean?

Use it when each value contributes a different amount to the whole. The most common case is finance: to average P/E ratios across an index where each stock has a different market capitalisation, use those market caps as weights. Another case is averaging fuel economy across a fleet where vehicles travel different total distances; use distance as the weight. The formula becomes the total weight divided by the sum of each weight divided by its value.

What is the two-value shortcut for the harmonic mean?

For exactly two positive values x and y, the harmonic mean equals 2xy / (x + y). For example, 30 mph and 60 mph gives 2*30*60 / (30+60) = 3600 / 90 = 40 mph. This is the same formula as the formula for two resistors in parallel and for the harmonic mean in geometry.

Why is the harmonic mean always less than the arithmetic mean?

Taking reciprocals magnifies small values relative to large ones, dragging the result downward. The classic proof uses the AM-HM inequality, a direct consequence of the Cauchy-Schwarz inequality. The only exception is when all values are equal: then all three Pythagorean means coincide.

What is the G squared equals H times A identity?

For any two positive numbers, the geometric mean squared equals the harmonic mean times the arithmetic mean: G^2 = H * A. This links all three Pythagorean means and is useful as a cross-check. If you compute any two of the three means for a two-value set, you can derive the third from this identity.

Can I use the harmonic mean with zero or negative numbers?

No. A zero produces division by zero, and negatives can cause reciprocals to cancel, making the result undefined or meaningless. The harmonic mean is defined only for strictly positive numbers. If your dataset contains zeros or negatives, use the arithmetic mean or a different summary statistic.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…