What is the order of operations in expressions like $-x^2$? For example, Google returns $-3^2 = -9$, but Excel returns $-3^2 = 9$.
Furthermore, is $-x! = -(x!)$ or $-x! = (-x)!$ ?
What is the order of operations in expressions like $-x^2$? For example, Google returns $-3^2 = -9$, but Excel returns $-3^2 = 9$.
Furthermore, is $-x! = -(x!)$ or $-x! = (-x)!$ ?
On
Without brackets: $-3^2=-9$ first square and then multiply by $-1$, with brackets $(-3)^2=9$ is the same as $(-3)\cdot (-3)=9$. For the factorial $-x!=-(x!)$.
On
I would put a lot more stock into what Wolfram Alpha says. According to Wolfram Alpha, $-3^2 = -9$. Which makes it the same as $0 - 3^2$.
Likewise for factorials, Wolfram Alpha says $-3! = -6$, making it consistent with $0 - 6!$ (remember "PFEMDAS").
Regardless of that, if you think your expression could be misunderstood, just add parentheses to make what you mean perfectly clear.
In the absence of brackets, Excel is parsing left to right, while Google correctly processes the expression according to standard operator precedence. Since exponentiation has higher precedence than unary negation (subtracting from a tacit $0$), it should be processed first, hence giving $9$ as an intermediate result. Then do the unary negation, giving $-9$.