9

From Wikipedia:

In order to reflect normal usage, addition, subtraction, multiplication, and division operators are usually left-associative while an exponentiation operator (if present) is right-associative

For example, we evaluate $2^{2^2}$ as $2^4$ rather than $4^2$. All other operations besides exponentiation, tetration, etc. are inherently left associative. Is there any reason why it's different for exponents?

rb612
  • 3,560
  • 8
    Because $(a^b)^c$ can be better expressed as $a^{bc}$. There is a case that can be made that ${}^ba$ would be a better name for what we call $a^b$. But it is much too late for that! – André Nicolas Feb 26 '16 at 23:07
  • 2
    I'm very familiar with the terms "right associative" and "left associative" in the context of programming. I don't remember what (if anything) they mean in mathematics, but I don't believe either addition or multiplication is "inherently left associative". Those operations are simply associative, that is, you get the same answer whether you start on the right or on the left. – David K Feb 26 '16 at 23:09
  • 1
    If you're going to cite Wikipedia, please provide a link to the article. But I found your quoted text anyway, and the first paragraph of the body of that page starts with the words, "In programming languages". Just above that are the words, "For the mathematical concept of associativity, see Associative property." This is MSE, not stackoverflow, so you're on the wrong page of Wikipedia. – David K Feb 26 '16 at 23:15
  • 2
    All twos is a bad example, since he value is the same either way... – Thomas Andrews Feb 26 '16 at 23:16
  • This all makes a lot of sense. Is there an intuitive explanation for why $(a^b)^c = a ^ (bc)$? – rb612 Feb 26 '16 at 23:20
  • 1
    @DavidK: this is an issue for mathematics not just computer science: subtraction isn't associative. Traditional mathematical notation for subtraction treats it as left-assocative: $1 - 2 - 3$ is $ (1 - 2) - 3 = -4$ not $1 - (2 - 3) = 2$. – Rob Arthan Feb 26 '16 at 23:27
  • 1
    @RobArthan Looks like I owe OP an apology after all: the Wikipedia page on mathematical associativity uses the term "left-associative" for the conventional order of operation of subtraction. So OP did not just make this up. – David K Feb 26 '16 at 23:36

1 Answers1

11

As André Nicolas writes, it is because $$ (a^b)^c = \underbrace{(a^b) \cdot (a^b) \cdots (a^b)}_{c\text{-times}} = a^{b \cdot c} \text{,} $$ so there is no need to use iterated exponentiation to represent that idea.

Additionally, consider the evaluation tree for the expression "a^b^c". It is "^(a, ^(b,c))" because, by order of operations, we evaluate the exponent first.

Finally, addition and multiplication are commutative and associative, so it does not matter in what order they are applied. Claiming that subtraction is left associative may be incomplete, depending on how you define subtraction. If subtraction is not adding the additive inverse, then it does not acquire commutativity and associativity $$\begin{align*} a - b - c &= (a-b)-c \neq a-(b-c) \\ &= a-(b+c) \\ &= a+ (-b) + (-c). \end{align*}$$ The same thing happens for division: $$\begin{align*} a / b / c &= (a/b)/c \neq a/(b/c) \\ &= a/(b \times c) \\ &= a(b^{-1})(c^{-1}). \end{align*}$$ (It is, perhaps, instructive to realize I just wrote the same display twice.) If we define subtraction and division as in the third lines of the two displays, then these operations are just as associative and commutative as addition and multiplication.

Is there any hope of doing the same thing with exponentiation? The above come in inverse pairs. Perhaps we should look at logarithms. But neither $ \log_a b = \log_b a$ nor $a^b = b^a$, so we don't have an associative and commutative member of the pair to write both operations in terms of. This is a commutative variation, $a^{\ln b} = \mathrm{e}^{(\ln a) (\ln b)} = b^{\ln a}$, but I can't say this is a common operation or that others would recognize it as rapidly as the six operations discussed so far. (This idea can be generalized to make commutative variants of tetration and higher operations.)

Eric Towers
  • 67,037
  • To put it very simply, if $f(x)$ is a function, then evaluating $a^{f(x)}$ requires evaluating $f(x)$ first, then calculating $a$ raised to that power. So with $3^{3^3}$, $3^3=27$ is evaluated first, then evaluate $3^{27}$ – Michael Ejercito Feb 05 '24 at 07:03