Equivalent Fractions and Simplifying
Different-looking fractions can name the same number: , and are all one half. This lesson shows how to make equivalent fractions, how to simplify a fraction to lowest terms with the greatest common factor, and how Python does it automatically.
Same amount, different names
Cut a cake into 2 pieces and take 1. Now cut the same cake into 4 pieces and take 2. You have the same amount of cake both times, so . Such fractions are called equivalent.
The rule: multiply or divide the numerator and the denominator by the same non-zero number, and the value does not change.
Why it works: multiplying top and bottom by 3 is the same as multiplying the fraction by , and . Multiplying by 1 changes nothing.
Simplifying to lowest terms
A fraction is in lowest terms (fully simplified) when the numerator and denominator have no common factor other than 1. To get there in one step, divide both by their greatest common factor (GCF):
| Fraction | GCF | Simplified |
|---|---|---|
| 2 | ||
| 5 | ||
| 6 | ||
| 1 | (already lowest) | |
| 14 |
You can also simplify in several small steps: (dividing by 2, then by 3). The result is the same; using the GCF just saves steps.
import math
def simplify(top, bottom):
g = math.gcd(top, bottom)
return top // g, bottom // g
for top, bottom in [(6, 8), (15, 25), (18, 24), (14, 15), (42, 56)]:
g = math.gcd(top, bottom)
print(f"{top}/{bottom}: gcd = {g:2d} -> {simplify(top, bottom)}")6/8: gcd = 2 -> (3, 4)
15/25: gcd = 5 -> (3, 5)
18/24: gcd = 6 -> (3, 4)
14/15: gcd = 1 -> (14, 15)
42/56: gcd = 14 -> (3, 4)
Checking whether two fractions are equal
Two fractions and are equivalent exactly when their cross products match: .
This test needs no simplifying at all, and it is how Fraction compares values internally.
Python does it for you
Fraction always stores the lowest-terms version, and every equivalent fraction compares equal:
from fractions import Fraction
print(Fraction(42, 56))
print(Fraction(1, 2) == Fraction(2, 4) == Fraction(50, 100))
# make equivalent fractions with a chosen denominator
half = Fraction(1, 2)
for d in [4, 10, 16, 100]:
print(f"1/2 = {half.numerator * d // half.denominator}/{d}")
# negative signs always move to the numerator
print(Fraction(3, -12))3/4
True
1/2 = 2/4
1/2 = 5/10
1/2 = 8/16
1/2 = 50/100
-1/4
Note: A negative fraction can be written three ways: , and are the same number. The convention, which
Fractionfollows, is a positive denominator.
Where you meet this in software
- Aspect ratios. A screen has the ratio , which simplifies (GCF 120) to . Image tools do exactly this simplification to label a resolution:
from fractions import Fraction
for w, h in [(1920, 1080), (2560, 1440), (1280, 1024), (3440, 1440), (1080, 1920)]:
r = Fraction(w, h)
print(f"{w}x{h} -> {r.numerator}:{r.denominator}")1920x1080 -> 16:9
2560x1440 -> 16:9
1280x1024 -> 5:4
3440x1440 -> 43:18
1080x1920 -> 9:16
Note that "ultrawide 21:9" monitors at are really 43:18 (about 2.39). The marketing name is a rounded label.
- Normalizing keys. If a program stores ratios as
(numerator, denominator)pairs, for example in a dictionary or a database, it must simplify them first, or and become two different keys. - Reducing gear or clock ratios. Audio resamplers convert 44 100 Hz to 48 000 Hz by the ratio , so they upsample by 160 and downsample by 147.
Exercises
Exercise 1: Fill the gap
Find the missing numbers: and .
Answer
and .
Solution
Exercise 2: Lowest terms
Simplify , and .
Answer
, and (already in lowest terms).
Solution
import math
for a, b in [(48, 60), (27, 81), (35, 64)]:
g = math.gcd(a, b)
print(f"{a}/{b} -> {a // g}/{b // g}")48/60 -> 4/5
27/81 -> 1/3
35/64 -> 35/64
Exercise 3: Cross-product check
Without simplifying, decide whether and are equivalent.
Answer
Yes, they are equivalent (both are ).
Solution
Cross products: and . They match, so the fractions are equal. (Simplified, each is .)
Exercise 4: Aspect ratio labels
Write a function aspect(w, h) that returns a string like "16:9" using math.gcd (no Fraction). Test it on , and .
Answer
683:384, 4:3 and 64:27.
Solution
Divide both sides by their GCF. , so is really 683:384 (sold as "16:9", about 1.779 vs 1.778). gives 4:3. gives 64:27 (sold as "21:9").
import math
def aspect(w, h):
g = math.gcd(w, h)
return f"{w // g}:{h // g}"
for w, h in [(1366, 768), (2048, 1536), (2560, 1080)]:
print(w, h, aspect(w, h))1366 768 683:384
2048 1536 4:3
2560 1080 64:27
Test yourself
Which fraction is equivalent to ?
What is in lowest terms?
Are and equivalent?
- No, the numbers are different
- Yes, both equal
- Only if you round them
- No, 7 is prime