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

Motivating question: Which integers can be
expressed as $x^2 + y^2$, $x^2 + 2y^2$?

\begin{flashcard}[bqf-defn]
\begin{definition}[BQF]
  \glsnoundefn{bqform}{binary quadratic form}{binary
  quadratic forms}
  \glsnoundefn[bqform]{bqf}{BQF}{BQFs}
  \cloze{
  A \emph{binary quadratic form} (BQF) is a
  polynomial $f(x, y) = ax^2 + bxy + cy^2$ where
  $a, b, c \in \ZZ$.

  \glsverbdefn{bqf_rep}{represent}{\gls{bqform}}
  If $N \in \ZZ$, we say $f$ \emph{represents} $N$
  if $\exists m, n \in \ZZ$ such that $f(m, n) =
  N$.
  }
\end{definition}
\end{flashcard}

\begin{notation*}
  \glssymboldefn{bqf_brack}{(a, b, c)}{(a, b, c)}
  \glssymboldefn{bqf_matrix}{(a, b/2, b/2, c)}{(a,
  b/2, b/2, c)}
  We will sometimes identify $f$ with the tuple
  $(a, b, c)$, or with the matrix
  \[
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  \]
  This is because we can write
  \[ f(x, y) =
  \begin{pmatrix}
    x & y
  \end{pmatrix}
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  \begin{pmatrix}
    x \\
    y
  \end{pmatrix}
  \]
\end{notation*}

\begin{example*}
  \[ f(x, y) = x^2 + y^2 \leftrightarrow (1, 0,
  1) \leftrightarrow
  \begin{pmatrix}
    1 & 0 \\
    0 & 1
  \end{pmatrix}
  \]
  \[ g(x, y) = 4x^2 + 12xy + 10y^2 \leftrightarrow
  \bqfb(4, 12, 0) \leftrightarrow
  \begin{pmatrix}
    4 & 6 \\
    6 & 10
  \end{pmatrix}
  \]
\end{example*}
\vspace{-1em}

Key idea: study the effect on \glspl{bqform} of
changes of variable.

Using the functions as in the example above, we have
\[ g(x, y) = (2x + 5y)^2 + y^2 = f(2x + 3y , y) .\]
However, $f$ and $g$ do not represent the same
sets of integers (as e.g. $g$ can only represent
event integers wheres $f$ represents $1$).

\begin{flashcard}[unimodular-change-of-variables-defn]
\begin{definition}[Unimodular change of variables]
  \glsnoundefn{unimod_cv}{unimdular change of
  variables}{unimodular changes of variables}
  \glsadjdefn{equiv_bqf}{equivalent}{\gls{bqform}}
  \glsnoundefn[equiv_bqf]{bqf_equiv_class}{equivalence
  class}{equivalence classes}
  \phantom{}
  \begin{enumerate}[(1)]
    \item \cloze{A unimodular change of variables
      is one of the form $X = \alpha x + \gamma y$,
      $Y = \beta x + \delta y$, where $\alpha,
      \beta, \gamma, \delta \in \ZZ$ with $\alpha
      \delta - \beta \gamma = 1$.}
    \item \cloze{We say that two \glspl{bqf} $f(x,
      y)$, $g(x, y)$ are \emph{equivalent} if
      there exists a \gls{unimod_cv}
      such that $g(x, y) = f(X, Y) =
      f(\alpha x + \gamma y, \beta x + \delta y)$.
      Equivalently, if there exists $A \in
      \SL_2(\ZZ)$ such that $g(x, y) = f((x,
      y)A)$.}
  \end{enumerate}
\end{definition}
\end{flashcard}

\begin{remark*}
  $X = 2x + 3y$, $Y = y$ is \emph{not}
  aunimodular change of variables, since
  \[ \det
  \begin{pmatrix}
    2 & 0 \\
    3 & 1
  \end{pmatrix}
  = 2 \neq 1 .\]
  \glsref[equiv_bqf]{Equivalence} of \glspl{bqf} is an equivalence
  relation. This is because $\SL_2(\ZZ)$ is a
  group (so for example, symmetry comes from the
  fact that inverses exist). 

  $\SL_2(\ZZ)$ acts on the set of \glspl{bqf} via
  $(A \cdot f)(x, y) = f((x, y)A)$. Two forms $f$
  and $g$ are \gls{equiv_bqf} if and only if
  they're in the same $\SL_2(\ZZ)$-orbit.

  If $f, g$ are \gls{equiv_bqf} \gls{bqform}, then
  they \gls{bqf_rep} the same sets of integers.
  This is because by symmetry, we need to show
  that if $g(x, y) = f(\alpha x + \gamma y, \beta
  x + \delta y)$, and $g$
  \glsref[bqf_rep]{represents} $N$, then $f$ also
  \glsref[bqf_rep]{represents} $N$.
\end{remark*}

\begin{flashcard}[bqf-discriminant-defn]
\begin{definition}[\gls{bqf} discriminant]
  \glsadjdefn{disc_bqf}{discriminant}{\gls{bqform}}
  \glssymboldefn{disc_bqf}{disc}{disc}
  \cloze{
  The \emph{discriminant} of a \gls{bqform} $f =
  \bqfb(a, b, c)$ is
  \[ \disc f = b^2 - 4ac .\]
  }
\end{definition}
\end{flashcard}

\begin{flashcard}[equiv-bqf-same-disc-lemma]
\begin{lemma}
  \Gls{equiv_bqf} \glsref[bqf]{forms} have the
  same \gls{disc_bqf}.
\end{lemma}

\begin{proof}
  \cloze{
  We need to check that $\disc f = \disc (A \cdot
  f)$ if $f = \bqfb(a, b, c)$, $A \in \SL_2(\ZZ)$. If
  $f = \bqfb(a, b, c)$, then
  \[ f \leftrightarrow
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  \]
  which has determinant $ac - \frac{b^2}{4} =
  -\quarter \disc f$. We have
  \[ f(x, y) = (x, y)
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  \]
  \[ (A \cdot f) (x, y) = f((x, y) A) = (x, y) A
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  \]
  so
  \[ A \cdot f \leftrightarrow A
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  A^\top \]
  Therefore
  \[ \det \left( A
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  A^\top \right) = \det(A) \det
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  \det (A)
  = \det
  \begin{pmatrix}
    a & \frac{b}{2} \\
    \frac{b}{2} & c
  \end{pmatrix}
  \qedhere \]
  }
\end{proof} 
\end{flashcard}

\begin{remark*}
  Converse does not hold: $x^2 + 6y^2$, $2x^2 +
  3y^2$ have the same \gls{disc_bqf} ($-24$), but not
  \gls{equiv_bqf} as they do not \gls{bqf_rep} the same
  integers (the first \glsref[bqf]{form}
  \glsref[bqf_rep]{represents} $1$, whereas the second does not).
\end{remark*}

\begin{lemma}
  % Lemma 3.6
  Let $d \in \ZZ$. Then there exist \glspl{bqf} of
  \gls{disc_bqf} $d$ if and only if $d \equiv 0
  \text{ or } 1 \pmod{4}$.
\end{lemma}

\begin{proof}
  If $d = \disc f$, $f = \bqfb (a, b, c)$, then $d
  = b^2 - 4ac \equiv b^2 \pmod{4}$. So must be $0$
  or $1$ \gls{modulo} $4$.

  If $d \equiv 0 \pmod{4}$, then $x^2 -
  \frac{d}{4} y^2$ is a \gls{bqf} of
  \gls{disc_bqf} $d$.

  If $d \equiv 1 \pmod{4}$, then $x^2 + xy +
  \frac{1 - d}{4} y^2$ is a \gls{bqf} of
  \gls{disc_bqf} $d$.
\end{proof}

\begin{flashcard}[pdbfq-defn]
\begin{definition}
  Let $f(x_1, \ldots, x_n) = \sum_{i \le j} a_{ij}
  x_i x_j$ be a (real) quadratic form, $a_{ij} \in
  \RR$. We say $f$ is:
  \glsadjdefn{pos_def}{positive
  definite}{quadratic form}
  \glsadjdefn{neg_def}{negative
  definite}{quadratic form}
  \glsadjdefn{indef}{indefinite}{quadratic form}
  \begin{itemize}
    \item \emph{positive definite} \cloze{if $\forall
      \mathbf{v} \in \RR^n - \{0\}$,
      $f(\mathbf{v}) > 0$.}
    \item \emph{negative definite} \cloze{if $\forall
      \mathbf{v} \in \RR^n - \{0\}$,
      $f(\mathbf{v}) < 0$.}
    \item \emph{indefinite} \cloze{if $\exists
      \mathbf{v}, \mathbf{w} \in \RR^n$ such that
      $f(\mathbf{v}) > 0$, $f(\mathbf{w}) < 0$.}
  \end{itemize}
\end{definition}
\end{flashcard}

\begin{proposition}
  Let $f(x, y) = ax^2 + bxy + cy^2$ be a \gls{bqf}
  of \gls{disc_bqf} $d \in \ZZ$. Then:
  \begin{enumerate}[(1)]
    \item If $d < 0$, $a > 0$, then $f$ is
      \gls{pos_def}. If $d < 0$, $a > 0$, $f$ is
      \gls{neg_def}.
    \item If $d > 0$, $f$ is \gls{indef}.
    \item If $d = 0$, then $\exists l, m, n \in
      \ZZ$ such that $f(x, y) = l(mx + ny)^2$.
  \end{enumerate}
\end{proposition}

\begin{proof}
  \phantom{}
  \begin{enumerate}[(1)]
    \item If $d < 0$, then $a \neq 0$ and
      \[ 4f(x,
      y) = 4a^2x^2 + 4abxy + 4acy^2 = (2ax + by)^2
      + (4ac - b^2)y^2 = (2ax + by)^2 - dy^2 .\]
      So $4af(x, y)$ is \gls{pos_def}.
    \item If $d > 0$, then we can factor $f(x, 1)
      = a(x - \alpha)(x - \beta)$, $\alpha, \beta
      \in \RR$, provided $a \neq 0$, using the
      quadratic formula. Since $d \neq 0$, $\alpha
      \neq \beta$, so we can assume $\alpha <
      \beta$. If $v, w \in \RR$, $v < \alpha$, $w
      \in (\alpha, \beta)$, then $f(v, 1)$ and
      $f(w, 1)$ are non-zero real numbers of
      opposite signs. So $f$ is \gls{indef}.
      If $a = c = 0$, then $f(x, y) = bxy$ with
      $b \neq 0$, clearly \gls{indef}.
    \item If $d = 0$, then $b^2 = 4ac$. Write $a =
      a_1 a_2^2$, $a_1, a_2 \in \ZZ$ squarefree.
      Then $b^2 = 4a_1 a_2^2 c$, so $a_1 c$ is a
      square, so $a_1 \divides c$, $c = a_1 z^2$,
      $z \in ZZ$. Then $f(x, y) = ax^2 + bxy +
      cy^2 = a_1 a_2^2 x^2 + bxy + cy^2 = a_1
      \left( a_2 x + \frac{b}{2a_1 a_2} y
      \right)^2$.
  \end{enumerate}
\end{proof}

\glsadjdefn{posdef_bqf}{positive
definite}{\gls{bqform}}
