142 lines
4.3 KiB
TeX
Raw Normal View History

2023-05-03 11:15:35 -07:00
\section{Challenge Problems}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\problem{}
Prove \ref{mod_has_inverse}: \\
$a$ has an inverse mod $m$ iff $\gcd(a, m) = 1$ \\
\begin{hint}
To prove an iff statement, prove each direction separately: \\
Assume that the left side is true and show that left $\implies$ right, \\
then do the reverse.
\end{hint}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{solution}
Assume $a^\star$ is the inverse of $a \pmod{m}$. \\
Then $a^\star \times a \equiv 1 \pmod{m}$ \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
Therefore, $aa^\star - 1 = km$, and $aa^\star - km = 1$ \\
We know that $\gcd(a, m)$ divides $a$ and $m$, therefore $\gcd(a, m)$ must divide $1$. \\
$\gcd(a, m) = 1$ \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
Now, assume $\gcd(a, m) = 1$. \\
By the Extended Euclidean Algorithm, we can find $(u, v)$ that satisfy $au+mv=1$ \\
So, $au-1 = mv$. \\
$m$ divides $au-1$, so $au \equiv 1 \pmod{m}$ \\
$u$ is $a^\star$.
\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{}<eua_runtime>
The Euclidean Algorithm (From \ref{euclid_algorithm}) can be written as follows: \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
Assume $a > b$.
Set $e_0 = a$ and $e_1 = b$. \\
Let $e_{n+1} = \text{remainder}(r_{n-1} \div r_{n})$ \\
Stop when $e_{k} = 0$.
Then, $\gcd(a, b) = e_{k-1}$. \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
Let $F_n$ be the $n^{\text{th}}$ Fibonacci number. ($F_0 = 0$; $F_1 = 1$; $F_2 = 1$; $\dots$)\\
Show that if the Euclidean algorithm requires $n$ steps for an input $(a, b)$, then $a \geq F_{n+2}$ and $b \geq F_{n+1}$.
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
(In other words, show that the longest-running input of a given size is a Fibonacci pair.)
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{solution}
The easiest way to go about this is induction on $n$: \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\textcolor{gray}{\textit{Base Case:}}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
If $n = 1$, $b$ divides $a$ with no remainder, and the smallest possible $a, b$ for which this is true is $(2, 1) = (F_3, F_2)$.
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\linehack{}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\textcolor{gray}{\textit{Induction:}}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
Assume that for $n$ steps, $a \geq F_{n+2}$ and $b \geq F_{n+1}$.
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
Now, say the algorithm takes $n+1 = m$ steps. \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
The first step gives us $a = q_0b + r_0$ \\
Therefore, the pair $(b, r_0)$ must take $m-1$ steps. \\
We thus know that $b \geq F_{m+1}$ and $r_0 \geq F_m$ \hfill \textcolor{gray}{by our induction hypothesis} \\
Therefore, $a = q_0b + r_0 \geq b + r_0$ \\
But $b + r_0 = F_{m+1} + F_{m} = F_{m+2}$, \\
so $a \geq F_{m+2}$.
\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
2023-05-03 11:15:35 -07:00
\problem{Chinese Remainder Theorem}
There are certain things whose number is unknown. If we count them by threes, we have two left over; by fives, we have three left over; and by sevens, two are left over. How many things are there?
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{solution}
$x \equiv 2 \pmod{3}$ \\
$x \equiv 3 \pmod{5}$ \\
$x \equiv 2 \pmod{7}$ \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
$x = 23 + 105k\ \forall k \in \mathbb{Z}$
\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{}<flt_prereq>
Show that if $p$ is prime, $\binom{p}{i} \equiv 0 \pmod{p}$
for $0 < i < p$.
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{solution}
$\binom{p}{i} = \frac{p!}{i!(p-i)!}$ tells us that $i!(p-i)!$ divides $p! = p(p-1)!$. \\
However, $i!(p-i)!$ and $p$ are coprime, since all factors of $i!(p-i)!$ are smaller than $p$. \\
Therefore, $i!(p-i)!$ must divide $(p-1)!$ \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
So, $\binom{p}{i} = p \times \frac{(p-1)!}{i!(p-i)!}$, and $\binom{p}{i} \equiv 0 \pmod{p}$.
\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{Fermat's Little Theorem}
Show that if $p$ is prime and $a \not\equiv 0 \pmod{p}$, then $a^{p-1} \equiv 1 \pmod{p}$. \\
You may want to use \ref{flt_prereq}.
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{hint}
It may be easier to show that $a^p \equiv a \pmod{p}$
\end{hint}
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
\begin{solution}
Use induction:
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
$1 \equiv 1 \pmod{p}$ \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
Using \ref{flt_prereq} and the binomial theorem, we have
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
$2^p = (1 + 1)^p = 1 + \binom{p}{1} + \binom{p}{2} + \dots + \binom{p}{p-1} + 1 \equiv 1 + 0 + ... + 0 + 1 \equiv 2 \pmod{p}$ \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
Then,
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
$3^p = (1 + 2)^p = 1 + \binom{p}{1}2 + \binom{p}{2}2^2 + \dots + \binom{p}{p-1}2^{p-1} + 2^p \equiv 1 + 0 + ... + 0 + 2 \equiv 3 \pmod{p}$ \\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
We can repeat this for all $a$. This proof can be presented more formally with a bit of induction.
2022-11-13 13:02:25 -08:00
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
%\problem{}
%Prove \ref{theorem:gcd_abc}: \\
%For any integers $a, b, c$, \\
%$\gcd(ac + b, a) = \gcd(a, b)$\\
2022-11-13 13:02:25 -08:00
2023-05-03 11:15:35 -07:00
%\begin{solution}
% This problem is hard, \\
% I'll write a solution eventually.
%\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
[Note on \ref{eua_runtime}] This proof can be used to show that the Euclidean algorithm finishes in logarithmic time, and it is the first practical application of the Fibonacci numbers. If you have finished all challenge problems, finish the proof: show that the Euclidean runs in $O(\log{n})$
\pagebreak