3.1: The Euclidean Algorithm
- Page ID
- 60308
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)Lemma 3.1
In the division algorithm of Definition2.4, we have \(\gcd(r_{1},r_{2}) = \gcd(r_{2}, r_{3})\).
- Proof
-
On the one hand, we have \(r_{1} = r_{2}q_{2}+r_{3}\), and so any common divisor of \(r_{2}\) and \(r_{3}\) must also be a divisor of \(r_{1}\) (and of \(r_{2}\)). Vice versa, since \(r_{1}-r_{2}q_{2} = r_{3}\), we have that any common divisor of \(r_{1}\) and \(r_{2}\) must also be a divisor of \(r_{3}\) (and of \(r_{2}\)).
Thus by calculating \(r_{3}\), the residue of \(r_{1}\) modulo \(r_{2}\), we have simplified the computation of \(\gcd (r_{1}, r_{2})\). This is because \(r_{3}\) is strictly smaller (in absolute value) than both \(r_{1}\) and \(r_{2}\). In turn, the computation of \(\gcd (r_{2}, r_{3})\) can be simplified similarly, and so the process can be repeated. Since the \(r_{i}\) form a monotone decreasing sequence in \(\mathbb{N}\), this process must end when \(r_{n}+1 = 0\) after a finite number of steps. We then have \(gcd(r_{1},r_{2}) = gcd(r_{n},0) = r_{n}\).
Corollary 3.2
Given \(r_{1} > r_{2} > 0\), apply the division algorithm until \(r_{n} > r_{n+1} = 0\). Then \(\gcd (r_{1}, r_{2}) = \gcd(r_{n}, 0) = r_{n}\). Since \(r_{i}\) is decreasing, the algorithm always ends.
Definition 3.3
The repeated application of the division algorithm to compute \(\gcd(r_{1}, r_{2})\) is called the Euclidean algorithm.
We now give a framework to reduce the messiness of these repeated computations. Suppose we want to compute \(\gcd(188, 158)\). We do the following computations:
\[188 = 158·1+30 \nonumber\]
\[158 = 30·5+8 \nonumber\]
\[30 = 8·3+6 \nonumber\]
\[8 = 6·1+2 \nonumber\]
\[6 = 2·3+0 \nonumber\]
We see that \(\gcd(188,158) = 2\). The numbers that multiply the \(r_{i}\) are the quotients of the division algorithm (see the proof of Lemma 2.3). If we call them \(q_{i-1}\), the computation looks as follows:
\[\begin{array} {c} {r_{1} = r_{2} q_{2}+r_{3}}\\ {r_{2} = r_{3} q_{3}+r_{4}}\\ {\vdots}\\ {r_{n-3} = r_{n-2} q_{n-2}+r_{n-3}}\\ {r_{n-2} = r_{n-1} q_{n-1}+r_{n-2}}\\ {r_{n-1} = r_{n} q_{n}+0} \end{array}\]
where we use the convention that \(r_{n+1} = 0\) while \(r_{n} \ne 0\). Observe that with that convention, (3.1) consists of \(n-1\) steps. A much more concise form (in part based on a suggestion of Katahdin [16]) to render this computation is as follows.
Thus, each step \(r_{i+1} |r_{i}|\) is similar to the usual long division, except that its quotient \(q_{i+1}\) is placed above \(r_{i+1}\) (and not above \(r_{i}\)), while its remainder \(r_{i+2}\) is placed all the way to the left of of \(r_{i+1}\). The example we worked out before now it looks like:
There is a beautiful visualization of this process outlined in exercise 3.4.