Example 1
- a = 3, b = 7
7
What is max(3, 7)? 7.
Enter two real numbers a and b. The result is the larger one: max(a, b). For 3 and 7 the value is 7. For −2 and 5 the value is 5. When a and b are equal, the result equals that common value. This page does not compute argmax or the maximum of a list longer than two arguments.
Enter a and b.
Two fields, one result. Min, max, and range with a third number live on minimum and maximum of numbers. List range — on range (max − min).
The maximum of two real numbers is the larger one with respect to the usual order on ℝ. Piecewise: max(a, b) = a when a ≥ b; otherwise max(a, b) = b. The calculator uses the numbers you enter in fields a and b and computes max(a, b) — the same result as the classical definition.
An equivalent absolute-value identity is max(a, b) = (a + b + |a − b|) / 2. The midpoint of the segment is (a+b)/2, and half the distance is |a−b|/2; their sum reaches the larger endpoint. When a ≥ b, |a−b| = a−b and the expression simplifies to a; when b > a it simplifies to b. The minimum has the twin formula min(a, b) = (a + b − |a − b|) / 2. Hence max + min = a + b and max − min = |a − b|.
When a = b both branches give the same value; |a−b| = 0. Field order does not change the result (commutativity). Negatives and zero compare as on the line: −2 and 5 give 5; 0 and −3 give 0; −8 and −3 give −3. Worked examples: 3 and 7 → 7; −2 and 5 → 5; 4 and 4 → 4; 2.5 and 1 → 2.5.
max returns a value, not an index. argmax would indicate which field wins; a tie does not pick a unique index. Min, max, and range of three numbers live on a neighbouring page; list range on another. An empty field leaves the result blank. A comma and a period are equivalent.
Mathematical model: maximum with respect to the order on ℝ and the identity max = (a+b+|a−b|)/2 (standard in real analysis / algebra textbooks). Not a 0–100 scale or a custom “index” — only the larger of two numbers.
max(a, b) = a when a ≥ b; otherwise max(a, b) = b.
Equivalently: max(a, b) = (a + b + |a − b|) / 2. Minimum: min(a, b) = (a + b − |a − b|) / 2.
Computation: max(a, b). Model: maximum with respect to the order on ℝ + absolute-value identity.
The maximum of two real numbers a and b, written max(a, b), is the larger of them: max(a, b) = a when a ≥ b, and b when b ≥ a. An equivalent branch-free algebraic identity is max(a, b) = (a + b + |a − b|)/2. Dually min(a, b) = (a + b − |a − b|)/2. The calculator uses max(a, b) and shows a check of the absolute-value identity.
The definition is standard in analysis and in Concrete Mathematics (Knuth et al.); MathWorld (Maximum) gives the same |·| formula. In programming max is a built-in library function.
In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.
Comparing two magnitudes is prior to the full min/max lattice on sets. In optimization, statistics (sample extrema), and graphics (clipping), max is everyday. The |a − b| identity lets one write max in languages that have abs but awkward branching — useful in proofs and in smoothed automatic differentiation.
Conceptually max of two numbers does not sort lists or compute percentiles. A separate min–max–range calculator handles two or three values together with the range.
In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.
Domain: a, b ∈ ℝ. Codomain: ℝ. max(a, a) = a; max(a, b) = max(b, a); max(a, max(b, c)) = max(max(a, b), c). max(a, b) ≥ a and max(a, b) ≥ b.
Links: max(a, b) + min(a, b) = a + b; max(a, b) − min(a, b) = |a − b|. Positive homogeneity: max(λa, λb) = λ max(a, b) for λ ≥ 0; for λ < 0 the inequality flips toward min.
The formula (a + b + |a − b|)/2 follows by checking the cases a ≥ b and a < b.
In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.
Step 1. If a ≥ b, then |a − b| = a − b, so (a + b + a − b)/2 = a = max(a, b).
Step 2. If a < b, then |a − b| = b − a, so (a + b + b − a)/2 = b = max(a, b).
Step 3. In both cases the formula holds. Analogously min(a, b) = (a + b − |a − b|)/2.
Step 4. max selects by comparison; the result must match the identity in floating-point arithmetic up to the representation of |·|.
In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.
Examples: max(3, 7) = 7; max(−2, 5) = 5; max(4, 4) = 4; max(0, −3) = 0; max(−8, −3) = −3. When a = b, |a − b| = 0 and the formula yields a.
NaN in computer arithmetic propagates through max in a browser-dependent way; this calculator requires finite numeric inputs.
In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.
The comparison a ≥ b is exact for finite numbers other than NaN. The abs identity may overflow a + b for huge |a|, |b| even when max is finite — hence library max is safer; the panel still shows both routes on typical data.
Comma and period are equivalent. The axis diagram marks both values and the maximum.
In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.
Related: min–max–range (list of 2–3 numbers), floor, square of a sum. The median of three is a separate model.
Authorities: Concrete Mathematics; MathWorld — Maximum; Wikipedia — Maxima and minima; ECMAScript Math.max. Educational tool.
In classroom practice it helps to separate the mathematical formula from floating-point limits: this calculator reports the browser’s floating-point computation (about 15–16 significant digits), not a symbolic identity on paper. When inputs are extreme, check the domain first, then the floating-point range.
max(a, b) = (a+b+|a−b|)/2. For 3 and 7 the maximum is 7. The panel also shows min and |a−b|.
7
What is max(3, 7)? 7.
5
What is max(−2, 5)? 5.
4
What is max(4, 4)? 4.
0
What is max(0, −3)? 0.
2.5
What is max(2.5, 1)? 2.5.
−3
What is max(−8, −3)? −3.
7
What is max(7, 3)? 7 (same as 3 and 7).
−1
What is max(−1, −1)? −1.
It returns the larger of two real numbers a and b, that is max(a, b). For a = 3 and b = 7 the result is 7. One result — not a minimum and not a three-number range.
If a ≥ b, then max(a, b) = a; otherwise max(a, b) = b. When a = b both branches give the same value. On the number line the larger number lies farther to the right.
The midpoint of the segment [a, b] is (a+b)/2, and half the distance is |a−b|/2. Their sum reaches the larger endpoint. When a ≥ b, |a−b| = a−b, so (a+b+a−b)/2 = a. When b > a, |a−b| = b−a and the result is b. This is a classical real-analysis identity.
min(a, b) = (a+b−|a−b|)/2. Also max(a,b)+min(a,b)=a+b and max(a,b)−min(a,b)=|a−b|. The result panel shows the minimum and |a−b| beside the primary maximum.
The result equals a (and also b). |a−b| = 0, so the absolute-value identity returns a as well. Example: 4 and 4 give 4.
No. max is commutative: max(a,b)=max(b,a). Example 7: a = 7, b = 3 also gives 7 — the same as 3 and 7.
Comparison is the usual order on ℝ. −2 and 5 give 5; 0 and −3 give 0; −8 and −3 give −3 (because −3 > −8). Zero is a number, not an empty field.
An empty a or empty b leaves the result blank. The calculator does not substitute the other number for a missing entry.
max(a,b) returns the value (the larger number). argmax would indicate which field wins (a or b), and a tie does not pick a unique index. The panel shows a winner label or a tie, but the primary result is always the max value.
On the minimum and maximum of numbers page (a, b, and optional c). Range from a list lives on the separate range calculator. Here only max of two fields.
Yes. 2.5 and 2,5 are the same number. For a = 2.5 and b = 1 the result is 2.5.
No. The result depends only on a and b. The currency and unit settings in the page header do not affect this result.
Pick the larger of the two numbers, or use max(a, b) = (a + b + |a − b|)/2. For a = 3 and b = 7: (10 + 4)/2 = 7.
5. The positive number lies farther right on the line than −2. That is Example 2 on this page.
−3, because −3 > −8. That is Example 6 on this page.
No. The result is the maximum value, not a field index. On a tie both numbers equal the result.
No. Here only two arguments. Min, max, and range of three numbers and list range live on neighbouring cards.
The definition, |·| identity, and links to min below come from recognized sources.
Page Updated November 2, 2026.