Textbook
For $f:S\to\mathbb R$, argmax is the set of admissible inputs attaining the largest function value. The set-valued convention applies: it can have one element, several elements, or none.
$$\operatorname*{argmax}_{x\in S}f(x):=\{x\in S\mid\forall z\in S:\ f(x)\ge f(z)\}.$$
For scores $s_1=2$, $s_2=7$, $s_3=4$, the maximum is 7 while $\operatorname*{argmax}_{i\in\{1,2,3\}}s_i=\{2\}$. A value and an index play different roles; argmax does not return the best score.
If $s_3$ also becomes 7, the answer set is $\{2,3\}$. Choosing the first index adds a tie-breaking rule. A single answer written equal to argmax therefore needs a convention; $i^*\in\operatorname*{argmax}_i s_i$ explicitly denotes one chosen member.
For a function without an attained maximum, the set is empty. For example, $f(x)=x$ on $(0,1)$ always allows the larger input $(x+1)/2$. An upper bound alone does not supply a maximizing input.
Checking a candidate $x^*$ requires $f(x^*)\ge f(z)$ for every admissible $z$, rather than comparison with one selected rival. On a nonempty finite domain with real scores, at least one candidate exists: successive comparisons retain the best input examined so far. Adding an admissible input can change the answer even when all previous function values stay unchanged. The domain is part of the optimization problem.
Definitions and notation: Mathematics for Machine Learning.
Related concepts: A function’s maximum: the largest attained value.
In plain language
Argmax resembles the list of winners with the highest score. The largest score is identified first, and every contestant attaining it is retained. A tie leaves several winners, while selecting one index requires a separate rule. Alphabetical order and the earliest index belong to the contest rules; the mathematical symbol does not moonlight as jury chair.
Example
In the constructed scores, the top index is identified, a tie is introduced, and the first index is explicitly selected.
Argmax: the set of maximizing inputs
Initial scores
Scores at three indices are 2, 7, and 4.
Step 1 of 4: Initial scores
Read all steps
Initial scores
Scores at three indices are 2, 7, and 4.
- Indices
- 123
- Scores
- 27current4
One winner
Only index 2 attains 7.
- Indices
- 1excluded2included3excluded
A tie
The third score becomes 7, so the set now contains two indices.
- Scores
- 27included7included
- Argmax
- 2included3included
An additional choice
The “first index” rule returns 2 without changing the mathematical set.
- Set
- 2included3included
- Selected index
- 2current
When the third score becomes 7, index 2 does not get worse; it gains an equally qualified neighbour in the answer. The full set satisfies two conditions: every included index scores 7, and no excluded index scores as much or more. The final step chooses one representative. A program may need that choice, but it does not make the mathematical answer unique.
The interface contract specifies whether the result is a set or a single index and how tied top values are handled.