# Exponent of an exponent?

If I have an expression that gives 2^3^4, would I compute this as $(2^3)^4$ or as $2^{(3^4)}$? The two answers are wildly different.

My TI gives the former but Wolfram gives the latter and I don't know which to trust more on math. I also tried reading up in textbooks on the Laws of Exponents, but I could not find the case A^B^C in any of the textbooks I can access...

EDIT: This was found as an example in a CompSci textbook, thus the notation as it was.

• en.wikipedia.org/wiki/Operator_associativity says : an exponentiation operator (if present) is right-associative – lab bhattacharjee Sep 1 '15 at 16:16
• – JuliusL33t Sep 1 '15 at 16:16
• Generally, we don't write $2\hat{\phantom:}3\hat{\phantom:}4$. We write $2^{3^4}$. And that means $2^{(3^4)}$ unambiguously. – Akiva Weinberger Sep 1 '15 at 18:54

Conventionally $a^{b^c}$ means $a^{(b^c)}$.

The other way of parsing it, $(a^b)^c$, yields a result equal to $a^{bc}$. In particular $(2^3)^4 = 2^{3\times 4} = 2^{12} = 4096$.

• Thank you, I actually had written it the way I did, though, because that was how it had been presented to me in my programming textbook. I was pretty sure it was the conventional format, but couldn't find precedent. – Falconic Katadora Sep 1 '15 at 18:02
• If it's in a programming language, you need to find out whether the ^ operator in that language is left-associative (x^y^z = (x^y)^z) or right-associative (x^y^z = x^(y^z)). Math doesn't use ^ as the exponentiation operator. – Joe Sep 2 '15 at 6:57
• Funny that this answer is the accepted one when it actually doesn't answer the question, which is about a^b^c. – Yves Daoust Sep 2 '15 at 9:39

There are a number of type-setting situations with algebraic expressions that cause problems when you try to enter them into a one-line input calculator.

For example $$\frac{2+3}{4+5}$$must be entered into a calculator as $$(2+3)/(4+5)$$The horizontal line in the fraction implies brackets around the expression in the numerator and denominator.

Similarly, the expression$$\sqrt{2+5}$$must be entered on my Casio as$$\sqrt{}(2+5)$$Here the horizontal line above the expression shows what expression is to be included in the root; the brackets in the second version do the same thing for the calculator.

Finally, if an exponent is itself an expression, that typesetting defines exactly what is in the exponent; if you can't enter the typesetting directly, you need to supply the missing information.$$2^{3^4}$$should be entered into a calculator as $$\text{2 ^ ( 3 ^ 4 )}$$

Note that when you enter 2 ^ 3 ^ 4 into Wolfram Alpha, it back translates the expression into the typeset version and then evaluates that expression correctly

In standard mathematics the notation $A \mathrel{^\wedge} B$ is not used; one does $A^B$ instead.

In some computer science (programming) applications the infix circumflex operator notation $A \mathrel{^\wedge} B$ is used (or rather the ASCII version A^B). What you point out is that this operator $\mathrel{^\wedge}$ is not associative.

So does $A \mathrel{^\wedge} B \mathrel{^\wedge} C$ mean $A \mathrel{^\wedge} (B \mathrel{^\wedge} C)$ (that is $A^{B^C}$) or $(A \mathrel{^\wedge} B) \mathrel{^\wedge} C$ (which is $(A^B)^C$)? Well, that depends on the language! For example in PARI/GP and Wolfram Alpha it would be the former, while in Visual Basic .NET and some calculators it would be the latter.

So if you are writing a computer program, find out what convention the programming language in question uses. If you are writing for a human reader, avoid $A \mathrel{^\wedge} B \mathrel{^\wedge} C$ without parenthesis because it can be ambiguous.

For similar reasons, avoid $A/B/C$ and use either $A/(B/C)$ or $(A/B)/C$. Of course, whenever it is technically possible, use "real" mathematical notation like $\frac{A}{\frac{B}{C}}$ or $\frac{\frac{A}{B}}{C}$.

PS! Out of curiosity, was the textbook using a particular programming language?

Addition: In the Java programming language, A^B is not exponentiation but instead bitwise exclusive OR (bitwise XOR). See What does the ^ operator do in Java? Since this operation is associative, A^(B^C) == (A^B)^C for XOR, there will usually not be an issue here.

• Java, it's for my Data Structures class. My professor is flabbergasted as well. – Falconic Katadora Sep 2 '15 at 1:31
• @FalconicKatadora Java?! But Java uses ^ for another purpose, so your question is not really relevant there. See updated answer above. – Jeppe Stig Nielsen Sep 2 '15 at 9:27
• It's in the textbook, not in a code snippet though. – Falconic Katadora Sep 2 '15 at 11:57
• @FalconicKatadora What is the context in the book? Why would they use ^ notation for exponentiation in a textbook on Java? – Jeppe Stig Nielsen Sep 2 '15 at 12:14
• It is in reference to infix/polish/RPN. Other than that I have no clue as to why this author would do such... This author has been known to make really odd choices in his code too though. – Falconic Katadora Sep 3 '15 at 12:56