66 lines
1.9 KiB
TeX
Raw Normal View History

2023-05-03 11:15:35 -07:00
\section{Modular Arithmetic}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\definition{}
We say that $a, b$ are equivalent mod $m$ if $m$ divides $a - b$. \\
If $a$ is equivalent to $b$ mod $m$, we write $a \equiv b \pmod{m}$. \\
You can think of $b$ as the remainder of $a \div m$:
\begin{itemize}
\item[] $32 \equiv 2 \pmod{6}$
\item[] $4 \equiv 4 \pmod{6}$
\item[] $-2 \equiv 4 \pmod{6}$
\end{itemize}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\problem{}
Complete the following:
\begin{itemize}
\item[] $87 \equiv ? \pmod{12}$ \hspace{3em} \textcolor{gray}{(Your answer should be between $0$ and $12$)}
\item[] $13 \equiv 2 \pmod{?}$
\item[] $? \equiv 1 \pmod{9}$
\end{itemize}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{solution}
2022-11-13 13:02:25 -08:00
\begin{itemize}
2023-05-03 11:15:35 -07:00
\item[] $87 \equiv 3 \pmod{12}$
\item[] $13 \equiv 2 \pmod{11}$
\item[] $(9k + 1) \equiv 1 \pmod{9}\ \forall k \in \mathbb{Z}$
2022-11-13 13:02:25 -08:00
\end{itemize}
2023-05-03 11:15:35 -07:00
\end{solution}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\vfill
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\definition{}
The inverse of $a$ mod $m$ is an integer $a^\star$ so that \\
$a \times a^\star \equiv 1 \pmod{m}$. \\
Note that not every $a$ has an inverse mod $m$.
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\theorem{}<mod_has_inverse>
$a$ has an inverse mod $m$ iff $\gcd(a, m) = 1$ \\
\textcolor{gray}{\textit{The proof of this theorem is left as a challenge problem.}}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\problem{D\'ej\`a vu?}<find_inverse>
Find the inverse of $20 \pmod{14}$, if one exists. \\
Find the inverse of $34 \pmod{541}$, if one exists.
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{solution}
$20^\star$ does not exist mod $14$, by \ref{mod_has_inverse}. \\
$34^\star \equiv -175 \equiv 366 \pmod{541}$.
See \ref{general_inverse} for an explanation.
\end{solution}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\vfill
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\problem{}<general_inverse>
In general, how can we find the inverse of $a \pmod{p}$?\\
(Assume $p$ is prime.)
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{solution}
We need an $a^\star$ so that $a \times a^\star \equiv 1 \pmod{m}$. \\
This means that $aa^\star - mk = 1$. \\
Since $p$ is prime, $\gcd(a, m) = 1$, and $aa^\star - mk = \gcd(a, m)$ \\
Now use the Extended Euclidean Algorithm from \ref{extend_e_algorithm} to find $a^\star$.
\end{solution}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\vfill
\pagebreak
2022-11-13 13:02:25 -08:00