%! TEX root = NT.tex
% vim: tw=50
% 20/10/2023 10AM

\begin{example*}
  If $a = 3$, then for $p > 3$,
  \[ \mu = \# \left\{ b \in \ZZ ~\bigg|~ 0 < b <
  \frac{p}{2}, \gmod{3b} < 0 \right\} \]
  If $0 < b < \frac{p}{6}$, $0 < 3b <
  \frac{p}{2}$, so $\gmod{3b} = 3b > 0$. If
  $\frac{p}{6} < b \frac{p}{3}$, $\frac{p}{2}
  3b > p$, $-\frac{p}{2} < 3b - p < 0$, so
  $\gmod{3b} = 3b - p < 0$. If $\frac{p}{3} < b <
  \frac{p}{2}$, $p < 3b < \frac{3p}{2}$, $0 < 3b -
  p < \frac{p}{2}$, so $\gmod{3b} = 3b - p > 0$.
  So
  \[ \mu = \# \left\{ b \in \ZZ ~\bigg|~
  \frac{p}{2} < b < \frac{p}{3} \right\} \]
  In this case, $(-1)^\mu = \legendre{3}{p}$
  depends only on $p \bmod{12}$. In general, if $a
  \in \ZZ$, $p \nmid a$, $b \in \ZZ$, then there
  exists $c \in \ZZ$ such that $-\frac{p}{2} < ab
  - pc < \frac{p}{2}$. Then $\gmod{ab} = ab - pc$.
  So another way to express $\mu$ is
  \[ \mu = \# \left\{(b, c) \in \ZZ^2 ~\bigg|~ 0 < b <
  \frac{p}{2}, -\frac{p}{2} < ab - pc < 0
  \right\} .\]
\end{example*}

\begin{flashcard}[law-of-qr-thm]
\begin{theorem}[Law of Quadratic Reciprocity]
  \label{law_qr}
  \cloze{
  Let $p$, $q$ be distinct odd \glspl{prime}. Then
  \[ \legendre{p}{q} \legendre{q}{p}
  = (-1)^{\left( \frac{p - 1}{2} \right) \left(
  \frac{q - 1}{2} \right)} .\]
  Equivalently,
  \[ \legendre{p}{q} = \begin{cases}
    -\legendre{q}{p} & \text{if $p \equiv q \equiv
    3 \pmod{4}$} \\
    \legendre{q}{p} & \text{otherwise}
  \end{cases} \]
  }
\end{theorem}

\begin{proof}
  \cloze{
  We know $\legendre{q}{p} = (-1)^\mu$,
  \[ \mu = \# \left\{ (b, c) \in \ZZ^2 ~\bigg|~ 0
  < b < \frac{p}{2}, -\frac{p}{2} < qb - pc < 0
  \right\} .\]
  We know $\legendre{p}{q} = (-1)^\nu$,
  \begin{align*}
    \nu
    &= \# \left\{ (b, c) \in \ZZ^2 ~\bigg|~ 0 <
    b < \frac{q}{2}, -\frac{q}{2} < pb - qc < 0
    \right\} \\
    &= \# \left\{ (b, c) \in \ZZ^2 ~\bigg|~ 0 < c
    < \frac{q}{2}, 0 < qb - pc < \frac{q}{2} \right\} 
  \end{align*}
  Define
  \begin{align*}
    A
    &= \left\{ (b, c) \in \ZZ^2 ~\bigg|~ 0
    < b < \frac{p}{2}, -\frac{p}{2} < qb - pc < 0
    \right\} \\
    B
    &= \left\{ (b, c) \in \ZZ^2 ~\bigg|~ 0 < c
    < \frac{q}{2}, 0 < qb - pc < \frac{q}{2}
    \right\}
  \end{align*}
  (so $\munum = \# A$, $\nu = \# B$).

  \textbf{Claim:} $A$, $B$ are disjoint subsets of
  \[ S = \left\{ (b, c) \in \ZZ^2 ~\bigg|~ 0 < b <
  \frac{p}{2}, 0 < c < \frac{q}{2} \right\} .\]
  Why? $A \subset S$. We need to show $(b, c) \in
  A$ implies $0 < c < \frac{q}{2}$. We have $pc >
  qb > 0 \implies c > 0$, and
  \[ pc < qb + \frac{p}{2} < \frac{qp}{2} +
  \frac{p}{2} \implies c < \frac{q + 1}{2}
  \implies c < \frac{q}{2} \]
  (since $c \in \ZZ$, $q$ odd). Similarly, $B
  \subset S$. $A$, $B$ are disjoint because $qb -
  pc < 0$ in $A$, $qb - pc > 0$ in $B$.

  We have $\# S = \left( \frac{p - 1}{2} \right)
  \left( \frac{q - 1}{2} \right)$, so
  \begin{align*}
    \text{desired result}
    &\iff (-1)^{\#A + \#B} = (-1)^{\#S} \\
    &\iff \#(A \sqcup B) \equiv \# S \pmod{2} \\
    &\iff \# (S \setminus (A \cup B)) \text{ is
    even}
  \end{align*}
  Note
  \[ S \setminus (A \cup B) = \left\{ (b, c) \in S
  ~\bigg|~ qb - pc < -\frac{p}{2} \right\} \sqcup
  \left\{ (b, c) \in S ~\bigg|~ qb - pc >
  \frac{q}{2} \right\} \eqdef X \sqcup Y \]
  We'll show $\#X = \#Y$.

  Consider the map $\theta : S \to S$, $\theta(b,
  c) = \left( \frac{p + 1}{2} - b, \frac{q + 1}{2}
  - c \right)$. We have $\theta^2 = \id$, hence
  $\theta$ is surjective, hence bijective since
  $S$ is finite. To show $\#X = \#Y$, it's enough
  to show $\theta(X) = Y$. If $(b, c) \in S$, then
  $(b, c) \in X \iff qb - pc < -\frac{p}{2}$.
  \begin{align*}
    \theta(b, c) \in Y
    &\iff q \left( \frac{p + 1}{2} - b \right) - p
    \left( \frac{q + 1}{2} - c \right) >
    \frac{q}{2} \\
    &\iff \frac{q}{2} - qb - \frac{p}{2} + pc >
    \frac{q}{2} \\
    &\iff pc - qb > \frac{p}{2} \\
    &\iff (b, c) \in X \qedhere
  \end{align*}
  }
\end{proof}
\end{flashcard}

Picture of proof:
\begin{center}
  \includegraphics[width=0.6\linewidth]
  {images/e3091c106f2d11ee.png}
\end{center}
\[ A = \left\{ (b, c) \in S ~\bigg|~ -\frac{p}{2}
< qb - pc < 0 \right\} \]
\[ -\frac{p}{2} = qb - pc \iff c = \frac{q}{p}b +
\half \]

\begin{example*}
  Let $p \ge 5$. We determine $\legendre{3}{p}$
  using \nameref{law_qr}. We have
  \[ \legendre{3}{p} = \begin{cases}
    -\legendre{p}{3} & p \equiv 3 \pmod{4} \\
    \legendre{p}{3} & p \equiv \pmod{4}
  \end{cases} \]
  $\legendre{p}{3}$ only depends on $p$
  \gls{modulo}
  $3$. In particular
  \[ \legendre{p}{3} = \begin{cases}
    1 & p \equiv 1 \pmod{3} \\
    -1 & p \equiv -1 \pmod{3}
  \end{cases} \]
  We find
  \[ \legendre{3}{p} = \begin{cases}
    +1 & p \equiv \pm 1 \pmod{12} \\
    -1 & p \equiv \pm 5 \pmod{12}
  \end{cases} \]
\end{example*}

\begin{example*}
  Question: Does the equation $X^2 = 19$ have a
  \gls{eq_sol} in $\ZZ / 73\ZZ$? $73$ is \gls{prime}, so
  this happens if and only if $\legendre{19}{73} =
  1$. $19$ is also \gls{prime}, so this equals
  \[ \legendre{73}{19} = \legendre{16}{19} = +1 \]
  as $16$ is a square number (and using $73 = 3
  \times 19 + 6$).
\end{example*}

\begin{example*}
  \begin{align*}
    \legendre{34}{97}
    &= \legendre{2 \times 2}{97} \\
    &= \legendre{2}{97} \legendre{2}{97} \\
    &= \legendre{17}{97} \\
    &= \legendre{97}{17} \\
    &= \legendre{12}{17} \\
    &= \legendre{3}{17} \legendre{4}{17} \\
    &= \legendre{3}{17} \\
    &= -1
  \end{align*}
\end{example*}

\begin{example*}
  \[ \legendre{7411}{9283} = -
  \legendre{9283}{7411} = -\legendre{1872}{7411} =
  -\legendre{13}{7411} = -\legendre{7411}{13} =
  -\legendre{1}{13} = -1 \]
\end{example*}

To compute \glspl{leg_symb} without
\glsref[prime_factorisation]{factorising},
we can use the \gls{jac_symb}.

\begin{flashcard}[jacobi-symb-defn]
\begin{definition}[Jacobi Symbol]
  \glsnoundefn{jac_symb}{Jacobi symbol}{Jacobi
  symbols}
  \glssymboldefn{jac_symb}{Jacobi symbol}{(j)}
  \cloze{
  Let $N \in \NN$ be odd with
  \gls{prime_factorisation} $N = p_1 \cdots p_k$,
  noting that the $p_i$'s need not be distinct.
  Then for $a \in \ZZ$, we define the \emph{Jacobi
  symbol} as
  \[ \jacobi{a}{N} = \prod_{i = 1}^k
  \legendre{a}{p_i} \]
  where the right hand side is a product of
  \glspl{leg_symb}.
  }
\end{definition}
\end{flashcard}
