Skip to content
The Lumenary
Grades 3–5Ages 8–11 45 min

Fractions and decimals

Fractions are numbers with their own places on the number line — and once you see that, comparing, adding and decimals all make sense.

Formally verified · 19 LeanComputationally tested · 2 PythonAI-drafted · awaiting human reviewMathematically reviewed: Awaiting human review

Your guides: Chloe, Margaret, Gideon

MotivationH

Three injera, four friends

Hana and three friends in Addis Ababa have 3 injera to share equally. That is 33 flatbreads for 44 people, so nobody can have a whole one.

Hana has an idea. She cuts each injera into 44 equal pieces. Now there are 1212 pieces, and each friend takes 33 of them. Each piece is one quarter of an injera, so each friend gets three quarters:

3÷4=34.3 \div 4 = \tfrac{3}{4}.

In whole-number arithmetic, 3÷43 \div 4 was "00 remainder 33". Fractions are how we answer "how much?" exactly, when the answer is not a whole number. In this lesson you will see that a fraction is a number in its own right, with its own place on the number line.

IntuitionH

Fractions live on the number line

Take the stretch of number line from 00 to 11 and cut it into 44 equal parts. Each part has length 14\tfrac14 (one quarter). Three of those parts, laid end to end from 00, reach the point 34\tfrac34.

01/42/43/415/46/47/423 copies of 1/45/4 = 1 and 1/4
The number line from 0 to 2, cut into quarters. Three copies of 1/4 reach 3/4. Five copies reach 5/4, which is one whole and one more quarter.

So a fraction is not only "part of a pizza". It is a length, and a point on the number line, just like 11, 22 and 33. Some fractions are bigger than 11: five quarters, 54\tfrac54, is one whole and one more quarter, which we can write as the mixed number 1141\tfrac14. Whole numbers are fractions too: 2=21=42=842 = \tfrac21 = \tfrac42 = \tfrac84.

Fractions and decimals on one line

Add your own numbers. Which ones land on the same point?

01/42/43/415/46/47/421/40.5 = 2/43/45/4
  • 1/4
  • 3/4
  • 5/4
  • 0.5
  • 2/4

From smallest to largest

1/4 < 0.5 = 2/4 < 3/4 < 5/4

With 4 equal parts in each whole, which points land exactly on a tick mark?

1/4 = 0.25 · 0.5 = 2/4 = 1/2 · 3/4 = 0.75 · 5/4 = 1.25

DefinitionsH

The words we need

Definition— unit fraction

Let bb be a whole number bigger than 00. Cut the stretch from 00 to 11 into bb equal parts. The length of each part is the unit fraction 1b\tfrac{1}{b}.

Definition— fraction

For whole numbers aa and bb with b>0b > 0, the fraction ab\tfrac{a}{b} is the length of aa parts of size 1b\tfrac{1}{b}, laid end to end. The bottom number bb is the denominator: it names the size of the parts. The top number aa is the numerator: it counts how many parts.

Definition— equivalent fractions

Two fractions are equivalent when they mark the same point on the number line, that is, when they are the same number. There is a quick test: ab\tfrac{a}{b} and cd\tfrac{c}{d} are equivalent exactly when a×d=c×ba \times d = c \times b.

Definition— decimal

Decimals continue place value to the right of the ones. The first place after the decimal point counts tenths, the next hundredths, the next thousandths. So 0.370.37 means 33 tenths and 77 hundredths, which is 37100\tfrac{37}{100}.

The denominator can never be 00: nobody can cut a whole into 00 equal parts.

Worked examplesH

Worked examples

Example— Families of equivalent fractions

Cut every half into 22 pieces and you get quarters: 12=24\tfrac12 = \tfrac24. Cut every half into 33 pieces and you get sixths: 12=36\tfrac12 = \tfrac36. So

12=24=36=48=50100=⋯\tfrac12 = \tfrac24 = \tfrac36 = \tfrac48 = \tfrac{50}{100} = \cdots

Going the other way, 68=34\tfrac68 = \tfrac34: both 66 and 88 are 22 times something, so we can join pairs of eighths into quarters. A fraction is in simplest form (or lowest terms) when no whole number bigger than 11 divides both the top and the bottom.

Example— Comparing

Which is bigger, 34\tfrac34 or 23\tfrac23? Their pieces are different sizes, so rewrite both with twelfths: 34=912\tfrac34 = \tfrac{9}{12} and 23=812\tfrac23 = \tfrac{8}{12}. Now the pieces are the same size, and 99 pieces are more than 88. So 34>23\tfrac34 > \tfrac23.

With the same numerator, the bigger denominator means smaller pieces: 15>18\tfrac15 > \tfrac18, because fifths are bigger than eighths.

Example— Adding and subtracting

  • 12+13=36+26=56\tfrac12 + \tfrac13 = \tfrac36 + \tfrac26 = \tfrac56.
  • 34−16=912−212=712\tfrac34 - \tfrac16 = \tfrac{9}{12} - \tfrac{2}{12} = \tfrac{7}{12}.
  • 25+45=65=115\tfrac25 + \tfrac45 = \tfrac65 = 1\tfrac15. Same denominator, so just add the numerators.

Example— Decimals and fractions

  • 0.7=7100.7 = \tfrac{7}{10}, 0.07=7100\quad 0.07 = \tfrac{7}{100}, 0.007=71000\quad 0.007 = \tfrac{7}{1000}.
  • 0.125=1251000=180.125 = \tfrac{125}{1000} = \tfrac18, because 8×125=10008 \times 125 = 1000.
  • 320=15100=0.15\tfrac{3}{20} = \tfrac{15}{100} = 0.15: multiply top and bottom by 55 to make hundredths.
  • Which is bigger, 0.30.3 or 0.250.25? Write 0.30.3 as 0.300.30: that is 3030 hundredths, and 0.250.25 is 2525 hundredths. So 0.3>0.250.3 > 0.25.

Example— A whole number times a fraction

4×234 \times \tfrac23 means 44 groups of 22 thirds, which is 88 thirds: 83=223\tfrac83 = 2\tfrac23. In general, n×ab=n×abn \times \tfrac{a}{b} = \tfrac{n \times a}{b}. The size of the pieces stays the same, and there are nn times as many of them.

Explore

Explore with fraction bars

All the bars below are the same length, so they all show the same whole.

Compare. Change the numerators and denominators. How does the widget decide which fraction is bigger?

Compare fractions

Each strip is the same whole. Change the fractions and compare how much is shaded.

3/4
2/3
5/8
3
4
2
3
5
8

5/8<2/3<3/4

Cut each whole into 24 equal pieces: then just count the pieces.

3/4 = 18/242/3 = 16/245/8 = 15/24

Equivalent fractions. Move the slider to cut every part into smaller pieces. The bar does not change, but its name does.

Equivalent fractions

Cut every part into the same number of pieces. The pieces change, but the amount stays the same.

2/3
2/3

2/3=(2 × 1) / (3 × 1)=2/3

This is the simplest form: the pieces cannot be grouped into fewer equal parts.

The same amount, written different ways (tap one):

===

Adding. Watch how both fractions are re-cut into pieces of the same size before anything is added.

Adding and subtracting fractions

To add or subtract, first cut both wholes into pieces of the same size.

1/2
1/3
1
2
1
3

Step 1 of 3

1/2 + 1/3 = ?

The pieces are different sizes (cut into 2 and into 3), so we can't add or subtract the pieces yet.

ProofH

Why the rules work

Why ab=n×an×b\tfrac{a}{b} = \tfrac{n \times a}{n \times b}

Start with ab\tfrac{a}{b}: the whole is cut into bb equal parts, and we take aa of them. Now cut every part into nn smaller equal pieces. The whole now has n×bn \times b pieces. Each old part became nn new pieces, so our aa old parts are n×an \times a new pieces. We cut, but we did not move anything, so the length is the same:

ab=n×an×bfor every whole number n>0.\frac{a}{b} = \frac{n \times a}{n \times b} \qquad \text{for every whole number } n > 0.

Why the cross-multiplication test works

To compare ab\tfrac{a}{b} and cd\tfrac{c}{d}, rewrite both with the same pieces, using the rule above. Multiply the first by dd on top and bottom, and the second by bb:

ab=a×db×d,cd=c×bd×b.\frac{a}{b} = \frac{a \times d}{b \times d}, \qquad \frac{c}{d} = \frac{c \times b}{d \times b}.

Now both fractions count pieces of the same size, 1b×d\tfrac{1}{b \times d}. Two counts of same-sized pieces give the same length exactly when the counts are equal. So ab=cd\tfrac{a}{b} = \tfrac{c}{d} exactly when a×d=c×ba \times d = c \times b. In the same way, ab<cd\tfrac{a}{b} < \tfrac{c}{d} exactly when a×d<c×ba \times d < c \times b.

Example— Using the test

Is 69=1015\tfrac{6}{9} = \tfrac{10}{15}? Check: 6×15=906 \times 15 = 90 and 10×9=9010 \times 9 = 90. Yes! Is 23=34\tfrac23 = \tfrac34? 2×4=82 \times 4 = 8 but 3×3=93 \times 3 = 9. No: since 8<98 < 9, 23<34\tfrac23 < \tfrac34.

Why we add with a common denominator

We can only add counts of the same thing: 33 sixths and 22 sixths are 55 sixths, just as 33 apples and 22 apples are 55 apples. Halves and thirds are different-sized pieces, so we first re-cut both into sixths. In general,

ab+cd=a×db×d+c×bb×d=a×d+c×bb×d.\frac{a}{b} + \frac{c}{d} = \frac{a \times d}{b \times d} + \frac{c \times b}{b \times d} = \frac{a \times d + c \times b}{b \times d}.

Theorem— the tempting mistake

12+13\tfrac12 + \tfrac13 is not 25\tfrac25.

Proof

Adding 13\tfrac13 to 12\tfrac12 must give something bigger than 12\tfrac12. But 25\tfrac25 is smaller than 12\tfrac12, because 2×2=42 \times 2 = 4 is less than 1×5=51 \times 5 = 5. So 25\tfrac25 cannot be the answer. (The correct answer is 56\tfrac56.)

∎

Why 0.30.3 is bigger than 0.250.25

The digits of a decimal are counts of tenths, hundredths and thousandths. To compare, use the same place values: 0.3=0.30=301000.3 = 0.30 = \tfrac{30}{100} and 0.25=251000.25 = \tfrac{25}{100}. Thirty hundredths are more than twenty-five hundredths. Comparing "2525 with 33" compares hundredths with tenths, which are different-sized pieces.

Which fractions have a decimal that stops?

A decimal with 33 places is a number of thousandths, like 0.375=37510000.375 = \tfrac{375}{1000}. So a fraction has a decimal that stops exactly when it can be rewritten with denominator 1010, 100100, 10001000 or another power of ten.

  • 38\tfrac38 can: 8×125=10008 \times 125 = 1000, so 38=3751000=0.375\tfrac38 = \tfrac{375}{1000} = 0.375.
  • 720\tfrac{7}{20} can: 20×5=10020 \times 5 = 100, so 720=35100=0.35\tfrac{7}{20} = \tfrac{35}{100} = 0.35.
  • 13\tfrac13 cannot!

Theorem— one third never stops

There is no power of ten 10,100,1000,…10, 100, 1000, \dots that 13\tfrac13 can be rewritten over. So the decimal of 13\tfrac13 goes on forever: 0.333…0.333\ldots

Proof

Suppose 13=m1000\tfrac13 = \tfrac{m}{1000}, or over some other power of ten. By the cross-multiplication test, 1000=3×m1000 = 3 \times m, so 10001000 would be a multiple of 33. But 1000=999+11000 = 999 + 1, and 999=3×333999 = 3 \times 333. So 10001000 is one more than a multiple of 33, and it is not a multiple of 33 itself. The same is true of every power of ten: 10=9+110 = 9 + 1, 100=99+1100 = 99 + 1, 10000=9999+110000 = 9999 + 1, and so on.

∎

For grown-ups · the general rule

A fraction in lowest terms has a decimal that stops exactly when its denominator has no prime factors other than 22 and 55 (see factors and primes). One direction is easy: if the denominator is made of 22s and 55s, multiply top and bottom by enough 22s and 55s to pair them all up into 1010s. The other direction needs the fact that prime factorisations are unique, since the only prime factors of 10k10^k are 22 and 55. This is proved in divisibility and unique factorisation. Lowest terms matter: 312\tfrac{3}{12} has a 33 in its denominator, yet 312=14=0.25\tfrac{3}{12} = \tfrac14 = 0.25 stops.

Formal mathematicsF

Gideon's precise statements

  1. "24=12\tfrac24 = \tfrac12." — True. 2×2=42 \times 2 = 4 and 1×4=41 \times 4 = 4.
  2. "A bigger denominator always means a bigger fraction." — False. 18<15\tfrac18 < \tfrac15. One counterexample settles it.
  3. "12+13=25\tfrac12 + \tfrac13 = \tfrac25." — False. 25\tfrac25 is less than 12\tfrac12.
  4. "0.25>0.30.25 > 0.3." — False. 25100<30100\tfrac{25}{100} < \tfrac{30}{100}.
  5. "13\tfrac13 can be written with denominator 10001000." — False. 10001000 is not a multiple of 33.
For grown-ups · the same ideas in Lean, a proof checker

Lean checks proofs. Here we build fractions from scratch: a fraction is a pair of whole numbers with a denominator bigger than 00, and "equivalent" means the cross-multiplication test.

FracLean 4Formally verified
/-- A fraction `num / den` of whole numbers. The denominator must not be `0`: it says how
many equal parts the whole is cut into. -/
structure Frac where
  /-- The numerator: how many parts we take. -/
  num : Nat
  /-- The denominator: how many equal parts make one whole. -/
  den : Nat
  /-- A whole cannot be cut into `0` parts. -/
  den_pos : 0 < den
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor
EquivLean 4Formally verified
/-- `a / b` and `c / d` are **equivalent** (they are the same number) when `a × d = c × b`:
written over the common denominator `b × d`, they have the same numerator. -/
def Frac.Equiv (x y : Frac) : Prop := x.num * y.den = y.num * x.den
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor

Equivalent fractions. Multiplying top and bottom by the same nn gives an equivalent fraction, and Lean checks some examples by multiplying:

scale_equivLean 4Proved here from basic factsFormally verified
/-- Multiplying the numerator and the denominator by the same `n > 0` gives an equivalent
fraction: `(n × a) / (n × b) = a / b`. Cutting every part into `n` smaller parts makes `n`
times as many parts, each `n` times smaller. -/
theorem scale_equiv (a b n : Nat) (hb : 0 < b) (hn : 0 < n) :
    frac (n * a) (n * b) (Nat.mul_pos hn hb) ≈ frac a b hb := by
  -- Unfolded, the claim is `(n × a) × b = a × (n × b)`: reorder the product.
  change n * a * b = a * (n * b)
  rw [Nat.mul_comm n a, Nat.mul_assoc]
Axioms used: propextformal/Lumenary/Fractions.leanTry it in the Lean web editor
two_quartersLean 4Proved here from basic factsFormally verified
/-- `2/4`, `3/6` and `50/100` are all equivalent to `1/2`. -/
theorem two_quarters : frac 2 4 ≈ frac 1 2 ∧ frac 3 6 ≈ frac 1 2 ∧ frac 50 100 ≈ frac 1 2 := by
  decide
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor

If two fractions are both equivalent to a third, they are equivalent to each other. The proof multiplies out and then cancels a factor, which is allowed because denominators are never 00:

equiv_transLean 4Proved here from basic factsFormally verified
/-- If `a/b ≈ c/d` and `c/d ≈ e/f`, then `a/b ≈ e/f`. We multiply out, use both facts, and
cancel the factor `d`, which is allowed because `d > 0` (`Nat.eq_of_mul_eq_mul_right`).
`ac_rfl` reorders a product; multiplication is commutative and associative. -/
theorem equiv_trans {x y z : Frac} (h1 : x ≈ y) (h2 : y ≈ z) : x ≈ z := by
  obtain ⟨a, b, _⟩ := x
  obtain ⟨c, d, hd⟩ := y
  obtain ⟨e, f, _⟩ := z
  change a * d = c * b at h1
  change c * f = e * d at h2
  change a * f = e * b
  apply Nat.eq_of_mul_eq_mul_right hd
  calc a * f * d = (a * d) * f := by ac_rfl
    _ = (c * b) * f := by rw [h1]
    _ = (c * f) * b := by ac_rfl
    _ = (e * d) * b := by rw [h2]
    _ = e * b * d := by ac_rfl
Axioms used: propext, Quot.soundformal/Lumenary/Fractions.leanTry it in the Lean web editor

Comparing.

same_den_ltLean 4Proved here from basic factsFormally verified
/-- With the same denominator, the fraction with the bigger numerator is bigger:
`a / b < c / b` exactly when `a < c` (same-sized pieces, so compare how many). -/
theorem same_den_lt (a c b : Nat) (hb : 0 < b) : frac a b hb < frac c b hb ↔ a < c := by
  change a * b < c * b ↔ a < c
  exact Nat.mul_lt_mul_right hb
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/Fractions.leanTry it in the Lean web editor
bigger_den_smaller_pieceLean 4Proved here from basic factsFormally verified
/-- A bigger denominator means a *smaller* piece: if `b < d` then `1/d < 1/b`.
Cutting the whole into more parts makes each part smaller. -/
theorem bigger_den_smaller_piece (b d : Nat) (hb : 0 < b) (hd : 0 < d) (h : b < d) :
    frac 1 d hd < frac 1 b hb := by
  change 1 * b < 1 * d
  rw [Nat.one_mul, Nat.one_mul]
  exact h
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor
three_quarters_gt_two_thirdsLean 4Proved here from basic factsFormally verified
/-- `2/3 < 3/4`, because over the common denominator `12` they are `8/12` and `9/12`. -/
theorem three_quarters_gt_two_thirds : frac 2 3 < frac 3 4 := by decide
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor

Adding. The rule, the examples, and a theorem that matters more than it looks. If we swap a fraction for an equivalent one, say 24\tfrac24 for 12\tfrac12, the sum is still the same number. Without this theorem, "adding fractions" would not even make sense!

addLean 4Formally verified
/-- `a/b + c/d = (a × d + c × b) / (b × d)`: rewrite both fractions over the common
denominator `b × d`, then add the numerators. -/
def Frac.add (x y : Frac) : Frac :=
  ⟨x.num * y.den + y.num * x.den, x.den * y.den, Nat.mul_pos x.den_pos y.den_pos⟩
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor
half_plus_thirdLean 4Proved here from basic factsFormally verified
/-- `1/2 + 1/3 = 5/6`. The rule gives `(1 × 3 + 1 × 2) / (2 × 3) = 5/6`. -/
theorem half_plus_third : (frac 1 2).add (frac 1 3) ≈ frac 5 6 := by decide
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor
half_plus_third_not_two_fifthsLean 4Proved here from basic factsFormally verified
/-- Adding tops and bottoms is wrong: `1/2 + 1/3` is **not** `2/5`. In fact `2/5` is smaller
than `1/2`, and a sum of two positive fractions must be bigger than each of them. -/
theorem half_plus_third_not_two_fifths :
    ¬ ((frac 1 2).add (frac 1 3) ≈ frac 2 5) ∧ frac 2 5 < frac 1 2 := by decide
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor
add_respects_equivLean 4Proved here from basic factsFormally verified
/-- The answer to an addition does not depend on which equivalent fractions we use:
if `x ≈ x'` and `y ≈ y'` then `x + y ≈ x' + y'`. So adding `2/4 + 1/3` gives the same number
as `1/2 + 1/3`. The proof multiplies out and uses the two cross-multiplication facts. -/
theorem add_respects_equiv {x x' y y' : Frac} (hx : x ≈ x') (hy : y ≈ y') :
    x.add y ≈ x'.add y' := by
  obtain ⟨a, b, _⟩ := x
  obtain ⟨a', b', _⟩ := x'
  obtain ⟨c, d, _⟩ := y
  obtain ⟨c', d', _⟩ := y'
  change a * b' = a' * b at hx
  change c * d' = c' * d at hy
  change (a * d + c * b) * (b' * d') = (a' * d' + c' * b') * (b * d)
  calc (a * d + c * b) * (b' * d') = (a * b') * (d * d') + (c * d') * (b * b') := by
          rw [Nat.add_mul]; ac_rfl
    _ = (a' * b) * (d * d') + (c' * d) * (b * b') := by rw [hx, hy]
    _ = (a' * d' + c' * b') * (b * d) := by rw [Nat.add_mul]; ac_rfl
Axioms used: propext, Quot.soundformal/Lumenary/Fractions.leanTry it in the Lean web editor
four_times_two_thirdsLean 4Proved here from basic factsFormally verified
/-- `4 × 2/3 = 8/3`, which is `2 2/3`: eight thirds, or two wholes and two thirds. -/
theorem four_times_two_thirds : (frac 2 3).natMul 4 ≈ frac 8 3 := by decide
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor

Decimals.

decimals_compareLean 4Proved here from basic factsFormally verified
/-- `0.25 < 0.3`: as fractions, `25/100 < 3/10`, because `3/10 = 30/100`. -/
theorem decimals_compare : frac 25 100 < frac 3 10 ∧ frac 3 10 ≈ frac 30 100 := by decide
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor
eighth_as_decimalLean 4Proved here from basic factsFormally verified
/-- `1/8 = 125/1000 = 0.125` and `3/8 = 375/1000 = 0.375`: since `8 × 125 = 1000`,
eighths can be written as thousandths. -/
theorem eighth_as_decimal : frac 1 8 ≈ frac 125 1000 ∧ frac 3 8 ≈ frac 375 1000 := by decide
Axioms used: No axiomsformal/Lumenary/Fractions.leanTry it in the Lean web editor
ten_pow_mod_threeLean 4Proved here from basic factsFormally verified
/-- Every power of ten leaves remainder `1` when divided by `3`: `10 = 9 + 1`,
`100 = 99 + 1`, `1000 = 999 + 1`, … Proved by induction, using that the remainder of a
product depends only on the remainders of the factors (`Nat.mul_mod`). -/
theorem ten_pow_mod_three (k : Nat) : 10 ^ k % 3 = 1 := by
  induction k with
  | zero => rfl
  | succ n ih => rw [Nat.pow_succ, Nat.mul_mod, ih]
Axioms used: propextformal/Lumenary/Fractions.leanTry it in the Lean web editor
third_not_terminatingLean 4Proved here from basic factsFormally verified
/-- `1/3` has no finite decimal: there are no `m` and `k` with `1/3 = m / 10^k`.
By cross-multiplication that would mean `10^k = 3 × m`, a multiple of `3`, but every power
of ten leaves remainder `1` when divided by `3`. -/
theorem third_not_terminating (m k : Nat) :
    ¬ (frac 1 3 ≈ frac m (10 ^ k) (Nat.pow_pos (by decide))) := by
  intro h
  change 1 * 10 ^ k = m * 3 at h
  have hrem : 10 ^ k % 3 = m * 3 % 3 := by rw [← h, Nat.one_mul]
  rw [ten_pow_mod_three, Nat.mul_mod_left] at hrem
  -- `hrem : 1 = 0`, which is false.
  exact absurd hrem (by decide)
Axioms used: propextformal/Lumenary/Fractions.leanTry it in the Lean web editor

Lean's own fractions. Lean also has a ready-made type of fractions, Rat (Mathlib calls it Q\Q). Its library contains the cross-multiplication test, and it can check our examples exactly:

rat_cross_mulLean 4Applies a library theoremFormally verified
/-- In Lean's own type of fractions `Rat`, `a/b = c/d` exactly when `a × d = c × b`
(for nonzero `b`, `d`). This applies core Lean's theorem `Rat.divInt_eq_divInt_iff`. -/
theorem rat_cross_mul {a b c d : Int} (hb : b ≠ 0) (hd : d ≠ 0) :
    (a : Rat) / b = c / d ↔ a * d = c * b := by
  rw [← Rat.divInt_eq_div, ← Rat.divInt_eq_div]
  exact Rat.divInt_eq_divInt_iff hb hd
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/Fractions.leanTry it in the Lean web editor
rat_examplesLean 4Proved here from basic factsFormally verified
/-- The lesson's examples in Lean's `Rat`: `1/2 + 1/3 = 5/6`, `1/2 + 1/3 ≠ 2/5`,
`0.25 < 0.3` and `0.125 = 1/8`. The kernel evaluates both sides exactly. -/
theorem rat_examples :
    (1 : Rat) / 2 + 1 / 3 = 5 / 6 ∧ (1 : Rat) / 2 + 1 / 3 ≠ 2 / 5 ∧
      (0.25 : Rat) < 0.3 ∧ (0.125 : Rat) = 1 / 8 := by
  decide +kernel
Axioms used: propext, Classical.choice, Quot.soundformal/Lumenary/Fractions.leanTry it in the Lean web editor

What is not formalised here: our home-made fractions use whole numbers only (no negative fractions), and the general rule about decimals that stop is proved only for 13\tfrac13. The other direction of the general rule needs unique prime factorisation.

ComputationC

Margaret tests the rules

Adding fractions: right rule, wrong rule, exact answersPythonExhaustive finite checkCounterexampleComputationally tested
"""Adding fractions: the right rule, a tempting wrong rule, and computer decimals.

Python's fractions.Fraction does exact arithmetic with fractions. We use it to
compare the rule a/b + c/d = (ad + cb)/(bd) with the tempting wrong rule
"add the tops and add the bottoms", (a + c)/(b + d), on every pair of
fractions between 0 and 1 with denominators up to 12; to check the
cross-multiplication test ad = cb against exact equality; and to see why a
computer's ordinary decimals (floats) can disagree with exact fractions.
"""

from fractions import Fraction

def add_rule(a, b, c, d):
    """Numerator and denominator of a/b + c/d by the common-denominator rule."""
    return a * d + c * b, b * d

def wrong_rule(a, b, c, d):
    """The tempting mistake: add the numerators and add the denominators."""
    return a + c, b + d

def equivalent(a, b, c, d):
    """Cross-multiplication test: a/b and c/d are the same number."""
    return a * d == c * b

def fractions_in_unit_interval(max_den):
    """All pairs (a, b) with 1 <= a <= b <= max_den: fractions in (0, 1]."""
    return [(a, b) for b in range(1, max_den + 1) for a in range(1, b + 1)]

def compare_rules(max_den):
    """Return (pairs, right rule correct, wrong rule correct, wrong in between)."""
    fracs = fractions_in_unit_interval(max_den)
    right = wrong = between = 0
    for a, b in fracs:
        for c, d in fracs:
            exact = Fraction(a, b) + Fraction(c, d)
            right += Fraction(*add_rule(a, b, c, d)) == exact
            mediant = Fraction(*wrong_rule(a, b, c, d))
            wrong += mediant == exact
            low, high = sorted([Fraction(a, b), Fraction(c, d)])
            between += low <= mediant <= high
    return len(fracs) ** 2, right, wrong, between

def cross_test_agrees(max_num, max_den):
    """Return (pairs, agreements, equal pairs) for the cross-multiplication test."""
    fracs = [(a, b) for a in range(max_num + 1) for b in range(1, max_den + 1)]
    exact = {f: Fraction(*f) for f in fracs}
    pairs = agree = equal = 0
    for a, b in fracs:
        for c, d in fracs:
            pairs += 1
            same = exact[(a, b)] == exact[(c, d)]
            agree += equivalent(a, b, c, d) == same
            equal += same
    return pairs, agree, equal

def main():
    num, den = add_rule(1, 2, 1, 3)
    wn, wd = wrong_rule(1, 2, 1, 3)
    print(f"1/2 + 1/3 by the common-denominator rule: {num}/{den}")
    print(f"1/2 + 1/3 by 'add tops, add bottoms': {wn}/{wd}"
          f" = {float(Fraction(wn, wd))}, but 1/2 = 0.5")
    print("  The wrong answer is smaller than one of the parts!")
    print()
    pairs, right, wrong, between = compare_rules(12)
    print(f"All {pairs:,} pairs of fractions in (0, 1], denominators up to 12:")
    print(f"  right rule equals the exact sum:   {right:,} of {pairs:,}")
    print(f"  wrong rule equals the exact sum:   {wrong:,} of {pairs:,}")
    print(f"  wrong rule lands between the two:  {between:,} of {pairs:,}")
    pairs, agree, equal = cross_test_agrees(24, 12)
    print(f"Cross-multiplication test versus exact equality, {pairs:,} pairs:")
    print(f"  they agree {agree:,} times ({equal:,} pairs are equal numbers)")
    print()
    print(f"Floats:    0.1 + 0.2 == 0.3 is {0.1 + 0.2 == 0.3};"
          f" 0.1 + 0.2 = {0.1 + 0.2!r}")
    exact = Fraction(1, 10) + Fraction(2, 10) == Fraction(3, 10)
    print(f"Fractions: 1/10 + 2/10 == 3/10 is {exact}")
    print()
    print("Epistemic status: the checks are complete for the fractions listed,")
    print("so they prove nothing about larger denominators; the lesson's argument")
    print("(same-sized pieces, then count) covers every fraction. The float")
    print("result is a real counterexample: binary floats cannot store 0.1 exactly.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.

The computer's ordinary decimals are stored in base two, where 0.10.1 cannot be written exactly, just as 13\tfrac13 cannot be written exactly in base ten. Exact fractions have no such problem.

Decimals that stop and decimals that repeatPythonExact computationExhaustive finite checkComputationally tested
"""Which fractions have decimals that stop?

Long division turns a fraction into a decimal. The remainders can only be
0, 1, ..., b - 1, so either a remainder of 0 appears (the decimal stops) or
a remainder repeats (the digits repeat forever). We print the decimals of
1/2 to 1/20 and then test the rule: a fraction in lowest terms has a decimal
that stops exactly when its denominator is built from 2s and 5s only.
"""

from math import gcd

def decimal_expansion(a, b):
    """Long division of a/b (b > 0, a >= 0).

    Returns (whole part, digits before the repeat, repeating digits); the
    repeating list is empty when the decimal stops.
    """
    if b <= 0 or a < 0:
        raise ValueError("need a >= 0 and b > 0")
    whole, r = divmod(a, b)
    digits, seen = [], {}
    while r and r not in seen:
        seen[r] = len(digits)
        digit, r = divmod(10 * r, b)
        digits.append(digit)
    if r == 0:
        return whole, digits, []
    start = seen[r]
    return whole, digits[:start], digits[start:]

def show(a, b):
    """The decimal as text, with the repeating block in brackets: 0.1(6)."""
    whole, fixed, repeat = decimal_expansion(a, b)
    text = "".join(map(str, fixed))
    if repeat:
        text += "(" + "".join(map(str, repeat)) + ")"
    return f"{whole}.{text}" if text else str(whole)

def only_twos_and_fives(n):
    """True if n > 0 has no prime factors other than 2 and 5."""
    if n <= 0:
        raise ValueError("n must be positive")
    for p in (2, 5):
        while n % p == 0:
            n //= p
    return n == 1

def check_rule(max_den):
    """Return (fractions checked, rule correct, decimals that stop)."""
    checked = correct = stops = 0
    for b in range(2, max_den + 1):
        for a in range(1, b):
            checked += 1
            terminates = decimal_expansion(a, b)[2] == []
            stops += terminates
            correct += terminates == only_twos_and_fives(b // gcd(a, b))
    return checked, correct, stops

def main():
    print("Long division of 1/b; brackets mark digits that repeat forever:")
    cells = [f"1/{b:<2} = {show(1, b)}" for b in range(2, 21)]
    for i in range(0, len(cells), 2):
        print("  " + "".join(f"{c:<36}" for c in cells[i:i + 2]).rstrip())
    print()
    checked, correct, stops = check_rule(100)
    print(f"All {checked:,} fractions a/b with 1 <= a < b <= 100:")
    print(f"  {stops:,} have decimals that stop; the rest repeat forever.")
    print("  Rule: 'stops exactly when the lowest-terms denominator uses only")
    print(f"  2s and 5s' is right in {correct:,} of {checked:,} cases.")
    print(f"  Careful with lowest terms: 3/12 = {show(3, 12)} stops, because"
          f" 3/12 = 1/4.")
    print()
    print("Epistemic status: long division here is exact (whole-number")
    print("remainders, no rounding), so each expansion is correct; the rule is")
    print("checked completely for these 4,950 fractions only. Why it holds for")
    print("every fraction: a stopping decimal is m/10^k, and the only prime")
    print("factors of 10^k are 2 and 5.")

if __name__ == "__main__":
    main()
Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Exercises

Your turn

Take your time. You can open a hint whenever you like.

1. Fractions and decimals

Warm-upHuman

Fill in the missing numerator: 34=?20\dfrac{3}{4} = \dfrac{?}{20}.

2. Fractions and decimals

Warm-upHuman

On a number line, which point is further from 00: 18\tfrac18 or 15\tfrac15?

Choose one

3. Fractions and decimals

CoreHuman

Sipho says 12+13=25\tfrac12 + \tfrac13 = \tfrac25. What is the best reply?

Choose one

4. Fractions and decimals

CoreHuman

Work out 23+14\dfrac{2}{3} + \dfrac{1}{4}. Write the answer in twelfths: ?12\dfrac{?}{12}.

5. Fractions and decimals

CoreHuman

Kiri ran 0.250.25 km and Ana ran 0.30.3 km. Who ran further?

Choose one

6. Fractions and decimals

Warm-upHuman

Write 0.1250.125 as a fraction with denominator 10001000: 0.125=?10000.125 = \dfrac{?}{1000}.

7. Fractions and decimals

CoreHuman

What is 4×234 \times \tfrac23?

Choose one

8. Fractions and decimals

StretchHuman

Which of these fractions have a decimal that stops? (Choose all that apply.)

Choose all that apply

9. Fractions and decimals

CoreFormal

In Lean, Gideon says that the fractions ab\tfrac{a}{b} and cd\tfrac{c}{d} are equivalent when a * d = c * b. Which statement does Lean need to check to show that 24\tfrac24 is equivalent to 12\tfrac12?

Choose one

10. Fractions and decimals

StretchComputational

Write add_fractions(a, b, c, d) that returns the sum ab+cd\tfrac{a}{b} + \tfrac{c}{d} as a pair (numerator, denominator) in simplest form. The starter uses the wrong rule from the lesson, so the tests fail. Use a×d+c×bb×d\tfrac{a \times d + c \times b}{b \times d}, then divide top and bottom by their greatest common factor, math.gcd.

Runs entirely in your browser, in an isolated worker. Nothing is sent to a server.
Common misconceptionsH

Things that trip people up

Misconception

"Add the tops and add the bottoms": 12+13=25\tfrac12 + \tfrac13 = \tfrac25. The answer 25\tfrac25 is smaller than 12\tfrac12, so it cannot be a sum that includes 12\tfrac12. Re-cut into same-sized pieces first: 36+26=56\tfrac36 + \tfrac26 = \tfrac56.

Misconception

"A bigger denominator means a bigger fraction." The denominator tells you how many pieces the whole is cut into. More pieces means smaller pieces, so 18<15\tfrac18 < \tfrac15.

Misconception

"0.25>0.30.25 > 0.3, because 25>325 > 3." The 2525 counts hundredths and the 33 counts tenths. Write 0.30.3 as 0.300.30 to compare hundredths with hundredths: 30>2530 > 25.

Misconception

"Fractions are only parts of shapes." Shapes are a good start, but a fraction is a number. It has a place on the number line, it can be bigger than 11 (54\tfrac54), and it can be the answer to a division (3÷4=343 \div 4 = \tfrac34).

Misconception

"Adding the same number to the top and bottom gives an equivalent fraction." 12\tfrac12 is not 1+12+1=23\tfrac{1 + 1}{2 + 1} = \tfrac23. Equivalent fractions come from multiplying top and bottom by the same number.

ViewpointsH

Other ways of seeing

Geometry— Fractions are points and lengths

A geometer sees ab\tfrac{a}{b} as a point on a line, found by cutting the unit length into bb equal parts. Ancient Greek geometers knew how to do that cutting with only a straightedge and compass, using parallel lines (Euclid, Elements, Book VI). In this picture, equivalent fractions are one point with many names. Comparing fractions means asking which point is further to the right.

Number theory— Lowest terms, and the primes 2 and 5

A number theorist notices that simplest form is about common factors. ab\tfrac{a}{b} is in lowest terms when the greatest common factor of aa and bb is 11. And whether a decimal stops depends only on the primes in the denominator, because 10=2×510 = 2 \times 5. In base twelve, which uses 12=2×2×312 = 2 \times 2 \times 3, the fraction 13\tfrac13 would stop. See factors and primes.

Algebra— Division always works now

With whole numbers alone, 3÷43 \div 4 has no exact answer. With fractions, every division by a number other than 00 has one: a÷b=aba \div b = \tfrac{a}{b}. Every fraction except 00 also has a partner that multiplies with it to make 11: 34×43=1\tfrac34 \times \tfrac43 = 1. Later, with negative numbers included, the fractions form the rational numbers. There, all four operations work (except division by zero), and algebraists call a system like that a field. Some numbers, such as 2\sqrt2, are not fractions at all (real numbers).

Wonder Trails

Wonder further

Set-theoretic connectionH

A fraction is a whole family

Think of all the names for one half: 12,24,36,48,…\tfrac12, \tfrac24, \tfrac36, \tfrac48, \dots They form a set, a family of equivalent fractions. Every fraction belongs to exactly one family, and the families never overlap. Mathematicians say that "is equivalent to" is an equivalence relation. It is reflexive (each fraction is equivalent to itself), symmetric, and transitive (Lean proved equiv_trans above). Its families are called equivalence classes (relations and partitions).

One way to say what the number "one half" is: it is the whole family. The Lean theorem add_respects_equiv says that adding works family by family. It does not matter which member of a family you pick.

History & global context

History and global context

  • Egypt. Scribes wrote almost every fraction as a sum of different unit fractions. The Rhind Mathematical Papyrus (around 1550 BCE) begins with a table of such sums, for example 25=13+115\tfrac25 = \tfrac13 + \tfrac{1}{15}.
  • Mesopotamia. Babylonian scribes wrote fractions in base 6060, about four thousand years ago. We still split an hour into 6060 minutes and a minute into 6060 seconds.
  • China. The Nine Chapters on the Mathematical Art, compiled about two thousand years ago, gives rules for adding, subtracting and comparing fractions with a common denominator. It also reduces fractions to lowest terms by repeatedly subtracting the smaller number from the larger.
  • India. Indian mathematicians wrote a fraction as the numerator above the denominator, without a line between them. The horizontal fraction bar later appears in Arabic writing, for example in the 12th-century work of al-Ḥaṣṣār in the Maghreb.
  • Decimal fractions. Abu'l-Ḥasan al-Uqlīdisī, writing in Damascus around 952 CE, already used decimal fractions. Jamshīd al-Kāshī in Samarkand explained them fully in his Key to Arithmetic (1427). In Flanders, Simon Stevin's booklet De Thiende (1585) spread decimals across Europe.
Further reading

Further reading

  • Hung-Hsi Wu, Understanding Numbers in Elementary School Mathematics (2011). Builds fractions on the number line, exactly as in this lesson.
  • Liping Ma, Knowing and Teaching Elementary Mathematics (1999). Chapter 3 is about dividing fractions.
  • Richard Courant and Herbert Robbins, What Is Mathematics? (1941). Chapter 2 is on rational numbers and decimals.
  • Victor J. Katz, A History of Mathematics: An Introduction (1993). The history of fractions in many cultures.