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

\begin{remark*}
  If $\gcdbrack (a, N) > 1$, then $\jacobi{a}{N} =
  0$, as if $p \divides \gcdbrack (a, N)$ then
  $\jacobi{a}{p} = 0$. If $N$ is \gls{prime}, then
  $\jacobi{a}{N}$ is well-defined (because
  \gls{jac_symb} equals the \gls{leg_symb}).
\end{remark*}

\begin{example*}
  \[ \jacobi{1}{15} = \jacobi{1}{3} \jacobi{1}{5}
  = 1 \qquad \jacobi{2}{15} = \jacobi{2}{3}
  \jacobi{2}{5} = -1 \times -1 = 1 \]
\end{example*}

\begin{warning*}
  The \gls{jac_symb} does not tell you whether $a$
  is a square \gls{modulo} $N$ (except when $N$ is
  \gls{prime}). For example, $2$ is not a square
  \gls{modulo} $15$ (since it isn't a square
  \gls{modulo} $3$), but as seen in the
  previous example, $\jacobi{2}{15} = 1$.

  If $N = pq$, where $p$ and $q$ are distinct odd
  \glspl{prime}, then $a \bmod pq$ is a square if
  and only if $a \bmod p$ is a square and $a \bmod
  q$ is a square, which happens if and only if
  $\legendre{a}{p} = \legendre{a}{q} = 1$.

  But we have $\jacobi{a}{N} = \legendre{a}{p}
  \legendre{a}{q} = 1$, which happens if and only
  if either $\legendre{a}{p} = \legendre{a}{q} =
  1$ \emph{or} $\legendre{a}{p} = \legendre{a}{q}
  = -1$.
\end{warning*}
\vspace{-1em}

In general, to decide is $a \bmod{N}$ is a square,
we need to factorise $N$.

\begin{flashcard}[jacobi-formulae-lemma]
\begin{lemma}[Jacobi formulae]
  Let $M, N \in \NN$ be odd, $a, b \in \ZZ$. Then:
  \begin{enumerate}[(1)]
    \item \cloze{If $a \equiv b \pmod{N}$, then
      $\jacobi{a}{N} = \jacobi{b}{N}$.}
    \item \cloze{$\jacobi{ab}{N} = \jacobi{a}{N}
      \jacobi{b}{N}$.}
    \item \cloze{$\jacobi{a}{MN} = \jacobi{a}{M}
      \jacobi{a}{N}$.}
  \end{enumerate}
\end{lemma}

\begin{proof}
  \phantom{}
  \begin{enumerate}[(1)]
    \item \cloze{If $N = p_1 \cdots p_r$, then
      \[ \jacobi{a}{N} = \prod_{i = 1}^r
      \legendre{a}{p_i} \]
      If $a \equiv b \pmod{N}$, then $a \equiv b
      \pmod{p} ~\forall p \divides N$. If $p
      \divides N$
      is \gls{prime}, then $\legendre{a}{p}$ only
      depends on $a \bmod{p}$. So indeed
      \[ \jacobi{a}{N} = \jacobi{b}{N} \]
      if $a \equiv b \pmod{N}$.}
    \item \cloze{
      \[ \jacobi{ab}{N} = \prod_{i = 1}^r
      \legendre{ab}{p_i} = \prod_{i = 1}^r
      \legendre{a}{p_i}\legendre{b}{p_i}
      = \jacobi{a}{N} \jacobi{b}{N} .\]
      }
    \item \cloze{If $N = p_1 \cdots p_r$, $M = q_1
      \cdots q_s$, then $NM = p_1 \cdots p_r q_1
      \cdots q_s$, so}
      \[ \cloze{\jacobi{a}{MN} = \left( \prod_{i =
      1}^r \legendre{a}{p_i} \right) \left(
      \prod_{j = 1}^s \legendre{a}{q_j} \right) =
      \jacobi{a}{M} \jacobi{a}{N}} \qedhere \]
  \end{enumerate}
\end{proof}
\end{flashcard}

\begin{flashcard}[jacobi-1-2-formulae-prop]
\begin{proposition}
  If $N \in \NN$ is odd, then
  \begin{align*}
    \jacobi{-1}{N} 
    &= \cloze{(-1)^{\frac{N - 1}{2}} =
    \begin{cases}
      1 & N \equiv \pmod{4} \\
      -1 & N \equiv 3 \pmod{4}
    \end{cases}} \\
    \jacobi{2}{N}
    &= \cloze{(-1)^{\frac{N^2 - 1}{8}}
    = \begin{cases}
      1 & N \equiv \pm 1 \pmod{8} \\
      -1 & N \equiv \pm 5 \pmod{8}
    \end{cases}}
  \end{align*}
\end{proposition}

\begin{proof}
  \cloze{
  If $N = p_1 \cdots p_r$, then
  \[ \jacobi{-1}{N} = \prod_{i = 1}^r
  \legendre{-1}{p_i} = \prod_{i = 1}^r
  (-1)^{\frac{p_i - 1}{2}} \]
  We need to show that if $a, b \in \ZZ$ are odd,
  then $(-1)^{\frac{a - 1}{2}} (-1)^{\frac{b -
  1}{2}} = (-1)^{\frac{ab - 1}{2}}$. We have:
  \begin{align*}
    2 \divides a - 1, 2 \divides b - 1
    &\implies (a - 1)(b - 1) \equiv 0 \pmod{4} \\
    &\implies ab - a - b + 1 \equiv 0 \pmod{4} \\
    &\equiv ab - 1 \equiv (a - 1) + (b - 1)
    \pmod{4} \\
    &\implies \frac{ab - 1}{2} \equiv \frac{a -
    1}{2} + \frac{b - 1}{2} \pmod{2} \\
    &\implies (-1)^{\frac{ab - 1}{2}} =
    (-1)^{\frac{a - 1}{2}} \cdot (-1)^{\frac{b -
    1}{2}}
  \end{align*}
  Similarly, we compute
  \[ \jacobi{2}{N} = \prod_{i = 1}^r
  \legendre{2}{p_i} = \prod_{i = 1}^r
  (-1)^{\frac{p_i^2 - 1}{8}} \]
  We need to check that if $a, b \in \ZZ$ are odd,
  then $(-1)^{\frac{a^2 - 1}{8}} \cdot
  (-1)^{\frac{b^2 - 1}{8}} = (-1)^{\frac{(ab)^2 -
  1}{8}}$. We have
  \begin{align*}
    a^2 \equiv 1 \pmod{4}, b^2 \equiv 1 \pmod{4}
    &\implies (a^2 - 1)(b^2 - 1) \equiv 0
    \pmod{16} \\
    &\implies a^2 b^2 - 1 \equiv (a^2 - 1) + (b^2
    - 1) \pmod{16} \\
    &\implies \frac{(ab)^2 - 1}{8} \equiv
    \frac{a^2 - 1}{8} + \frac{b^2 - 1}{8} \pmod{2}
    \qedhere
  \end{align*}
  }
\end{proof}
\end{flashcard}

\begin{flashcard}[qr-jacobi-thm]
\begin{theorem}[Quadratic Reciprocity for Jacobi
  symbols]
  \label{law_qr_jac}
  \cloze{
  Let $M, N \in \NN$ be odd. Then
  \[ \jacobi{M}{N} = \jacobi{N}{M} \cdot
  (-1)^{\left( \frac{M - 1}{2} \right) \left(
  \frac{N - 1}{2} \right)} \]
  If $\gcdbrack (M, N) = 1$, then
  \[ \jacobi{M}{N} \jacobi{N}{M} =
  (-1)^{\left( \frac{M - 1}{2} \right) \left(
  \frac{N - 1}{2} \right)} .\]
  }
\end{theorem}

\begin{proof}
  \cloze{Factorise $M = q_1 \cdots q_s$, $N = p_1
  \cdots p_r$. Let $k = \#\{j \st q_j \equiv 3
  \pmod{4}\}$, $l = \#\{i \st p_i \equiv 3
  \pmod{4}\}$. We can assume $M$ and $N$ are
  \gls{coprime} (since if they have a common
  factor, the \glspl{jac_symb} will both be
  zero). Then
  \begin{align*}
    \jacobi{M}{N}
    &= \prod_{i = 1}^r \legendre{M}{p_i} \\
    &= \prod_{i = 1}^r \prod_{j = 1}^s
    \legendre{q_j}{p_i} \\
    &= (-1)^{kl} \prod_{i = 1}^r \prod_{j = 1}^s
    \legendre{p_i}{q_j} \\
    &= (-1)^{kl} \jacobi{N}{M}
  \end{align*}
  We need to show $(-1)^{kl} = (-1)^{\left(
  \frac{M - 1}{2} \right) \left( \frac{N - 1}{2}
  \right)}$. We know $M \equiv 3 \pmod{4}$ if and
  only if $k$ is odd. Similarly, $N \equiv 3
  \pmod{4}$ if and only if $l$ is odd. So:
  \begin{align*}
    \RHS \text{ is $-1$}
    &\iff M, N \equiv 3 \pmod{4} \\
    &\iff \text{both $k$ and $l$ are odd} \\
    &\iff \text{$kl$ is odd} \\
    &\iff (-1)^{kl} = -1 \qedhere
  \end{align*}
  }
\end{proof}
\end{flashcard}

\begin{example*}
  We can use the \gls{jac_symb} to compute
  \glspl{leg_symb} without factoring. For example:
  \[ \jacobi{33}{73} = \jacobi{73}{33} =
  \jacobi{7}{33} = \jacobi{33}{7} = \jacobi{5}{7}
  \jacobi{7}{5} = \jacobi{2}{5} = - 1 .\]
  Another example (using the above, noting that we
  first
  factor out the $2$ because \nameref{law_qr_jac}
  requires both numbers to be odd):
  \[ \jacobi{66}{73} = \jacobi{2}{73}
  \jacobi{33}{73} = -1 .\]
\end{example*}

\newpage
\section{Binary Quadratic Forms}

\begin{theorem}[Fermat-Euler]
  If $N \in \NN$, then we can write $N = x^2 +
  y^2$, $x, y \in \ZZ$ if and only if for every
  \gls{prime} number $p$ such that $p \divides N$
  and $p \equiv 3 \pmod{4}$, then $p$
  divides $N$
  an even number of times.

  In particular, if $q$ is an odd \gls{prime},
  then $Q = x^2 + y^2 \iff q \equiv \pmod{4}$.
\end{theorem}
\vspace{-1em}

In \courseref{GRM}, this is proved using unique
factorisation in $\ZZ[i]$.

Here, we will develop a general theory that
applies to $x^2 + y^2$ (an example of a
\gls{bqf}) and also to $x^2 + 2y^2$, $x^2 +
3y^2$, \ldots.
