Sub topic 12
Raising a fraction to a power
This chapter assumes you can multiply and divide fractions, you know what an exponent means (repeated multiplication), and you can work with negative integers. It covers one rule, why it works, and the ways it goes wrong in practice.
The rule: the exponent reaches both parts
A fraction raised to a power means the whole fraction is multiplied by itself. Take the fraction (2/3) squared:
(2/3)² = (2/3) × (2/3) = (2 × 2) / (3 × 3) = 4/9
Multiplying fractions multiplies the numerators and multiplies the denominators. So the exponent lands on both parts:
(a/b)ⁿ = aⁿ / bⁿ (with b ≠ 0)
Two details are worth fixing early:
- The exponent applies to the numerator and the denominator, never to just one of them.
- The result is not simplified by cancelling across the powers. You compute aⁿ and bⁿ, then reduce the final fraction if a common factor remains. For example, (6/4)² = 36/16 = 9/4. You get the same answer by reducing first: (3/2)² = 9/4.
from fractions import Fraction
base = Fraction(2, 3)
print(base ** 2) # 4/9
print(Fraction(2 ** 2, 3 ** 2)) # 4/9: numerator and denominator powered separately
print(Fraction(6, 4) ** 2) # 9/4: reduced automaticallyParentheses decide what the exponent touches
An exponent attaches to the nearest thing on its left. For a fraction written on one line, that thing is only the last number unless you add parentheses.
| Expression | What the exponent applies to | Value |
|---|---|---|
| (2/3)^2 | the whole fraction | 4/9 |
| 2/3^2 | only the 3 | 2/9 |
| 2^2/3 | only the 2 | 4/3 |
In 2/3^2, the exponent ranks above division. So you evaluate 3² = 9 first, then divide 2 by 9. This is a direct use of the precedence rules from earlier chapters, not a special rule for fractions.
When a fraction is typeset with a horizontal bar and a small raised exponent after a large parenthesis, the parentheses are visible and there is no ambiguity. When you type it on one line, you must add them yourself.
from fractions import Fraction
print(Fraction(2, 3) ** 2) # 4/9: the whole fraction is the base
print(Fraction(2) / 3 ** 2) # 2/9: the exponent binds to 3 only
print(Fraction(2) ** 2 / 3) # 4/3: the exponent binds to 2 onlyNegative fractions and the sign
A negative fraction raised to a power follows the same rule as -3² versus (-3)² from the previous chapter. Whether the minus sign is part of the base depends on parentheses.
- (-2/3)² has -2/3 as the base. It equals (-2)²/3² = 4/9.
- -(2/3)² applies the exponent first, then the minus sign. It equals -4/9.
- (-2/3)³ = (-2)³/3³ = -8/27.
The sign of the result follows a pattern you can use as a quick check. A negative base with an even exponent gives a positive result. A negative base with an odd exponent gives a negative result.
| Expression | Base | Exponent | Result |
|---|---|---|---|
| (-2/3)^2 | -2/3 | even | 4/9 |
| (-2/3)^3 | -2/3 | odd | -8/27 |
| -(2/3)^2 | 2/3, then negated | even | -4/9 |
| -(2/3)^3 | 2/3, then negated | odd | -8/27 |
A negative fraction can place its minus sign in the numerator, in the denominator, or in front of the bar. These are all the same number: -2/3 = (-2)/3 = 2/(-3). Inside parentheses with an exponent, you may pick whichever form is easiest.
from fractions import Fraction
print(Fraction(-2, 3) ** 2) # 4/9
print(Fraction(-2, 3) ** 3) # -8/27
print(-Fraction(2, 3) ** 2) # -4/9: unary minus ranks below **
print(-Fraction(2, 3) ** 3) # -8/27In Python, -Fraction(2, 3) ** 2 is parsed as -(Fraction(2, 3) ** 2). This mirrors the written rule, so the code can confirm a hand calculation of -3² type cases.
Where the power sits in a longer expression
A power of a fraction is just an exponent, so it is evaluated at the exponent stage. It comes after grouping and before multiplication and division. Here is a full worked example:
1/2 + 3/4 × (2/3)²
- Grouping: (2/3) is already one value, and the exponent applies to it.
- Exponent: (2/3)² = 4/9, so the expression becomes 1/2 + 3/4 × 4/9.
- Multiplication: 3/4 × 4/9 = 12/36 = 1/3.
- Addition: 1/2 + 1/3 = 3/6 + 2/6 = 5/6.
A second example puts a subtraction inside the parentheses:
(1/2 − 3/4)² ÷ 1/4
- Parentheses first: 1/2 − 3/4 = 2/4 − 3/4 = −1/4.
- Exponent: (−1/4)² = 1/16. The result is positive because the exponent is even.
- Division: 1/16 ÷ 1/4 = 1/16 × 4/1 = 4/16 = 1/4.
from fractions import Fraction
first = Fraction(1, 2) + Fraction(3, 4) * Fraction(2, 3) ** 2
second = (Fraction(1, 2) - Fraction(3, 4)) ** 2 / Fraction(1, 4)
print(first) # 5/6
print(second) # 1/4Mixed numbers and decimals
A mixed number such as 1 1/2 must be converted to an improper fraction before you apply an exponent. Mixed numbers hide an addition: 1 1/2 means 1 + 1/2. Squaring the parts separately gives 1² + (1/2)² = 1 1/4, which is wrong.
The correct path is 1 1/2 = 3/2, so (3/2)² = 9/4 = 2 1/4.
A decimal base works the same way, but fractions keep the answer exact. For example, (0.5)³ = 0.125, which equals (1/2)³ = 1/8. Convert to a fraction when you want an exact result or when the decimal repeats.
A short note on negative exponents
Chapter 13 covers zero and negative exponents in full. For fractions, the one fact you need here is that a negative exponent takes the reciprocal. Flip the fraction, then use the positive exponent:
(a/b)⁻ⁿ = (b/a)ⁿ
So (2/3)⁻² = (3/2)² = 9/4. The base is flipped, not the sign of the result.
from fractions import Fraction
print(Fraction(2, 3) ** -2) # 9/4
print(Fraction(-1, 2) ** -3) # -8The second line works because (−1/2)⁻³ = (−2/1)³ = −8. The negative base with an odd exponent keeps its sign.
Common mistakes
- Raising only the numerator: (2/3)² computed as 4/3.
- Multiplying the fraction by the exponent: (2/3)² computed as 4/6. An exponent means repeated multiplication, not multiplication by the exponent.
- Dropping parentheses when typing: 2/3^2 gives 2/9, not 4/9.
- Losing the sign: (−2/3)² computed as −4/9. The parentheses make −2/3 the base.
- Squaring the parts of a mixed number separately.
- Reducing across the powers incorrectly. Reduce before or after powering, but reduce a fraction as a whole.
Check your understanding
Exercise
Evaluate 1/3 + (−1/2)³ × 4 by hand, showing each step. Then write the Python line that checks it with Fraction.
Show answer
Exponent first: (−1/2)³ = −1/8, because the base is negative and the exponent is odd. Multiplication next: −1/8 × 4 = −4/8 = −1/2. Addition last: 1/3 + (−1/2) = 2/6 − 3/6 = −1/6. Check: print(Fraction(1, 3) + Fraction(-1, 2) * 3 4) prints -1/6.
Exercise
Explain why (3/5)² equals 9/25 but 3/5² equals 3/25. Then give the value of -(3/5)² and of (-3/5)².
Show answer
In (3/5)² the parentheses make the whole fraction the base, so both 3 and 5 are squared: 9/25. In 3/5² the exponent attaches only to the 5, so 5² = 25 is computed first and 3 is divided by 25: 3/25. For the signs, -(3/5)² = -9/25 because the minus is applied after the power, and (-3/5)² = 9/25 because the negative fraction is the base and the exponent is even.