2023-08-16 11:36:49 -07:00
|
|
|
\section{The Euclidean Algorithm}
|
|
|
|
|
2023-05-03 11:15:35 -07:00
|
|
|
\definition{}
|
2023-08-16 11:36:49 -07:00
|
|
|
The \textit{greatest common divisor} of $a$ and $b$ is the greatest integer that divides both $a$ and $b$. \par
|
2023-05-03 11:15:35 -07:00
|
|
|
We denote this number with $\gcd(a, b)$. For example, $\gcd(45, 60) = 15$.
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
Find $\gcd(20, 14)$ by hand.
|
2022-11-13 13:02:25 -08:00
|
|
|
|
2023-05-03 11:15:35 -07:00
|
|
|
\begin{solution}
|
|
|
|
$\gcd(20, 14) = 2$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
2023-08-30 15:27:07 -07:00
|
|
|
\theorem{The Division Algorithm}<divalgo>
|
2023-08-16 11:36:49 -07:00
|
|
|
Given two integers $a, b$, we can find two integers $q, r$, where $0 \leq r < b$ and $a = qb + r$. \par
|
|
|
|
In other words, we can divide $a$ by $b$ to get $q$ remainder $r$.
|
|
|
|
|
|
|
|
\theorem{}<gcd_abc>
|
|
|
|
For any integers $a, b, c$, \par
|
|
|
|
$\gcd(ac + b, a) = \gcd(a, b)$
|
|
|
|
|
2024-10-17 21:09:13 -07:00
|
|
|
\problem{}
|
|
|
|
Compute the gcd of 12 and 976.
|
|
|
|
\begin{solution}
|
|
|
|
$976 = 3 \times 324 + 4 = 3 \times 4 \times 81 + 4$
|
|
|
|
So, $\gcd(a, b) = 4$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
2023-08-16 11:36:49 -07:00
|
|
|
\problem{The Euclidean Algorithm}<euclid>
|
|
|
|
Using the two theorems above, detail an algorithm for finding $\gcd(a, b)$. \par
|
|
|
|
Then, compute $\gcd(1610, 207)$ by hand. \par
|
2023-05-03 11:15:35 -07:00
|
|
|
|
|
|
|
\begin{solution}
|
2023-12-09 18:17:22 -08:00
|
|
|
Using \ref{gcd_abc} and the division algorithm,
|
2023-05-03 11:15:35 -07:00
|
|
|
|
|
|
|
% Minipage prevents column breaks inside body
|
|
|
|
\begin{multicols}{2}
|
|
|
|
\begin{minipage}{\columnwidth}
|
|
|
|
$\gcd(1610, 207)$ \par
|
|
|
|
$= \gcd(207, 161)$ \par
|
|
|
|
$= \gcd(161, 46)$ \par
|
|
|
|
$= \gcd(46, 23)$ \par
|
|
|
|
$= \gcd(23, 0) = 23$ \par
|
|
|
|
\end{minipage}
|
|
|
|
|
|
|
|
\columnbreak
|
|
|
|
|
|
|
|
\begin{minipage}{\columnwidth}
|
|
|
|
$1610 = 207 \times 7 + 161$ \par
|
|
|
|
$207 = 161 \times 1 + 46$ \par
|
|
|
|
$161 = 46 \times 3 + 23$ \par
|
|
|
|
$46 = 23 \times 2 + 0$ \par
|
|
|
|
\end{minipage}
|
|
|
|
\end{multicols}
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
\pagebreak
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-16 11:36:49 -07:00
|
|
|
\problem{}<extendedeuclid>
|
2023-05-03 11:15:35 -07:00
|
|
|
Using the output of the Euclidean algorithm,
|
|
|
|
|
|
|
|
\begin{itemize}
|
|
|
|
\item[-] find a pair $(u, v)$ that satisfies $20u + 14v = \gcd(20, 14)$
|
2023-08-16 11:36:49 -07:00
|
|
|
\item[-] find a pair $(u, v)$ that satisfies $541u + 34v = \gcd(541, 34)$
|
2023-05-03 11:15:35 -07:00
|
|
|
% gcd = 1
|
|
|
|
% u = 11; v = -175
|
|
|
|
\end{itemize}
|
2023-08-30 15:27:07 -07:00
|
|
|
This is called the \textit{extended Euclidean algorithm}. \par
|
|
|
|
\hint{
|
|
|
|
You don't need to fully solve the last part of this question. \\
|
|
|
|
Understand how you \textit{would} do it, then move on.
|
|
|
|
Don't spend too much time on arithmetic.
|
|
|
|
}
|
2023-08-16 11:36:49 -07:00
|
|
|
|
|
|
|
%For which numbers $c$ can we find a $(u, v)$ so that $541u + 34v = c$? \\
|
|
|
|
%For every such $c$, what are $u$ and $v$?
|
|
|
|
|
|
|
|
\vspace{2mm}
|
|
|
|
|
|
|
|
\textbf{Hint:}
|
|
|
|
|
|
|
|
After running the Euclidean algorithm, you have a table similar to the one shown below. \par
|
|
|
|
You can use a bit of algebra to rearrange these statements to get what you need. \par
|
|
|
|
|
|
|
|
\vspace{5mm}
|
|
|
|
|
|
|
|
\newdimen\mywidth
|
|
|
|
\setbox0=\hbox{Using the Euclidean Algorithm to find that $\gcd(20, 14) = 2$:}
|
|
|
|
\mywidth=\wd0
|
|
|
|
\begin{minipage}{\mywidth}
|
|
|
|
\begin{center}
|
|
|
|
Using the Euclidean Algorithm to find that $\gcd(20, 14) = 2$: \par
|
|
|
|
$20 = 14 \times 1 + 6$ \par
|
|
|
|
$14 = 6 \times 2 + 2$ \par
|
|
|
|
$6 = 2 \times 3 + 0$ \par
|
|
|
|
\end{center}
|
|
|
|
\end{minipage}\par
|
|
|
|
\vspace{2mm}
|
|
|
|
We now want to write the 2 in the last equation in terms of 20 and 14.
|
|
|
|
|
|
|
|
|
2023-05-03 11:15:35 -07:00
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
|
|
|
|
Using the output of the Euclidean Algorithm, we can use substitution and a bit of algebra to solve such problems. Consider the following example:
|
|
|
|
|
|
|
|
\begin{multicols}{2}
|
|
|
|
\begin{minipage}{\columnwidth}
|
|
|
|
\textit{Euclidean Algorithm:} \par
|
|
|
|
$20 = 14 \times 1 + 6$ \par
|
|
|
|
$14 = 6 \times 2 + 2$ \par
|
|
|
|
$6 = 2 \times 3 + 0$ \par
|
|
|
|
\end{minipage}
|
|
|
|
|
|
|
|
\columnbreak
|
|
|
|
|
|
|
|
\begin{minipage}{\columnwidth}
|
|
|
|
\textit{Rearranged:} \par
|
|
|
|
$6 = 20 - 14 \times 1$ \par
|
|
|
|
$2 = 14 - 6 \times 2 = \gcd(20, 14)$ \par
|
|
|
|
\end{minipage}
|
|
|
|
\end{multicols}
|
|
|
|
|
|
|
|
Using the right table, we can replace $6$ in $2 = 14 - 6 \times 2$ to get
|
2023-08-16 11:36:49 -07:00
|
|
|
$2 = 14 - (20 - 14) \times 2$, \par
|
|
|
|
which gives us $2 = \gcd(20, 14) = (3)14 + (-2)20$. \par
|
2023-05-03 11:15:35 -07:00
|
|
|
|
|
|
|
\linehack{}
|
|
|
|
|
2023-08-16 11:36:49 -07:00
|
|
|
$\gcd(20, 14) = 20(-2) + 14(3)$ \par
|
|
|
|
$\gcd(541, 34) = 541(11) + 34(-175)$
|
2023-05-03 11:15:35 -07:00
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
\pagebreak
|
2022-11-13 13:02:25 -08:00
|
|
|
|