Optimization Problems (\minimize
, \maximize
, \subjectto
)
Macro Code
% ╭──────────────────────────────────────────────╮ % │ Optimization Problems │ % ╰──────────────────────────────────────────────╯ % Requires the amsmath package, which provides % "\DeclareMathOperator" and "\DeclareMathOperator*". % Example usage: % \begin{align*} % \minimize_{x \in \reals^n} \quad & f(x) \\ % \subjectto \quad & Ax \leq 0 \\ % & Bx = 0. % \end{align*} \DeclareMathOperator*{\minimize}{minimize} \DeclareMathOperator*{\maximize}{maximize} \DeclareMathOperator {\subjectto}{subject~to} % Aliases for \maximize and \minimize with British spelling. \let\minimise=\minimize \let\maximise=\maximize
I define \minimize
, \maximize
, and \subjectto
as math operators using the amsmath
package's macros \DeclareMathOperator
and \DeclareMathOperator*
(the resulting macros are equivalent to placing \operatorname*{minimize}
in the body of your document). Defining the macros as math operators ensures that the font matches the roman math font (cf. using \text{minimize}
which will become italicized when used in the body of a theorem), and gives us control over the placement of "limits" on the text, e.g., "\minimize_{x \in \reals}
". In particular, using \DeclareMathOperator*
instead of \DeclareMathOperator
causes subscripts to be placed below the text in display equations, so \[\minimize_{x \in \reals}\]
is rendered as
$$\operatorname*{minimize}_{x \in \reals}$$
instead of
$$\operatorname{minimize}_{x \in \reals}.$$
For inline equations, limits are still placed to the side, e.g., "$\operatorname*{minimize}_{x \in \reals}$".
For \subjectto
, we use a fixed-width nonbreaking space "~
" in \operatorname
to preserve the space in the name, since \operatorname
gobbles regular spaces.
See “Minimize” vs. “Min” in Optimization Problems for discussion of it is better to not use "\min
" when writing optimization problems.
For the Britishly-inclined, I have included aliases \minimise
and \maximise
. Depending on the publication venue, you can change the spelling in the definitions of "minimize" and "maximize", but to enforce consistency, I advise against defining macros that insert different variants of the spelling.
Examples
Code | Output |
---|---|
\begin{align*} \minimize_{x \in \reals^n} \quad & f(x) \\ \subjectto \quad & Ax \leq 0 \\ & Bx = 0. \end{align*} |
$$\begin{align*} \operatorname*{minimize}_{x \in \reals^n} \quad & f(x) \\ \operatorname{subject~to} \quad & Ax \leq 0 \\ & Bx = 0. \end{align*}$$ |