Sub topic 14
Stacked exponents: 2^3^2
This chapter assumes you can evaluate a single power such as 2^3, that you know the precedence levels from the earlier chapters (grouping, exponents, multiplication and division, addition and subtraction), and that you can read basic Python.
The problem: two ways to read 2^3^2
An expression with one exponent has one meaning. When one exponent sits on top of another, the plain text 2^3^2 can be grouped in two ways.
- Left first: (2^3)^2 = 8^2 = 64.
- Top first: 2^(3^2) = 2^9 = 512.
The two answers differ by a factor of 8, so a convention is needed. The standard convention in mathematics is to evaluate stacked exponents from the top down, which means from right to left in a line of text. So 2^3^2 means 2^(3^2) = 512.
This is an exception to the rule you learned for multiplication, division, addition, and subtraction, where equal-rank operations go left to right. Exponentiation is the one common operation that groups to the right.
How it looks when written by hand
When written with superscripts, the layout makes the order visible. In a tower, 2 is the base, 3 is raised to the power 2, and that whole upper part is the exponent of 2. You work on the highest level first, because it has to be a single number before it can serve as an exponent.
Evaluate 2^3^2 step by step:
- Find the topmost exponent group: 3^2 = 9.
- Replace it: the expression becomes 2^9.
- Evaluate: 2^9 = 512.
The same idea works for longer towers. For 2^2^2^2, work from the top:
- 2^2 = 4 (the top pair), giving 2^2^4.
- 2^4 = 16, giving 2^16.
- 2^16 = 65536.
Reading the same tower left to right would give ((2^2)^2)^2 = 256, which is a very different number.
Why the right-to-left rule makes sense
Grouping from the left is already covered by another rule. For any positive whole number exponents, repeated powers combine by multiplying the exponents:
(a^b)^c = a^(b × c)
So (2^3)^2 = 2^(3 × 2) = 2^6 = 64. If a bare a^b^c also meant (a^b)^c, it would just duplicate a^(b × c), and there would be no short way to write "a to the power b^c". The top-down reading gives the tower its own meaning. That is the usual justification given for the convention.
This also matches how you read the notation on paper. The small raised numbers describe what the exponent is, and the exponent is the whole raised expression.
Checking with Python
Python's ** operator follows the same convention, so it is a good way to check a hand calculation.
print(2 ** 3 ** 2) # 512: evaluated as 2 ** (3 ** 2)
print((2 ** 3) ** 2) # 64: parentheses force the left grouping
print(2 ** (3 ** 2)) # 512: the explicit form of the first line
print(2 ** 2 ** 2 ** 2) # 65536: 2 ** (2 ** (2 ** 2))
print(2 ** (3 * 2)) # 64: equals (2 ** 3) ** 2You can also write a small function that evaluates a tower from the top down, which makes the order explicit.
from functools import reduce
def tower(*levels):
"""Evaluate a^b^c^... from the top down."""
return reduce(lambda exponent, base: base ** exponent, reversed(levels))
print(tower(2, 3, 2)) # 512
print(tower(2, 2, 2, 2)) # 65536
print(tower(2, 3)) # 8The function starts with the topmost number and wraps each lower number around it as a base, which mirrors the hand method.
Mixing towers with other operations
A tower is still an exponent, so it is finished before multiplication, division, addition, or subtraction. Resolve the tower first, then apply the rest of the order.
Evaluate 2 × 3^2^2 + 1:
- Tower first, from the top: 2^2 = 4, so 3^2^2 = 3^4 = 81.
- Multiplication: 2 × 81 = 162.
- Addition: 162 + 1 = 163.
A minus sign in front of a tower follows the rule from the chapter on negative bases. The exponent work happens first, then the sign is applied. So −2^2^2 = −(2^4) = −16.
A negative number inside the tower changes the exponent. For 2^(−2) the exponent is −2, which means the reciprocal: 2^(−2) = 1/2^2 = 1/4 = 0.25. When the negative sign belongs to the exponent, evaluate the exponent first and then take the reciprocal.
Towers with fractions
A fraction base follows the same top-down rule. Evaluate (1/2)^3^2:
- Top exponent: 3^2 = 9.
- Power of the fraction: (1/2)^9 = 1^9 / 2^9 = 1/512.
The left-first reading gives ((1/2)^3)^2 = (1/8)^2 = 1/64. You can confirm the first with exact arithmetic:
from fractions import Fraction
print(Fraction(1, 2) ** 3 ** 2) # 1/512: (1/2) ** (3 ** 2)
print((Fraction(1, 2) ** 3) ** 2) # 1/64: the left-first readingA trap: when both readings agree
Sometimes the two readings give the same answer, which can hide a mistake. For 3^2^2:
- Top first: 3^(2^2) = 3^4 = 81.
- Left first: (3^2)^2 = 9^2 = 81.
They match because the top-down value of the upper part is 2^2 = 4, and the left-first rule multiplies the exponents, 2 × 2 = 4. The two readings agree exactly when b^c = b × c, and for whole numbers greater than 1 that happens only at b = c = 2. Do not test your understanding of towers using only towers of 2s on top.
| Expression | Top first (standard) | Left first | Same? |
|---|---|---|---|
| 2^3^2 | 2^9 = 512 | 8^2 = 64 | No |
| 2^2^3 | 2^8 = 256 | 4^3 = 64 | No |
| 3^2^2 | 3^4 = 81 | 9^2 = 81 | Yes |
| 2^2^2^2 | 2^16 = 65536 | 256 | No |
Common mistakes
- Evaluating left to right because every other equal-rank rule does. Exponents are the exception.
- Multiplying the exponents, as in 2^3^2 = 2^6. That rule applies only to (2^3)^2.
- Treating 2^3^2 as 2^3 × 2^2. That is a different expression, with value 8 × 4 = 32.
- Testing with 3^2^2 or 2^2^2 only, where the wrong reading accidentally gives the right answer.
Summary
Stacked exponents group from the top down: a^b^c = a^(b^c). Resolve the highest exponent first, replace it with its value, and repeat. The left-first form (a^b)^c is a separate expression that equals a^(b × c) and needs explicit parentheses. When in doubt, check with Python's ** or add parentheses.
Exercise
Evaluate 2^2^3 by hand, and then evaluate (2^2)^3. Which one is the standard meaning of 2^2^3, and why are the two values different?
Show answer
The standard meaning is top down: 2^2^3 = 2^(2^3) = 2^8 = 256. The other expression is (2^2)^3 = 4^3 = 64, which also equals 2^(2 × 3) = 2^6. The values differ because the exponent in the first is the whole value 2^3 = 8, while in the second the exponents are multiplied, 2 × 3 = 6.
Exercise
Evaluate 5 + 2 × 2^3^2 − 1. Show each step.
Show answer
First resolve the tower from the top: 3^2 = 9, so 2^3^2 = 2^9 = 512. The expression becomes 5 + 2 × 512 − 1. Multiply: 2 × 512 = 1024, giving 5 + 1024 − 1. Then go left to right: 5 + 1024 = 1029, and 1029 − 1 = 1028. The answer is 1028.
Exercise
Without running code, give the value of -2 2 2 in Python and explain the order of the steps.
Show answer
The value is -16. The exponent operator binds tighter than the leading minus sign, and the tower is evaluated top down: 2 2 = 4, then 2 4 = 16. The minus sign is applied last, giving -16.