LatexNotes

Argmax and argmin in LaTeX

argmax is the input at which a function reaches its maximum; in LaTeX \operatorname*{arg\,max}_{x} sets it as an upright operator with the subscript underneath, like \max.

LaTeX command

\operatorname*{arg\,max}_{x} f(x)

Not the symbol you meant? Draw it to find the command →

Typing up handwritten notes? Convert a whole page of handwriting to LaTeX →

LaTeX has \max and \min but no \argmax, so typing argmax gives six italic letters that read as a product. \operatorname*{arg\,max} makes a proper operator: upright, spaced like \max, and, because of the star, with its subscript placed underneath in a displayed equation. The \, adds a thin space between arg and max; leave it out for argmax written as one word.

In running text, as with \sum, the subscript sits beside the operator to keep the line short. To force it underneath there too, write \limits straight after the operator, or use \displaystyle for the whole formula.

The quick form \arg\max_{x} also works, but the subscript then sits under max alone, slightly off centre. If argmax appears more than once, define it in the preamble with \DeclareMathOperator* and write \argmax from then on.

Define \argmax and \argmin once

Put these lines in the preamble, with amsmath loaded, and \argmax_{x} f(x) works everywhere in the document. The star is what puts the subscript underneath; without it the subscript sits to the side even in display.

\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}

Other forms

\operatorname*{arg\,min}_{x} f(x)argmin
\DeclareMathOperator*{\argmax}{arg\,max}define \argmax once, in the preamble
\arg\max_{x}quick form; the subscript sits under max only

Examples

$$\operatorname*{arg\,max}_{x \in S} f(x)$$

displayed, with the subscript underneath

$\hat{\theta} = \operatorname*{arg\,max}_{\theta} \, L(\theta)$

a maximum likelihood estimate

$w^{*} = \operatorname*{arg\,min}_{w} \sum_{i} (y_i - w^{\top} x_i)^2$

least squares as an argmin

$\operatorname*{arg\,max}\limits_{k} p_k$

\limits keeps the subscript underneath inline

Tips and common mistakes

Working from handwritten notes?

LatexNotes turns a photo or PDF of handwritten mathematics into LaTeX, graphs and all. It is built with real pdflatex before you see it, and the .tex file is yours to edit or take to Overleaf. Free to try, no sign-up.

See how handwriting to LaTeX works, step by step, or go from GoodNotes to LaTeX if you write on an iPad (Notability works the same way).

Convert your maths to LaTeX →

FAQ

How do I write argmax in LaTeX?

Use \operatorname*{arg\,max}_{x} f(x), which sets argmax upright with x underneath in a displayed equation.

How do I put the subscript below argmax?

Use the starred \operatorname*. In running text add \limits after it, or use \displaystyle, to keep the subscript underneath.

Is there an \argmax command?

Not by default. Define one with \DeclareMathOperator*{\argmax}{arg\,max} in the preamble (amsmath), and the same for \argmin.

Why does my argmax look italic?

It was typed as letters. Plain letters in maths are variables; \operatorname* makes it an upright operator.

See also