[Tex/LaTex] Using the underset command in AMS

amsmathbracketsmathtools

I seem to get an error with the following code and I do not know why. This is the first time I have used the \underset_ command whereas I used to use the \limits_ command. However when I tried to use the \limits_ command in the following code it came up with an error. Then I tried the \underset_ command and it says I am missing a } but I can't seem to find it. I think I may just be using the command wrong. If anyone can see what it is, that would be very helpful.

\documentclass[a4paper]{report}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}
\begin{equation}
\underset_{p\neq 0}{\textbf{minimize}}\frac{p^T\nabla f(x_k)}{\| \ {p} \| \cdot \| \ {\nabla f(x_k)} \| }
\end{equation}

Best Answer

The _ after \underset is wrong. On the other hand, you can simplify your input:

\documentclass[a4paper]{report}
\usepackage{amsmath}
\usepackage{mathtools}

\DeclareMathOperator*{\minimize}{\mathbf{minimize}}

\begin{document}

\begin{equation}
\minimize_{p\neq 0} \frac{p^T\nabla f(x_k)}{\|p\| \cdot \|\nabla f(x_k)\|}
\end{equation}

\end{document}

enter image description here

There should be no space between \| and the following term.

Even better, you can define \norm with \DeclarePairedDelimiter (see the manual of mathtools for further information).

\documentclass[a4paper]{report}
\usepackage{amsmath}
\usepackage{mathtools}

\DeclareMathOperator*{\minimize}{\mathbf{minimize}}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}

\begin{document}

\begin{equation}
\minimize_{p\neq 0} \frac{p^T\nabla f(x_k)}{\norm{p} \cdot \norm{\nabla f(x_k)}}
\end{equation}

\end{document}
Related Question