Harmonic Mean Calculator

Enter two positive numbers a and b. The calculator computes the harmonic mean H = 2ab/(a+b) = 2/(1/a+1/b). 3 and 6 give 4, 1 and 3 give 1.5, and 60 and 90 on equal legs give average speed 72, not 75. This is not an n-value list mean and not a weighted-distance speed model.

Input

Result

Enter two positive numbers a and b.

Domain: a > 0 and b > 0. Zero and negatives yield a domain error. Exactly two numbers — not an n-term list.

How it works

How H is computed for 3 and 6
a3
b6
H4

The harmonic mean of two positive numbers a and b is the reciprocal of the arithmetic mean of their reciprocals: H = 2 / (1/a + 1/b). Clearing the common denominator yields the equivalent form H = 2ab / (a + b). With a = 3 and b = 6 one gets H = 36/9 = 4. With a = 1 and b = 3 one gets H = 6/4 = 1.5. With speeds 60 and 90 on equal legs one gets H = 72 — that is the average speed for the whole trip, not (60+90)/2 = 75.

For any positive a and b the Pythagorean-means inequality AM ≥ GM ≥ HM holds, that is (a+b)/2 ≥ √(a·b) ≥ 2ab/(a+b), with equality if and only if a = b. The harmonic mean is therefore the smallest of the three classical means and pulls more strongly toward the smaller value. That is why averaging rates and equal-distance speeds with AM overstates the true average pace.

The calculator uses the numbers you enter in the fields a (srednia-harmoniczna-dwoch-a) and b (srednia-harmoniczna-dwoch-b). The domain is a > 0 and b > 0. Zero or a negative value yields a domain error — the reciprocal 1/a is undefined in the reals at a = 0, and negative rates lose their usual meaning. Comma and period in the fields are equivalent.

The result panel shows H, the arithmetic mean AM, the geometric mean GM, the reciprocals 1/a and 1/b, the sum of reciprocals, and an AM–GM–HM bar diagram. Worked examples: 3 and 6 give 4; 1 and 3 give 1.5; 60 and 90 give 72; 2 and 2 give 2; 40 and 60 give 48; 4 and 9 give about 5.538462 with AM = 6.5 and GM = 6.

The neighbor geometric-mean page computes the square root of the product. The arithmetic-mean page averages a variable-length list. Here there are always exactly two positive numbers and the formula 2/(1/a+1/b). The calculator does not compute a weighted harmonic mean or an n-term mean for n > 2.

Formula

H = 2 / (1/a + 1/b) = 2ab / (a + b) for a > 0, b > 0.

Comparison: AM = (a + b) / 2, GM = √(a · b), and the inequality AM ≥ GM ≥ HM.

Symbols: a, b — fields srednia-harmoniczna-dwoch-a and -b; H — result. Mathematical model: the harmonic mean among the Pythagorean means (Hardy–Littlewood–Pólya; MathWorld).

Theory, domain, and Pythagorean means

Definition

For positive real numbers a and b the two-argument harmonic mean is defined by H(a,b) = 2 / (1/a + 1/b). Equivalently H(a,b) = 2ab / (a + b). The first form stresses that H is the reciprocal of the arithmetic mean of the reciprocals; the second is convenient on paper. Both are identically equal when a ≠ 0 and b ≠ 0. On this page the domain is restricted to a > 0, b > 0 — the classical setting of the Pythagorean means and of rate averaging.

The general harmonic mean of n positive numbers x₁, …, xₙ is H = n / (Σᵢ₌₁ⁿ 1/xᵢ). For n = 2 the formula reduces exactly to the form used by this calculator. Mathematical model: the harmonic mean as one of the three Pythagorean means alongside the arithmetic and geometric means (Hardy–Littlewood–Pólya, Inequalities; Bullen, Handbook of Means and Their Inequalities; MathWorld — Harmonic Mean).

In teaching practice it helps to separate the mathematical identity from floating-point limits: this calculator shows the browser’s floating-point result, not a symbolic paper proof. When inputs are extreme, check the domain (a > 0, b > 0) first, then the floating-point range.

Historical and conceptual context

The Pythagorean means — arithmetic, geometric, and harmonic — were already known in ancient Greece in the theory of proportions and music (intervals, harmonic means of string lengths). In modern inequality theory the AM–GM–HM chain is a textbook staple (Hardy–Littlewood–Pólya). In statistics and finance the harmonic mean appears when averaging ratio-defined indicators (price–earnings, densities, throughputs) and when averaging speeds over equal distances.

Conceptually this calculator does not replace the geometric mean (multiplicative growth) or the arithmetic mean (additive quantities). It also does not compute a weighted harmonic mean Σ wᵢ / Σ (wᵢ/xᵢ). A longer list would use the n-term formula; this calculator deliberately has exactly two fields.

The speed motivation is the clearest classroom story: if you cover two equal legs at speeds a and b, total time is d/a + d/b, so average speed v̄ = 2d / (d/a + d/b) = H(a,b). The arithmetic mean (a+b)/2 would match equal time on both legs, not equal length — hence the classic trap “60 and 90 → 75 instead of 72”.

Formal properties

Domain: a > 0, b > 0. Range: H(a,b) > 0. Degree-1 homogeneity: H(λa, λb) = λ H(a,b) for λ > 0. Symmetry: H(a,b) = H(b,a). Monotonicity: if 0 < a ≤ a′ and 0 < b ≤ b′, then H(a,b) ≤ H(a′,b′).

AM–GM–HM inequality: for a, b > 0 one has (a+b)/2 ≥ √(a b) ≥ 2ab/(a+b), with equality ⇔ a = b. Thus HM is not always ≤ min(a,b) in a trivial sense that would exclude interior values (with 3 and 6, H = 4 lies between 3 and 6), but always H ≤ GM ≤ AM and min(a,b) ≤ H ≤ max(a,b).

Link to parallel resistors: the equivalent of two parallel resistors is R₁ ∥ R₂ = R₁R₂/(R₁+R₂) = H(R₁,R₂)/2. Series capacitors share the same reciprocal structure. That shows why the harmonic mean naturally describes quantities combined by summing reciprocals.

Full derivation

Step 1. From the arithmetic mean of reciprocals: A(1/a, 1/b) = (1/a + 1/b)/2.

Step 2. The harmonic mean is the reciprocal of that quantity: H = 1 / A(1/a, 1/b) = 2 / (1/a + 1/b).

Step 3. Algebra: 1/a + 1/b = (a+b)/(ab), so 2 / ((a+b)/(ab)) = 2ab/(a+b).

Step 4. Speed derivation: v̄ = total distance / total time = 2d / (d/a + d/b) = 2 / (1/a + 1/b) = H(a,b).

Step 5. HM ≤ GM follows from AM–GM on 1/a and 1/b: ((1/a)+(1/b))/2 ≥ √(1/(ab)); inverting (1/t decreasing on positives) yields H ≤ √(ab).

Special cases

Examples: a = 3, b = 6 → H = 4; a = 1, b = 3 → H = 1.5; a = 60, b = 90 → H = 72; a = 2, b = 2 → H = 2; a = 40, b = 60 → H = 48; a = 4, b = 9 → H = 72/13 ≈ 5.538462. When a = b one always has H = a = AM = GM.

An empty field leaves the placeholder (no result). Invalid text yields a parse error. a ≤ 0 or b ≤ 0 yields a domain error. The calculator no longer returns 0 when a + b = 0 — such a pair already falls outside a, b > 0.

Limits: as b → ∞ with fixed a > 0, H(a,b) → 2a; as b → 0⁺, H → 0⁺. That illustrates how a very small rate pulls the harmonic mean down hard.

Numerical notes

The calculator computes H = 2 / (1/a + 1/b), which is numerically equivalent to 2ab/(a+b) for moderate positive a, b in floating-point arithmetic. For extremely large a and b the product 2ab may overflow the floating-point range earlier than the sum of reciprocals; for tiny positives the reciprocals become large. For typical school and engineering values both paths are safe.

Comma and period are equivalent in the parser. Result formatting uses en-US / pl-PL locale and trims unnecessary zeros. The bar diagram scales AM, GM, and HM against the maximum of the three so the AM ≥ GM ≥ HM inequality is visible at a glance.

The calculator does not weight observations — both numbers enter with weight 1 in the n = 2 sense.

Related notions and sources

Related: geometric mean of two numbers (√(ab)), arithmetic mean of a list, weighted mean. In physics and electronics — parallel resistances and series capacitances. In finance — harmonic averaging of ratio indicators such as P/E for equal investment amounts.

Sources Hardy, Littlewood, Pólya — Inequalities (Cambridge); Bullen — Handbook of Means and Their Inequalities; Weisstein, Eric W. — “Harmonic Mean”, MathWorld; Wikipedia — Harmonic mean; NIST/SEMATECH e-Handbook (location measures in the context of means). CalcBoxer educational tool — the result does not replace a textbook.

How to use

  1. Enter a positive a, for example 3.
  2. Enter a positive b, for example 6.
  3. Click Calculate or wait for the live result. 3 and 6 give 4. 1 and 3 give 1.5. 60 and 90 give 72.
  4. Check the panel: AM, GM, reciprocals, and the AM–GM–HM diagram.
  5. Zero or a negative value yields a domain error. Use the geometric-mean page for √(ab).

Symbol glossary

With 3 and 6 the harmonic mean is 4. With 60 and 90 it is 72 — average speed on equal legs.

H
Harmonic mean 2ab/(a+b). With 3 and 6 it is 4. With 1 and 3 it is 1.5.
a, b
Positive numbers in fields srednia-harmoniczna-dwoch-a and -b. Order does not change H.
AM
Arithmetic mean (a+b)/2. With 60 and 90 it is 75 — larger than H = 72.
GM
Geometric mean √(ab). With 4 and 9 it is 6; then H ≈ 5.538462.
1/a, 1/b
Reciprocals. H is the reciprocal of the arithmetic mean of 1/a and 1/b.

Examples

Example 1

  • a = 3
  • b = 6

4

What is the harmonic mean of 3 and 6? 4.

Example 2

  • a = 1
  • b = 3

1.5

What do 1 and 3 give? H = 1.5.

Example 3

  • a = 60
  • b = 90

72

What average speed at 60 and 90? 72, not 75.

Example 4

  • a = 2
  • b = 2

2

What if a = b = 2? H = AM = GM = 2.

Example 5

  • a = 40
  • b = 60

48

What do 40 and 60 give? H = 48.

Example 6

  • a = 4
  • b = 9

≈ 5.538462

What about 4 and 9? H ≈ 5.538462.

Related calculators

Frequently asked questions

What is the domain of the two-number harmonic mean?

Both numbers must be positive: a > 0 and b > 0. Zero and negatives have no (real) harmonic mean here, because 1/a is undefined or loses rate-averaging meaning. The calculator then shows a domain error, not a misleading zero.

What is the harmonic mean of 3 and 6?

The result is 4. H = 2×3×6/(3+6) = 36/9 = 4, equivalently H = 2/(1/3+1/6) = 2/(1/2) = 4. That is the first example on this page.

What about 1 and 3, and 60 and 90?

1 and 3 give H = 1.5. 60 and 90 (speeds on equal legs) give H = 72. The arithmetic mean of 60 and 90 is 75 — the average speed over equal distances is the harmonic mean, not the arithmetic one.

How does this differ from the geometric and arithmetic means?

Arithmetic is (a+b)/2. Geometric is √(a·b). Harmonic is 2ab/(a+b). For positive a ≠ b one has AM > GM > HM. When a = b all three coincide.

Why is average speed on equal distances H, not AM?

Time on a leg of length d at speed v is d/v. On two equal legs at speeds a and b the total time is d/a + d/b, so average speed is 2d/(d/a+d/b) = 2/(1/a+1/b) = H(a,b).

Does the order of a and b change the result?

No. H(a,b) = H(b,a) because product and sum are commutative. 3 and 6 and 6 and 3 both give 4.

What if a = b?

Then H = a. With 2 and 2 the result is 2, and AM = GM = HM = 2 at once.

Do zero or negative values work?

No. If a ≤ 0 or b ≤ 0 the calculator reports a domain error. An earlier version of the calculator returned 0 when a+b = 0; here the domain is explicitly positive.

How many numbers does this calculator take?

Exactly two: fields a and b. The n-term harmonic mean is n/(Σ 1/xᵢ), but this page computes only the two-argument form.

Do the currency and unit settings in the page header affect the result?

No. The result depends only on a and b. The currency and unit settings in the page header do not affect this result.

Does a comma in 1.5 work?

Yes. 1.5 and 1,5 are the same number. Comma and period in the fields are equivalent.

What else does the panel show besides H?

The arithmetic mean AM, geometric mean GM, reciprocals 1/a and 1/b, the sum of reciprocals, and a bar diagram comparing AM, GM, and HM on a shared scale.

How do I calculate the harmonic mean of two numbers?

Use H = 2ab/(a+b), equivalently H = 2/(1/a+1/b). For 3 and 6: 36/9 = 4. Both numbers must be positive.

What is the harmonic mean of 40 and 60?

H = 2×40×60/100 = 48. The arithmetic mean is 50 — the panel also shows AM and GM beside H.

Is this the harmonic mean of many numbers (n > 2)?

No. Here there are exactly two fields a and b. For n values the formula is n/(Σ 1/xᵢ) — this page does not compute that.

Do 60 and 90 always give average speed 72?

Yes for two equal-distance legs at speeds 60 and 90. With unequal distances the pair a, b alone is not enough — the calculator does not weight segment lengths.

How does the harmonic mean differ from the geometric mean?

The geometric mean is √(a·b); the harmonic mean is 2ab/(a+b). For positive a ≠ b one has AM > GM > HM. When a = b all three are equal.

The result is H = 2ab/(a+b): with 3 and 6 it is 4; with 60 and 90 it is 72. For √(ab) use the geometric mean page.

Sources

The definition and AM–GM–HM inequality below come from recognized sources.

Page updated November 3, 2026.