1

The equation $\max - \log x$ renders in a weird way:

equation

The minus is a unary operator (i.e. it means "negative logarithm", and not "the difference between max and log"). So I would expect that it would be closer to "log". That happens for $-b$ as opposed to $a-b$:

enter image description here

Is there a better way than $-\log x$ to write the negative logarithm?

root
  • 418
  • 6
    I'd use \max(-\log x) – egreg Jun 03 '18 at 19:50
  • What if I don't want to write the parentheses? I'm concerned about the spacing in $\max -\log x$ as opposed to $\max -b$. – root Jun 03 '18 at 19:54
  • I consider very ambiguous even \max\log x, because there's no binding of the variable. I can suggest \max-{\log x}, – egreg Jun 03 '18 at 19:59
  • It's actually \max\{\log x:x>0\} (or whatever interval you compute the maximum over. – egreg Jun 03 '18 at 20:02
  • What about \max{}-\log x? I dislike, but... – Sigur Jun 03 '18 at 20:04
  • I'm equally concerned about the spacing of the minus in $$\max_{x\in X} -\log x$$. @egreg is that what you mean by binding? – root Jun 03 '18 at 20:08
  • @Sigur that renders in the same way – root Jun 03 '18 at 20:09
  • @root, are you sure? Try \[ \max-\log x \]\[ \max{}-\log x \]. https://imgur.com/a/1MCHvT7 – Sigur Jun 03 '18 at 20:13
  • @Sigur in the Online LaTeX Equation Editor, it looks the same http://latex.codecogs.com/gif.latex?%5Cmax-%5Clog%20x http://latex.codecogs.com/gif.latex?%5Cmax%7B%7D-%5Clog%20x – root Jun 03 '18 at 22:58

2 Answers2

4

As @egreg pointed out in the comments, to avoid ambiguity a pair of parentheses is recommended. Or maybe you could try $\max_{x\ge2} -{\log x}$ instead of the full expression $\max\{ \, -{\log x} : x\ge2 \, \}$.

You mentioned you wanted a unary negation, so you have to use $-{\log x}$, and even $-\log x$ is incorrect.

In the $-\log x$ example, \log is of class \mathop, and the minus sign (which is not a binary operation here) will be rendered as an ordinary object (class \mathord - see this answer to learn about math classes). And so a thin space \, is added between them (because a thin space is always inserted between \mathord and \mathop - see this answer - think $\sin x\cos x$ for example).

Therefore, to truly get unary negation, you must make sure whatever you are negating is itself an ordinary object. This can be done by simply enclosing \log x within a pair of {}. Same idea applies to $-{\sin x}$, $\tan x = {\sin x}/{\cos x}$, etc.

Ruixi Zhang
  • 9,553
  • Thanks! What's ambiguous about $\max\log x$ without parentheses, what else can it mean apart from $\max(\log x)$? Why does $-\log$ create an "impossible" combination, where is it explained that $- cannot be followed by a \mathop? – root Jun 03 '18 at 22:55
  • 1
    @root A - in math mode is classified as \mathbin by default. “Impossible” means “it is impossible to start math mode with a \mathbin”, hence the \mathord adjustment. A \mathop can follow a \mathord—see my mentioned example. You can check this answer to learn about math classes, and this answer for the spacing rules. – Ruixi Zhang Jun 03 '18 at 23:38
  • @root done! :) – Ruixi Zhang Aug 05 '19 at 17:04
  • Thanks :) In the $-\log x$ example and the $\max-\log x$ example – root Aug 05 '19 at 21:22
  • 1
    @root not quite. In $\max-\log x$, the minus sign is a perfectly normal binary, the atoms in this math list are mathop mathbin mathop mathord. – Ruixi Zhang Aug 06 '19 at 23:50
4

A double pair of braces will do the trick. However, I also prefer to add a pair of parentheses:

\documentclas{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools}

\begin{document}

    \begin{align*}
     & \smashoperator{\max_{1 < x < \mathrm e}}{-}{\log x}\\
 & \smashoperator{\max_{1 < x < \mathrm e}} ({-}{\log x})
    \end{align*}%

\end{document}

enter image description here

Bernard
  • 271,350