Divide the count by the sum of the reciprocals. For 60 and 40 that is 2 ÷ (1/60 + 1/40) = 48. The reason it is not 50 is that the slow leg takes longer: at 60 the first 120 miles take two hours, at 40 the return takes three, so 240 miles take five hours — and 240 ÷ 5 is 48. The harmonic mean is what that calculation always comes to.
Sixty there, forty back
Drive 120 miles at 60 mph: two hours. Drive back at 40 mph: three hours. Total 240 miles in five hours, which is 48 mph.
Not 50. The arithmetic mean treats the two speeds as equally important, and they are not — you spent three hours at the slower one and two at the faster. The slow leg gets more weight because it occupies more of the journey.
The page works that journey through for any pair you enter, computing it from the legs rather than from the formula. That the two agree is the demonstration, and the suite checks it across two thousand generated pairs.
Which average, and how to decide
The question to ask is what is held FIXED.
Fixed distance, varying speed: harmonic. Each leg is the same length, so the slow ones take longer and count more.
Fixed time, varying speed: arithmetic. Drive an hour at 60 and an hour at 40 and you really did average 50, because each speed applied for equally long.
Same two numbers, two different correct answers, decided entirely by the setup. That is why the choice of mean is a modelling decision rather than a preference.
Where the weighting comes from
The harmonic mean is the arithmetic mean of the reciprocals, inverted. A small rate has a large reciprocal, so it takes a larger share of the total.
For 60 and 40 the reciprocals are 0.0167 and 0.025, and the shares are 40% and 60%. That 60% is exactly the fraction of the journey spent going slowly — the weighting is not a device, it is the time.
It also explains the harmonic mean’s character: it leans towards the smallest value, hard. With 1 and 100 it is 1.98, barely above the smaller one, because a leg at speed 1 dominates everything.
The F1 score is one of these
In machine learning, the F1 score is the harmonic mean of precision and recall. It is chosen deliberately, not for elegance.
A model with precision 1.0 and recall 0.0 has an arithmetic mean of 0.5, which sounds acceptable and describes a model that finds nothing. The harmonic mean is 0, which is the honest summary.
That is the general property: the harmonic mean punishes a bad component in a way the arithmetic mean does not. Wherever both numbers must be decent for the whole to be decent, it is the right average.
Why zero has no answer
Zero has no reciprocal, so a set containing one has no harmonic mean. The page refuses rather than returning something small.
In the journey reading that is exactly right: a leg travelled at zero speed never finishes, so the average speed over the whole trip is undefined rather than low.
Mixed signs are refused for a related reason. Reciprocals of opposite signs can cancel, producing an average larger than every input or a sign belonging to neither — a number with no interpretation. For data that changes sign, the arithmetic mean is the one that applies.
Other places it turns up
Average price per unit. Spend the same amount at two different prices and your average price paid is their harmonic mean, not their arithmetic one. Dollar-cost averaging works for exactly this reason: fixed spend buys more units when the price is low.
Combined work rates. Two people who each take a different time on the same job combine harmonically, which is why the classic “how long together” puzzle has the answer it does.
Parallel resistance. Resistors in parallel combine as the harmonic mean divided by the count — the same reciprocal sum, for the same structural reason.
Sources and methodology
The harmonic mean is standard; these are the references for the places it is required.
Method. The mean is n divided by the sum of the reciprocals. For a pair the page also simulates a fixed-distance journey — computing each leg’s time from its speed, summing them, and dividing total distance by total time — and the suite asserts the two agree across two thousand generated pairs. The arithmetic mean is computed alongside for contrast. That engine is verified on every change against 61 hand-written assertions, including that the harmonic mean equals total distance over total time in two thousand independently simulated journeys. The count and the per-case breakdown are published on the formula verification page.
Read the guide
For quantities that multiply rather than divide — growth rates, ratios — the Geometric Mean Calculator applies. If the items simply count differently, the Weighted Average Calculator is the one.