Lecture 29: Euclidean division

Terminology/Definitions

Euclidean division

Claim (Euclidean division algorithm): For any \(a\) and \(b > 0\) there exist \(q\) and \(r\) such that \(a = qb+r\) and \(0 \leq r \lt b\). Moreover, \(q\) and \(r\) are unique: if \(a = qb + r = q'b + r'\) then \(q = q'\) and \(r = r'\).

Notation: - \(q\) is called the quotient of \(a\) by \(b\), and is written \(quot(a,b)\). Some programming languages write \(a/b\) to refer to \(q\). Do not do this. \(a/b\) should have the property that \(b \cdot (a/b) = a\); the quotient does not have this property.

Proof of existence: By induction on \(a\). Fix \(b\) and let \(P(a)\) be the statement "\(∃ q, r \in \mathbb{Z}\) such that \(a = qb + r\)." We must prove \(P(0)\) and \(P(a+1)\) assuming \(P(a)\).

For \(P(0)\), let \(q = r = 0\). Since \(b > 0\), \(0 \leq r \lt b\). Moreover, \(0 = qb + r\) as required.

To prove \(P(a+1)\), assume \(P(a)\). Then there exist some \(q'\) and \(r' \lt b\) with \(a = q'b + r'\). Since \(r' \lt b\), either \(r' = b-1\) or \(r' \lt b-1\). We want to show that in either case, there exist \(q\) and \(r\) with \(a + 1 = qb + r\).

In the former case, we have \(a = q'b + r' = q'b + b-1\). Therefore \(a + 1 = q'b + b = (q'+1)b + 0\). Let \(q = q'+1\) and \(r = 0\), and we see that \(a + 1 = qb + r\) as required.

In the latter case, we can let \(q = q'\) and \(r = r'+1\). Since \(0 \leq r' \lt b-1\), we see that \(0 \leq r \lt b\). Moreover, since \(a = q'b + r'\), we see that \(a + 1 = qb + r\) as required.

Proof of uniqueness: Assume there are two pairs of numbers \(q_1, r_1\) and \(q_2, r_2\) with \(a = q_1b + r_1 = q_2b + r_2\) and with \(0 \leq r_i \lt b\). We want to show that \(q_1 = q_2\) and \(r_1 = r_2\).

Rearranging \(q_1b + r_1 = q_2b + r_2\), we see that \((q_1 - q_2)b = r_2 - r_1\). I claim that \(-b \lt r_2 - r_1 \lt b\), and the only multiple of \(b\) between \(-b\) and \(b\) is \(0\), so \(r_2 - r_1 = 0\).

To see this more carefully, we know \(0 \leq r_2 \lt b\). The same equation holds for \(r_1\); negating it yields \(-b \lt -r_1 \leq 0\). Adding these equations together gives \(-b \lt r_2 - r_1 \lt b\).

Therefore \(r_2 - r_1 = 0\), so \(r_2 = r_1\). Since \((q_1 - q_2)b = r_2 - r_1 = 0\) and since \(b \neq 0\), we have \(q_1 - q_2 = 0\), or \(q_1 = q_2\).