# Arg max

In mathematics, the arguments of the maxima (abbreviated arg max or argmax) and arguments of the minima (abbreviated arg min or argmin) are the input points at which a function output value is maximized and minimized, respectively. While the arguments are defined over the domain of a function, the output is part of its codomain.

## Definition

Given an arbitrary set $X$, a totally ordered set $Y$, and a function, $f\colon X\to Y$, the $\operatorname {argmax}$ over some subset $S$ of $X$ is defined by
    $\operatorname {argmax} _{S}f:={\underset {x\in S}{\operatorname {arg\,max} }}\,f(x):=\{x\in S~:~f(s)\leq f(x){\text{ for all }}s\in S\}.$
If $S=X$ or $S$ is clear from the context, then $S$ is often left out, as in ${\underset {x}{\operatorname {arg\,max} }}\,f(x):=\{x~:~f(s)\leq f(x){\text{ for all }}s\in X\}.$ In other words, $\operatorname {argmax}$ is the set of points $x$ for which $f(x)$ attains the function's largest value (if it exists). $\operatorname {Argmax}$ may be the empty set, a singleton, or contain multiple elements.
In the fields of convex analysis and variational analysis, a slightly different definition is used in the special case where $Y=[-\infty ,\infty ]=\mathbb {R} \cup \{\pm \infty \}$ are the extended real numbers. In this case, if $f$ is identically equal to $\infty$ on $S$ then $\operatorname {argmax} _{S}f:=\varnothing$ (that is, $\operatorname {argmax} _{S}\infty :=\varnothing$) and otherwise $\operatorname {argmax} _{S}f$ is defined as above, where in this case $\operatorname {argmax} _{S}f$ can also be written as:
    $\operatorname {argmax} _{S}f:=\left\{x\in S~:~f(x)=\sup_{S}f\right\}$
where it is emphasized that this equality involving $\sup_{S}f$ holds only when $f$ is not identically $\infty$ on $S$.

### Arg min

The notion of $\operatorname {argmin}$ (or $\operatorname {arg\,min}$), which stands for argument of the minimum, is defined analogously. For instance,
    ${\underset {x\in S}{\operatorname {arg\,min} }}\,f(x):=\{x\in S~:~f(s)\geq f(x){\text{ for all }}s\in S\}$
are points $x$ for which $f(x)$ attains its smallest value. It is the complementary operator of $\operatorname {arg\,max}$.
In the special case where $Y=[-\infty ,\infty ]=\mathbb {R} \cup \{\pm \infty \}$ are the extended real numbers, if $f$ is identically equal to $-\infty$ on $S$ then $\operatorname {argmin} _{S}f:=\varnothing$ (that is, $\operatorname {argmin} _{S}-\infty :=\varnothing$) and otherwise $\operatorname {argmin} _{S}f$ is defined as above and moreover, in this case (of $f$ not identically equal to $-\infty$) it also satisfies:
    $\operatorname {argmin} _{S}f:=\left\{x\in S~:~f(x)=\inf_{S}f\right\}.$

## Examples and properties

For example, if $f(x)$ is $1-|x|,$ then $f$ attains its maximum value of $1$ only at the point $x=0.$ Thus
    ${\underset {x}{\operatorname {arg\,max} }}\,(1-|x|)=\{0\}.$
The $\operatorname {argmax}$ operator is different from the $\max$ operator. The $\max$ operator, when given the same function, returns the maximum value of the function instead of the point or points that cause that function to reach that value; in other words
    $\max _{x}f(x)$ is the element in $\{f(x)~:~f(s)\leq f(x){\text{ for all }}s\in S\}.$
Like $\operatorname {argmax} ,$ max may be the empty set (in which case the maximum is undefined) or a singleton, but unlike $\operatorname {argmax} ,$ $\operatorname {max}$ may not contain multiple elements: for example, if $f(x)$ is $4x^{2}-x^{4},$ then ${\underset {x}{\operatorname {arg\,max} }}\,\left(4x^{2}-x^{4}\right)=\left\{-{\sqrt {2}},{\sqrt {2}}\right\},$ but ${\underset {x}{\operatorname {max} }}\,\left(4x^{2}-x^{4}\right)=\{4\}$ because the function attains the same value at every element of $\operatorname {argmax} .$
Equivalently, if $M$ is the maximum of $f,$ then the $\operatorname {argmax}$ is the level set of the maximum:
    ${\underset {x}{\operatorname {arg\,max} }}\,f(x)=\{x~:~f(x)=M\}=:f^{-1}(M).$
We can rearrange to give the simple identity
    $f\left({\underset {x}{\operatorname {arg\,max} }}\,f(x)\right)=\max _{x}f(x).$
If the maximum is reached at a single point then this point is often referred to as the $\operatorname {argmax} ,$ and $\operatorname {argmax}$ is considered a point, not a set of points. So, for example,
    ${\underset {x\in \mathbb {R} }{\operatorname {arg\,max} }}\,(x(10-x))=5$
(rather than the singleton set $\{5\}$), since the maximum value of $x(10-x)$ is $25,$ which occurs for $x=5.$ However, in case the maximum is reached at many points, $\operatorname {argmax}$ needs to be considered a set of points.
For example
    ${\underset {x\in [0,4\pi ]}{\operatorname {arg\,max} }}\,\cos(x)=\{0,2\pi ,4\pi \}$
because the maximum value of $\cos x$ is $1,$ which occurs on this interval for $x=0,2\pi$ or $4\pi .$ On the whole real line
    ${\underset {x\in \mathbb {R} }{\operatorname {arg\,max} }}\,\cos(x)=\left\{2k\pi ~:~k\in \mathbb {Z} \right\},$ so an infinite set.
Functions need not in general attain a maximum value, and hence the $\operatorname {argmax}$ is sometimes the empty set; for example, ${\underset {x\in \mathbb {R} }{\operatorname {arg\,max} }}\,x^{3}=\varnothing ,$ since $x^{3}$ is unbounded on the real line. As another example, ${\underset {x\in \mathbb {R} }{\operatorname {arg\,max} }}\,\arctan(x)=\varnothing ,$ although $\arctan$ is bounded by $\pm \pi /2.$ However, by the extreme value theorem, a continuous real-valued function on a closed interval has a maximum, and thus a nonempty $\operatorname {argmax} .$