\documentclass[11pt]{article}

\usepackage{amsmath,amssymb,amsthm}

\usepackage{xcolor}

%\usepackage{systeme}

%\usepackage[textheight=8.5in, margin=1.6in]{geometry}
\usepackage[total={6in,8in}]{geometry}


\theoremstyle{definition}
\newtheorem{thm}{Theorem}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{eg}[thm]{Example}
\newtheorem{ex}[thm]{Exercise}
\newtheorem{defn}[thm]{Definition}
\newtheorem{prop}[thm]{Proposition}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{remark}[thm]{Remark}
\newtheorem{question}[thm]{Question}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{tikz}
\usepackage{tikz-cd}
\tikzstyle{ball} = [circle,shading=ball, ball color=black,
    minimum size=1mm,inner sep=1.3pt]
\tikzstyle{miniball} = [circle,shading=ball, ball color=black,
    minimum size=1mm,inner sep=0.5pt]
\tikzstyle{mminiball} = [circle,shading=ball, ball color=black,
    minimum size=0.6mm,inner sep=0.1pt]
\usetikzlibrary{arrows.meta}
\tikzset{>={Latex[length=2mm,width=1.5mm]}}
\tikzset{->-/.style={decoration={markings, mark=at position #1 with
  {\arrow{>}}},postaction={decorate}}}
\usetikzlibrary{decorations.pathmorphing}    
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{arrows.meta,calc}
\usetikzlibrary{bending}
\usetikzlibrary{decorations.markings,shapes.geometric}
\tikzset{->-/.style={decoration={markings, mark=at position #1 with
  {\arrow{>}}},postaction={decorate}}}
\tikzset{-|-/.style={decoration={markings, mark=at position #1 with
  {\arrow{stealth}}},postaction={decorate}}}
\tikzset{movearrow/.style 2 args ={
        decoration={markings,
	  mark= at position {#1} with {\arrow{#2}} ,
        },
        postaction={decorate}
    }
}

%\usepackage{graphicx}

\usepackage{needspace}  % <-- to prevent bad pagebreak over environment titles
% Use:  \Needspace{3\baselineskip} before opening an environment

\usepackage{enumitem}
%\setlist[enumerate]{leftmargin=*}
\setlist[enumerate]{itemsep=1pt}

%\allowdisplaybreaks

\usepackage[colorlinks=true,citecolor=black,linkcolor=black,urlcolor=blue]{hyperref}

%\usepackage{algorithm}
%\usepackage[noend]{algpseudocode}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\W}{\mathbb{W}}
\newcommand{\FF}{\mathbb{F}}
\newcommand{\sn}{\mathfrak{S}}
\newcommand{\ve}{\varepsilon}
\newcommand{\ips}[2]{\langle{#1}, {#2}\rangle}
\newcommand{\incid}{\mathcal{I}(P)}
\newcommand{\tL}{\widetilde{L}}
\newcommand{\tV}{\widetilde{V}}
\newcommand{\F}{\mathcal{F}}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\Span}{\mathrm{Span}}
\DeclareMathOperator{\rk}{\mathrm{rank}}
\DeclareMathOperator{\wt}{\mathrm{wt}}
\DeclareMathOperator{\trace}{\mathrm{tr}}
\DeclareMathOperator{\im}{\mathrm{im}}
\DeclareMathOperator{\Sym}{\mathrm{Sym}}
\DeclareMathOperator{\Hom}{\mathrm{Hom}}
\DeclareMathOperator{\diag}{\mathrm{diag}}
\DeclareMathOperator{\glb}{\mathrm{glb}}
\DeclareMathOperator{\lcm}{\mathrm{lcm}}
\DeclareMathOperator{\lub}{\mathrm{lub}}
\DeclareMathOperator{\Div}{\mathrm{Div}}
\DeclareMathOperator{\Pic}{\mathrm{Pic}}
\DeclareMathOperator{\Jac}{\mathrm{Jac}}
\DeclareMathOperator{\cok}{\mathrm{cok}}
\DeclareMathOperator{\sgn}{\mathrm{sgn}}
\DeclareMathOperator{\outdeg}{\mathrm{outdeg}}
\DeclareMathOperator{\supp}{\mathrm{supp}}
\DeclareMathOperator{\vol}{\mathrm{vol}}

\parskip = 0.05in
\parindent = 0.0in

%\pagestyle{empty}

\begin{document}
\centerline{Math 361 lecture for Friday, Week 10}
\bigskip

\centerline{Four squares theorem}
\bigskip

Today, we will give some first application's of Minkowski's theorem.
\bigskip

\begin{thm}[Two squares theorem]
  Let $p\in\Z$ be a prime number, and suppose that~$p=1\bmod 4$.  Then 
  \[
    p = x^{2}+y^2
  \]
  for some $x,y\in\Z$. 
\end{thm}

\begin{ex}
  Try some examples.
\end{ex}

\begin{proof}[Proof of two square theorem]\

  \textbf{Step 1.} Pick $u\in \{1,\ldots,p-1\}$ such
  that~$u^2=-1\bmod p$.  To see that this is always possible,
  consider~$(\Z/p\Z)^{*}$, the multiplicative group of non-zero elements
  of~$\Z/p\Z$.  By the structure theorem for finite abelian groups,
  \[
    (\Z/p\Z)^{*}\simeq \Z/n_{1}\Z\times \cdots \times \Z/n_{k}\Z
  \]
  with~$n_{1}\geq1$, $n_{1}|n_{2}|\cdots|n_{k}$ and some~$k\geq0$.  It follows
  that~$a^{n_{k}}=1$ for all $a\in (\Z/p\Z)^{*}$. (Note that we have an
  isomorphism between a multiplicative group and an additive group.)  Thus,
  all~$p-1$ elements of~$(\Z/p\Z)^{*}$ are roots of the
  polynomial~$x^{n_{k}}-1\in K[x]$ where~$K$ is the field~$\Z/p\Z$.  Using
  the division algorithm, we know that~$x^{n_{k}}-1$ has at most $n_{k}$ roots,
  and thus~$n_{k}\geq p-1$.  In the other hand, we know $n_{1}\cdots n_{k}=p-1$,
  and so, $n_{k}\leq p-1$.  Therefore,~$k=1$, and $n_{1}=p-1$.

  So far we have shown that~$(\Z/p\Z)^{*}$ is cyclic of order~$p-1$ just based
  on the fact that~$p$ is prime.  In our case, $p-1=4k$ for some integer~$k$.
  Let~$v$ be a generator of~$(\Z/p\Z)^{*}$, and define~$u=v^{k}$.  It follows
  that~$u^4=v^{4k}=v^{p-1}=1\bmod p$, and $u^{2}\neq1\bmod p$ (since~$v$ has
  order~$4$).  Since
  \[
    u^4 -1 = (u^{2}-1)(u^{2}+1)=0\bmod p,
  \]
  it follows that~$u^{2}=-1\bmod p$.
  \medskip

  \textbf{Step 2.} Having fixed $u\in \{1,\ldots,p-1\}$ such that~$u^2=-1\bmod
  p$, define 
  \[
    L = \Span_{\Z}\{(0,p),(1,u)\}\subset\Z^{2}\subset\R^{2}
  \]
  Then~$L$ is a rank~$2$ lattice in~$\R^{2}$, and the area of a fundamental
  domain~$F$ for $L$ is
  \[
    \left|
    \left(\begin{array}{cc}
	0 & 1 \\
	p & u
    \end{array}\right)
    \right|
    =p.
  \]
  
  \textbf{Step 3.} Let~$X$ be the unit disc of radius~$r$ centered at the
  origin in~$\R^{2}$ where $r^2=\textstyle \frac{3}{2}p$.  We have
  \[
    \vol(X) =\pi r^2 =\frac{3}{2}\pi p>4p=2^{2}\vol(F).
  \]
  By Minkowski's theorem, there exists a nonzero lattice point~$(x,y)\in L\cap
  X$.  Since~$(x,y)\in X$, we have
  \[
    x^2+y^2\leq r^2=\frac{3}{2}p<2p.
  \]
  We now show that~$x^2+y^2$ is divisible by~$p$. Since~$(x,y)\in L$, we have
  \[
    (x,y)=a(0,p)+b(1,u)=(b,ap+bu)
  \]
  for some~$a,b\in\Z$.  Since~$u^2=-1\bmod p$, calculating modulo~$p$, we have
  \[
    x^2+y^2=b^2+(ap+bu)^{2}=b^2+(bu)^{2}=b^2+b^2u^2=b^2-b^2=0\bmod p.
  \]
  So $x^2+y^2=kp$ for some~$k\in\Z_{>0}$.  However, we have seen
  that~$x^2+y^2<2p$.  It follows that~$x^2+y^2=p$, as desired.
\end{proof}

\begin{thm}[Four squares theorem]
  Every positive integer is the sum of four integer squares.  In other words,
  if~$n\in\Z$, then there exist $a,b,c,d\in\Z$ such that
  \[
    n=a^2+b^2+c^2+d^2.
  \]
\end{thm}
\begin{proof}\

  \textbf{Step 1.}  It suffices to prove the result for primes~$p$ since
  \begin{align*}
   &(a^2+b^2+c^2+d^2)(A^2+B^2+C^2+D^2) =\\[5pt]
   &\qquad
   (aA-bB-cC-dD)^{2}
   +
   (aB+bA+cD-dC)^{2}\\
   &\qquad\qquad
   +
   (aC-bD+cA+dB)^{2}
   +
   (aD+bC-cB+dA)^{2}
  \end{align*}
  for all~$a,b,c,d,A,B,C,D\in\Z$.
  \medskip

  \textbf{Step 2.} The result holds for~$p=2$ since $2=1^{2}+1^{2}+0^{2}+0^{2}.$ 
  \medskip

  \textbf{Step 3.} Let~$p$ be an odd prime.  We claim there exist~$u,v\in\Z$ such that 
  \[
    u^2+v^2=-1\bmod p.
  \]
  To see this, note that the elements of~$\Z/p\Z$ may be written
  \[
    0,\pm 1,\pm2,\ldots,\pm(p-1).
  \]
  Further, 
  \[
    a^2=b^2\bmod p 
    \quad\Rightarrow\quad 
    (a+b)(a-b) \bmod p
    \quad\Rightarrow\quad
    a = \pm b\bmod p.
  \]
  Since, $p\neq 2$, we have $a\neq -a\bmod p$.  Therefore,
  \begin{align*}
    |\{u^{2}\bmod p:u\in\{0,1,\ldots,p-1\}\}|
   &=  |\{-1-v^{2}\bmod p:v\in\{0,1,\ldots,p-1\}\}|\\
   &= 1+\frac{p-1}{2}=\frac{p+1}{2}.
  \end{align*}
  The two sets above are not disjoint since
  \[
    \frac{p+1}{2}+\frac{p+1}{2}=p+1>p.
  \]
  So there exist~$u,v\in\Z$ such that~$u^2=-1-v^2\bmod p$.
  \medskip

  \textbf{Step 4.} Consider the rank~$4$ lattice
  \[
    L = \text{colspan}_{\Z}
    \left(\!\!\begin{array}{rrrr}
	1 & 0 & 0 & 0 \\
	0& 1 & 0 & 0 \\
	u& v & p & 0 \\
	-v& u & 0 & p
    \end{array}\right).
  \]
  The volume of a fundamental domain for~$L$ is $|\Z^{4}/L|=p^{2}$.  Apply
  Minkowski's theorem with~$X$ being a ball of radius $r=\sqrt{1.9p}$.
  Since~$X$ is a $4$-dimensional ball, 
   \[
     \vol(X)=\frac{\pi^{2}r^{4}}{2}>2^{4}p^2=2^{4}\vol(F)
   \]
   where~$F$ is a fundamental domain for~$L$.  Hence, by Minkowski's theorem,
   there exists a nonzero~$\ell=(a,b,c,d)\in L\cap X$.  Since~$\ell\in X$,
   \[
     a^2+b^2+c^2+d^2\leq r^2=1.9p<2p,
   \]
   Since~$\ell\in L$,
   \begin{align*}
     (a,b,c,d) 
     &=
     x(1,0,u,-v)+y(0,1,v,u)+z(0,0,p,0)+w(0,0,0,p)\\
     &=(x,y,xu+yv+zp,-xv+yu+wp).
   \end{align*}
   Working modulo~$p$, we have
   \begin{align*}
     a^2+b^2+c^2+d^2
     &=
     x^2+y^2+(xu+yv+zp)^{2}+(-vx+yu+wp)^{2}\\
     &=
     x^2+y^2+(xu+yv)^{2}+(-xv+uy)^{2}\\
     &=
     x^2+y^2+x^2u^2+2xyuv+y^2v^2+x^2v^2-2xyuv+y^2u^2\\
     &=
     x^2+y^2+x^2u^2+y^2v^2+x^2v^2+y^2u^2\\
     &=
     x^2+y^2+x^2(u^2+v^2)+y^2(v^2+u^2)\\
     &=0 \bmod p.
   \end{align*}
   So~$a^2+b^2+c^2+d^2=kp$ is a positive multiple of~$p$ that is less then~$2p$.
   Therefore,
   \[
     a^2+b^2+c^2+d^2=p.
   \]
\end{proof}
\end{document}
