6

Should I be using parentheses when using things like $\log$ in LaTeX, and when handwriting?

Should I use $\log x$ or $\log(x)$?

If it's just one value or variable, I can see getting away with not using parentheses, but suppose I have a function in there:

$$ \log p(w|v) \; \text{or} \; \log( p(w|v) ) \; ? $$

Same question applies to things like $\sin$, $\arctan$, $\ln$, etc.

amWhy
  • 209,954
polemon
  • 1,041
  • 5
    I prefer $\log x$; $\log p(w\mid v)$ is also unambiguous. On the other hand, one certainly needs parentheses for $\log(x+5)$. The same goes for all the rest. – Brian M. Scott Oct 29 '13 at 16:19
  • writing $ \log x $ in latex is actually faster but as @BrianM.Scott said On the other hand, one certainly needs parentheses for log(x+5). The same goes for all the rest. – what'sup Oct 29 '13 at 16:21
  • 2
    If it causes no ambiguity, I apply Tufte's 'maximize data-ink ratio' rule. So, in the above case, I would use $\log x$. Your other example is unambiguous, so the parentheses are unnecessary. – copper.hat Oct 29 '13 at 16:22
  • A rule of thumb for special function names (trig functions both hyperbolic and ordinary, $\log$, $\exp$, …) is that their precedence is between multiplication and addition; moreover, you should generally use parentheses only when required. So $\cos{2x}$ or $\cos{(x+5)}$. – mjqxxxx Oct 29 '13 at 16:31
  • That being said, $\cos x^2$ is fairly ambiguous. – mjqxxxx Oct 29 '13 at 16:32
  • @mjqxxxx I noticed you used a space between $\cos$ and the adjacent parentheses: $\cos , (x+5)$. Do you always use this space for function-like operators (what's the rule (of thumb))? $\cos x^2$, hmm, due to PEMDAS, I'd say it's unambiguous: $\cos x^2 = \cos , (x^2)$ The other thing is: $\cos^2 x = (\cos x)^2$ – polemon Oct 31 '13 at 03:27

3 Answers3

7

If $f$ was a function and $x$ its argument: who in the mathematician's world would write $f\,x$ instead of $f(x)$? So the question really is: “What is the reason to omit the argument's brackets in some cases?” (And how to remember these exceptions? It's sort of remembering the list of all irregular verbs.) Besides of overcame traditional unprogressive reasons every teacher among us will agree that maximizing the data-ink ratio will as well minimize the readability, hence the grasping of what is written.

In case you're a teacher you should always put brackets around a function's argument, just for the sake of consistency. In case you're not: correct your habit to avoid ambiguous expressions: Don't spare (digital) ink, write out your thoughts as clearly as possible!

Michael Hoppe
  • 18,103
  • 3
  • 32
  • 49
  • 2
    Actually, $fx$ (but not $f \ x$) is often used in various settings. Linear algebra and formal logic, for example. –  Oct 29 '13 at 19:09
  • 1
    In the context of Linear Algebra you omit a “\cdot” because if $A$ is a linear map we define $A(p):=A\cdot p$. About $f,x$ and $fx$ consider the difference between $\cos x$ and $\mathrm{cos}x$. – Michael Hoppe Oct 29 '13 at 20:00
  • As I understand it, $\log$ and $\sin$ etc, are /function-like operators/, as Larry Wall would call them, no doubt. I can see why they're treated differently, but for formal reasons, I asked this question. – polemon Oct 29 '13 at 21:17
  • 1
    To make things clearer: let $L\colon V\to W$ a linear map between finite dimensional vector spaces and $p\in V$. The image of $p$ under $L$ is $L(p)$. As we know $L$ can be represented by a matrix $A$ in the sense that $L(p)=Ap$. – Michael Hoppe Oct 30 '13 at 09:53
1

I treat $\log$ similarly to the trigonometric functions, so I would write $\sin x$ but I would write $\sin(x+k\pi)$ when the expression would be ambiguous without the parentheses.

So similarly, $\log x$, $\log f(x)$ and $\log\dfrac{1-x}{x}$ but $\log (1-x)$ and $\log(f(x)+g(x))$.

Dan Rust
  • 30,108
  • I kinda see it the same way, but I asked for formal reasons. Also, since things like $\log$ and $\sin$ are more like function-like operators, should there be a space between the function/operator and the argument in parentheses? $\log , (a+b)$ or $\log(a+b)$ There has to be a space between the function and the argument if there are no parentheses for obvious reasons... – polemon Oct 29 '13 at 21:20
0

See the answer here: https://math.stackexchange.com/a/212201/88378

If it's not ambiguous, omitting parentheses can help readability.

$\log$ and $\sin$ are different from $f$ and $g$. The latter could denote a scalar for example, and putting $()$ after them makes it clear that they're functions. $\log$, $\sin$, etc are universally accepted to denote specific functions, so parentheses aren't necessary to clarify that.

DirkGently
  • 1,618