TExcelTAD
Home › Basic Math & Pre-Algebra › Exponents

Exponents

An exponent is shorthand for repeated multiplication: instead of writing 3×3×3×33 \times 3 \times 3 \times 3 you write 343^4. This lesson covers the vocabulary, how to read and compute powers by hand and in Python, and the sign traps that catch people (and programs).

Base and exponent

In 343^4 the base is 3 and the exponent (or power) is 4. The exponent says how many copies of the base are multiplied together:

34=3×3×3×3=8125=2×2×2×2×2=32103=10×10×10=1000\begin{aligned} 3^4 &= 3 \times 3 \times 3 \times 3 = 81 \\ 2^5 &= 2 \times 2 \times 2 \times 2 \times 2 = 32 \\ 10^3 &= 10 \times 10 \times 10 = 1000 \end{aligned}

You read 343^4 as "three to the fourth power" or "three to the fourth". Two powers have their own names that come from geometry:

Expression Read as Why
525^2 five squared area of a 5-by-5 square
535^3 five cubed volume of a 5-by-5-by-5 cube
515^1 five to the first just 5 itself

An exponent of 1 means "one copy", so any number to the first power is itself: 71=77^1 = 7.

Powers in Python

Python writes powers with ** (two stars). The ^ symbol does not mean "power" in Python, JavaScript, C or Java; it is the bitwise XOR operator, a classic beginner bug.

python · try it yourself
print("3 ** 4 =", 3 ** 4)
print("2 ** 5 =", 2 ** 5)
print("10 ** 3 =", 10 ** 3)
print("pow(7, 2) =", pow(7, 2))
print("1.5 ** 2 =", 1.5 ** 2)

# The trap: ^ is XOR, not power
print("3 ^ 4 =", 3 ^ 4, " (XOR, not 81!)")

# Python integers never overflow, so huge powers are exact
print("2 ** 100 =", 2 ** 100)
3 ** 4 = 81
2 ** 5 = 32
10 ** 3 = 1000
pow(7, 2) = 49
1.5 ** 2 = 2.25
3 ^ 4 = 7  (XOR, not 81!)
2 ** 100 = 1267650600228229401496703205376

Note: Python's integers grow as large as memory allows, so 2 ** 100 is exact. In C, Java or Rust a 32-bit int would overflow long before that. See Integer Overflow and Two's Complement.

Negative bases and parentheses

Powers come before negation in the order of operations. That makes these two expressions different:

(−3)2=(−3)×(−3)=9the base is −3−32=−(3×3)=−9the base is 3, then negate\begin{aligned} (-3)^2 &= (-3) \times (-3) = 9 && \text{the base is } {-3} \\ -3^2 &= -(3 \times 3) = -9 && \text{the base is 3, then negate} \end{aligned}

A negative base raised to an even power gives a positive result; to an odd power, a negative result. Python follows the same rule, which surprises people who type -3 ** 2:

python · try it yourself
print("-3 ** 2   =", -3 ** 2)      # parsed as -(3 ** 2)
print("(-3) ** 2 =", (-3) ** 2)
print("(-2) ** 3 =", (-2) ** 3)
print("(-2) ** 4 =", (-2) ** 4)

for n in range(1, 7):
    print(f"(-1)^{n} = {(-1) ** n:2d}")
-3 ** 2   = -9
(-3) ** 2 = 9
(-2) ** 3 = -8
(-2) ** 4 = 16
(-1)^1 = -1
(-1)^2 =  1
(-1)^3 = -1
(-1)^4 =  1
(-1)^5 = -1
(-1)^6 =  1

The flip-flopping (−1)n(-1)^n is a handy trick for alternating signs, for example in series that go +−+−…+ - + - \ldots.

Powers grow fast

Squares and cubes of small numbers are worth knowing by heart. Notice how quickly the columns run away from each other:

python · try it yourself
print(" n   n²    n³     2ⁿ")
for n in range(1, 11):
    print(f"{n:2d} {n**2:4d} {n**3:5d} {2**n:6d}")
 n   n²    n³     2ⁿ
 1    1     1      2
 2    4     8      4
 3    9    27      8
 4   16    64     16
 5   25   125     32
 6   36   216     64
 7   49   343    128
 8   64   512    256
 9   81   729    512
10  100  1000   1024

When the exponent is the thing that grows (2n2^n), the numbers explode much faster than when the base grows (n2n^2 or n3n^3). That difference is the heart of Growth Rates and Big-O.

Tip: To square a number ending in 5, take the leading digits dd, compute d×(d+1)d \times (d + 1), and append 25. For 35235^2: 3×4=123 \times 4 = 12, so 1225.

In software

  • Area and volume: a texture that is 512 pixels wide and tall has 5122=262,144512^2 = 262{,}144 pixels; doubling the side quadruples the memory.
  • Combinations: a 4-digit PIN has 104=10,00010^4 = 10{,}000 possibilities; a password of 8 lowercase letters has 268≈20926^8 \approx 209 billion. That is why longer passwords are so much harder to brute-force.
  • Easing curves in UI animation often use t2t^2 or t3t^3 for a value tt between 0 and 1 to make motion start slowly and speed up (see easing).

Exercises

Exercise 1: Expand and compute

Write each power as a product and compute it: 434^3, 262^6, 929^2, 1501^{50}.

Answer

43=644^3 = 64, 26=642^6 = 64, 92=819^2 = 81, 150=11^{50} = 1.

Solution
43=4×4×4=16×4=6426=2×2×2×2×2×2=6492=9×9=81150=1×1×…×1 (50 ones)=1\begin{aligned} 4^3 &= 4 \times 4 \times 4 = 16 \times 4 = 64 \\ 2^6 &= 2 \times 2 \times 2 \times 2 \times 2 \times 2 = 64 \\ 9^2 &= 9 \times 9 = 81 \\ 1^{50} &= 1 \times 1 \times \ldots \times 1\ \text{(50 ones)} = 1 \end{aligned}

Note that 434^3 and 262^6 are equal: 4=224 = 2^2, so 43=22×22×22=264^3 = 2^2 \times 2^2 \times 2^2 = 2^6.

Exercise 2: Signs

Compute (−5)2(-5)^2, −52-5^2, (−5)3(-5)^3 and (−1)101(-1)^{101}.

Answer

25, −25, −125, −1.

Solution
(−5)2=(−5)×(−5)=25even power of a negative→positive−52=−(5×5)=−25the power binds before the minus(−5)3=25×(−5)=−125odd power of a negative→negative(−1)101=−1101 is odd\begin{aligned} (-5)^2 &= (-5) \times (-5) = 25 && \text{even power of a negative} \to \text{positive} \\ -5^2 &= -(5 \times 5) = -25 && \text{the power binds before the minus} \\ (-5)^3 &= 25 \times (-5) = -125 && \text{odd power of a negative} \to \text{negative} \\ (-1)^{101} &= -1 && \text{101 is odd} \end{aligned}

Exercise 3: PIN codes

A lock uses a code of 6 digits, each 0–9. How many codes are possible? How many more is that than a 4-digit code?

Answer

106=1,000,00010^6 = 1{,}000{,}000 codes, which is 990,000 more than the 104=10,00010^4 = 10{,}000 four-digit codes (100 times as many).

Solution

Each of the 6 positions has 10 choices, and the choices multiply: 10×10×10×10×10×10=10610 \times 10 \times 10 \times 10 \times 10 \times 10 = 10^6.

python · try it yourself
six = 10 ** 6
four = 10 ** 4
print(six, four, six - four, six // four)
1000000 10000 990000 100

Exercise 4: Find the exponent

Write a loop that finds the smallest nn with 3n>1,000,0003^n > 1{,}000{,}000.

Answer

n=13n = 13, because 312=531,4413^{12} = 531{,}441 and 313=1,594,3233^{13} = 1{,}594{,}323.

Solution

Start at n=0n = 0 and keep increasing nn while 3n3^n is still too small.

python · try it yourself
n = 0
while 3 ** n <= 1_000_000:
    n += 1
print(n, 3 ** (n - 1), 3 ** n)
13 531441 1594323

Test yourself

What does 2 ** 3 ** 2 print in Python? (Hint: ** groups from the right.)

  1. 64
  2. 512
  3. 36
  4. 12

What is −24-2^4 (without parentheses)?

  1. 16
  2. −8
  3. −16
  4. 8

Which Python expression computes 5 to the third power?

  1. 5 ^ 3
  2. 5 ** 3
  3. 5 * 3
  4. pow(3, 5)