# What is the order when doing $x^{y^z}$ and why?

Does $x^{y^z}$ equal $x^{(y^z)}$? If so, why?

Why not simply apply the order of the operation from left to right? Meaning $x^{y^z}$ equals $(x^y)^z$?

I always get confused with this and I don't understand the underlying rule. Any help would be appreciated!

• The most important thing to realize is $(x^y)^z \ne x^{(y^z)}$ (just try some values. I actually didn't realize there was a convention that $x^{y^z}$ was defined to be $x^{(y^z)}$ but it makes sense. $(x^y)^z = x^{yz}$ so we don't need another way to express that but $x^{(y^z)}$ doesn't equal anything simpler. It's a little like "why" $a*b + c = (a*b) + c$ and not $a*(b + c)$. It could have equalled $a*(b + c)$ because we have a distributive law $a*(b + c) = (a*b) + (a*c)$ so the need to express $(a*b) + (a*c)$ simply as $ab + ac$ seemed more ...to be continued ... – fleablood Jan 30 '16 at 23:39
• ... cont. ... It could have equalled $a*(b + c)$ because we have a distributive law $a*(b + c) = (a*b) + (a*c)$ so the need to express $(a*b) + (a*c)$ simply as $ab + ac$ seemed more necessary then the need to express $a*(b + c)$ as $a*b + c$. In any event, if clarity matters just put in the parenthesis. – fleablood Jan 30 '16 at 23:41
• It's just one of those conventions that people have adopted. This one saves on brackets as we can write $a^{b c}$ for $(a^b)^c$, and $a^{b^c}$ for $a^{(b^c)}$ – DanielWainfleet Jan 31 '16 at 1:48
• One possible motivation I think for the convention is that $\exp \exp x$ can only reasonably be interpreted as $\exp ( \exp x)$ (where $\exp x$ is a common notation for the ubiquitous $e^x$). Choosing $x^{(y^z)}$ over $(x^y)^z$ would keep to that. – Vandermonde Feb 1 '16 at 0:43
• Possible duplicate of Can anyone explain why $a^{b^c} = a^{(b^c)} \neq (a^b)^c = a^{(bc)}$ – anderstood Dec 1 '16 at 4:26

In the usual computer science jargon, exponentiation in mathematics is right-associative, which means that $x^{y^z}$ should be read as $x^{(y^z)}$, not $(x^y)^z$. In expositions of the BODMAS rules that are careful enough to address this question, the rule is to evaluate the top exponent first. One way to help remember this convention is to note that $(x^y)^z = x^{yz}$ (i.e., $x^{(yz)}$), so it would be silly if out of the two possibilities, $x^{y^z}$ meant the one that can be expressed without using two tiers of superscripts.

• Nice KIS(S) mnemotecnic! – JnxF Jan 30 '16 at 23:24
• Though, $x^{y^z}$ isn't ambiguous at all... it's just the version without formatting ($x^y^z$) that needs a rule about which operation to apply first. (I notice that MathJax actually treats that construction as ambiguous.) – Brilliand Jan 31 '16 at 4:05
• MathJax is presumably imitating $\TeX$'s double subscript error. $x^{{\mbox{$y$}}^{\mbox{$z$}}}$ is ambiguous if you and your typesetter haven't conspired to make the superscripts shrink. – Rob Arthan Jan 31 '16 at 11:09
• In CS, it's not exponentiation that is usually right-associative, but the ^ operator, which gives a unique way to interpret x^y^z (I say "usually" because not every language uses the same associativity rules for ^). Written math notation uses relative position and size to determine what is being exponentiated to what. In $x^{y^z}$ we can see that $z$ is smaller than $y$, and thus is not the exponent to $x$, but rather to $y$. In $(x^y)^z$, the $y$ and $z$ are the same size. Associativity is for 1D strings, not 2D layouts. – Kyle Miller Oct 24 '16 at 1:00
• @Anand: my answer is not about programming language conventions, but about mathematical practice. Your observation that $x^{y^z}$ is undefined is nonsense. – Rob Arthan Jul 30 '17 at 0:27

Usually, a^b^c is taken to mean a^(b^c). This is purely an issue of the definition of notation so deep "why" answers aren't super likely. The main thing is that we have the identity (for positive $a$): $$(a^b)^c=a^{bc}$$ so it would make little sense to make that the default order, given that it reduces to a simpler form, whereas $a^{(b^c)}$ doesn't reduce. Moreover, generally exponentiation is written as $a^{b^c}$ rather than a^b^c, and the former notation more clearly shows that all of $b^c$ is in the exponent.

• Not usually. Always. – user207421 Jan 31 '16 at 23:46
• @EJP Not in situations where you're limited to ASCII and have little to no typesetting capabilities (or it is a great deal of trouble to get around these limitations), a situation that you might find surprisingly common outside of tools specifically designed for math. – jpmc26 Feb 1 '16 at 8:24

I would just like to point out that many calculators share the OP's confusion, even calculators from the same manufacturer. Taking a quick sample from the lost-and-found box in my office, I found that 2^3^4 turned out to be:

• 4096 on Texas Instruments BA II Plus, TI-30XA, TI-30X II s, TI-36X solar, Windows calculator
• 2.4178...*10^24 on Texas Instruments TI-30XS MultiView, Casio fx-115ES Plus, Google search bar.
• No BS here, excellent use of time! +1 – Kevin Feb 3 '16 at 14:36

The notation helps here; the exponent (which is the part that's raised) always acts like it has parentheses around it. So $x^{y^z}$ means $x^{(y^z)}$. Similarly, $x^{y+z}$ means $x^{(y+z)}$ and $x^{yz}$ means $x^{(yz)}$, even though exponentiation has higher precedence than addition or multiplication (so $x+y^z$ means $x+(y^z)$ and $xy^z$ means $x(y^z)$).

• This is addressing a programming language convention, and not the math question. See my comment – Anand Jul 29 '17 at 14:51
• @Anand - no math text I have ever seen insists on, or even puts, parentheses around an actual exponent ($x^y$) when the exponent is actually typeset as superscripted text. See Brilliand's comment on the other question. I literally have no idea why you think $x^{y+x}$ needs parentheses; I've never seen $x^{(x+y)}$ anywhere in a math book or paper. – Jonathan Cast Jul 30 '17 at 12:55
• I did not say that. Please reread my other comment. – Anand Jul 30 '17 at 16:30

Without a convention, $x^{y^z}$ might be interpreted as either $(x^y)^z$ or $x^{(y^z)}$; so a convention is useful. If the convention meant the first, then we would be obliged to use parentheses whenever we intend the second. On the other hand, if the convention means the second (which it does), then there is no need to write parentheses for the first, because it can anyway be written more simply as $x^{yz}$. The convention predates computer code, and was adopted to save writing lots of parentheses.

The exponent is evaluated first if it is an expression. Examples are $3^{x+1}=3^{\left(x+1\right)}$ and $e^{5x^3+8x^2+5x+10}$ (the exponent is a cubic polynomial) and $10^{0+0+0+10^{15}+0+0+0}=10^{10^{15}}$. The left-associativity simply fails when the exponent contains multiple terms.