[Math] Why does unary minus operator sometimes take precedence over exponentiation, and sometimes not

notationsoft-question

How should I evaluate 2*-2^3?

Which one of these two is the correct one?

2*((-2)^3)
2*(-(2^3))

I was wondering what was the correct operator precedence. Everyone was taught at school to evaluate expressions this way:

  1. First exponentiation and roots
  2. Then multiplications and divisions
  3. Finally additions and subtractions

However, for more complex operations, this table is incomplete. For instance, which precedence do unary operators have regarding to the others?

On the one hand, we can see that unary operators have lower precedence than the exponentiation in many cases.

-2^2 = –(2^2) = -4 (exponentiation first)

On the other hand, we sometimes use it differently (unary operators take precedence over exponentiation):

2^-2 = 2^(-2) = 1/4 = 0.25 (unary minus first)

I am a bit confused about this, so these are my questions:

  1. Which would be the general correct rule for this kind of operations? I know this ambiguous problem can easily be solved putting brackets around the unary operators (but many programming languages perform those operations without needing them). Because of this, I think there should be a rule or an international standard.

  2. How should I evaluate the following expressions?

    2*-2^3 <– the most important
    2^-3*4
    2*-3*4
    -2^-3

In order to research how modern calculators behave, I have tested 2^-3*4 in many different calculators and each one gives me a different result:

 - Google                    2^-3*4 = (2^(-3))*4 = 0.5

 - http://web2.0calc.com/    2^-3*4 = 2^(-(3*4)) ~ 0.000244140625

Best Answer

Not everyone was taught what you say. I was not, for example. I was never taught how to write expressions with exponents in-line, so I never found out what the canonic meaning of x^a+b actually is.

What I was taught is that whenever there is some confusion and there may exist two ways of interpreting an expression, I should use parentheses. And that is exactly what you need to start doing.

The thing is that by now, the notation has become so widely used with no central rule telling us what the only proper way of evaluation is, that it no longer makes much sense to try to impose a world-wide standard.


Taking this into consideration, the answers are:

  1. There is no general correct rule for this kind of operation. Brackets are the way to go. There is no international standart.
  2. The following expressions should be evaluated as "input unclear". If you get an expression like that to evaluate, ask the author of the expression to further explain what they meant.