3
$\begingroup$

Why do

2 CenterDot[x,y]
- CenterDot[x,y]

produce output that looks like $2 \, x\cdot y$ for the former but $-(x\cdot y)$ with parentheses for the latter?

Both have FullForm of the form Times[n,Centerdot[x,y]], and normally Times[n,x] does not produce any parentheses when $n$ happens to be $-1$. The parentheses can be suppressed by writing PrecedenceForm[CenterDot[x, y], 490], yet not with PrecedenceForm[CenterDot[x, y], 489]; I do not quite understand why this is the case as Precendence[Times]=400. and Precendence[CenterDot]=410. are both rather lower.

$\endgroup$
1
  • 1
    $\begingroup$ feel free to make the title and tags more precise $\endgroup$ Aug 17, 2018 at 13:26

1 Answer 1

4
$\begingroup$

The problem is that unary minus has higher precedence than CenterDot:

Precedence[Minus]
Precedence[CenterDot]

480.

410.

Without the parentheses, -x \[CenterDot] y would be parsed as CenterDot[-x, y]:

FullForm[- x \[CenterDot] y]

CenterDot[Times[-1,x],y]

So, the parentheses are needed so that the output is equivalent to the input.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.