%\documentclass[a4paper,twoside,draft]{article}
\documentclass[a4paper,twoside,reqno,12pt,draft]{amsart}
\usepackage[headings]{fullpage}
\usepackage{multicol}
%\usepackage{showlabels}
%\usepackage[fulloldstyle]{fourier}
\title{Elementary Number Theory II}
\author{David Pierce}
\date{\today}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{verbatim}  % allows a comment environment:

%\begin{comment}
\address{Mathematics Dept\\
Middle East Technical University\\
Ankara 06531, Turkey}

\email{dpierce@metu.edu.tr}
\urladdr{http://www.math.metu.edu.tr/~dpierce/}

%\end{comment}


%\usepackage{amssymb,amsmath}
\usepackage{url}
\usepackage[all]{xy}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{textcomp}  % supposedly useful with \oldstylenums
\usepackage{upgreek}

\usepackage{layout}
\usepackage{hfoldsty} % this didn't work until I added missing
		      % brackets to some of the files.

%\usepackage{hyperref}
%\usepackage{makeidx}
%\makeindex
%\makeglossary  % should be turned off to make the glossary appear
\newcommand{\topic}[1]{\glossary{#1}}

\begin{comment}
\newcommand{\glossaryentry}[2]{\item #1\hfill #2}
\newcommand{\tableoftopics}{\begin{center}\textsc{List of Topics}\end{center}
\addcontentsline{toc}{section}{List of Topics}
\renewcommand{\theenumi}{\arabic{enumi}}
\renewcommand{\labelenumi}{\theenumi.}
\begin{enumerate}
\setlength{\leftmargin}{0pt}  % doesn't work!
\input{lectures.glo}
\end{enumerate}}
\end{comment}

\newcommand{\glossaryentry}[2]{#1\dotfill#2\\}
\newcommand{\tableoftopics}{\begin{center}\textsc{List of Topics}\end{center}
\addcontentsline{toc}{section}{List of Topics}
\input{lectures.glo}}

%\newcommand{\osn}[1]{\oldstylenums{#1}}

\newcommand{\asterism}{\par\mbox{}\par
%\mbox{}\hfill$*\qquad*\qquad*\qquad*\qquad*$\hfill\mbox{}
  \begin{center}
    $*\qquad*\qquad*\qquad*\qquad*$
  \end{center}
\par\mbox{}\par}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\renewcommand{\leq}{\leqslant}
\renewcommand{\geq}{\geqslant}
\renewcommand{\setminus}{\smallsetminus}
%\renewcommand{\phi}{\varphi}

\newcommand{\Iff}{}
\let\Iff\iff
\renewcommand{\iff}{\leftrightarrow}
\newcommand{\Exists}[1]{\exists{#1}\;}
\renewcommand{\emptyset}{\varnothing}
\renewcommand{\epsilon}{\varepsilon}

%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\lto}{\Rightarrow}
\renewcommand{\land}{\mathrel{\&}}
\renewcommand{\lor}{\mathrel{\mathrm{or}}}
\newcommand{\xsize}[1]{\Bigl|#1\Bigr|}
\newcommand{\size}[1]{\lvert#1\rvert}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeindex

\newcommand{\defn}[2]{\textbf{#1#2}\index{#1}}
\newcommand{\defnplain}[2]{\textbf{#1#2}}
\newcommand{\tech}[2]{\textsl{#1#2}\index{#1}}

%\renewcommand{\theenumi}{\alph{enumi}}
%\renewcommand{\labelenumi}{\textnormal{(\theenumi)}}
\renewcommand{\theenumi}{\roman{enumi}}
\renewcommand{\labelenumi}{\textnormal{(\theenumi)}}

%\renewcommand{\theenumii}{\roman{enumii}}
%\renewcommand{\labelenumii}{\textnormal{(\theenumii)}}

%%%%%%%%%%%%%%%

\newcommand{\divides}{\mathrel{|}}
\newcommand{\ndivides}{\mathrel{\nmid}}

%\newcommand{\ord}[2]{\operatorname{ord}_{#1}(#2)}

\newcommand{\ls}[2]{\Bigl(\displaystyle\frac{#1}{#2}\Bigr)}

% set-theoretic relations:

\newcommand{\included}{\subseteq}      % [the name suggests the meaning here]
\newcommand{\nincluded}{\not\subseteq} % not included
\newcommand{\pincluded}{\subset}       % proper inclusion    
\newcommand{\includes}{\supseteq}

\newcommand{\stnd}[1]{\mathbb{#1}}
\newcommand{\N}{\stnd{N}}         % natural numbers
\newcommand{\varN}{\upomega}        % my usual preference for this
%\newcommand{\Zp}{\Z_{+}}          % positive integers
\newcommand{\Z}{\stnd{Z}}         % integers
\newcommand{\Q}{\stnd{Q}}         % rationals
%\newcommand{\Pri}{\stnd{P}}         % primes
\newcommand{\R}{\stnd{R}}         % reals
\newcommand{\C}{\stnd{C}}         % complex numbers

%\newcommand{\units}[1]{#1^{\times}}
%\newcommand{\Zmod}[1][n]{\Z/(#1)}
%\newcommand{\Zmodu}[1][n]{\units{(\Zmod[#1])}}

%\newcommand{\scr}[1]{\operatorname{s}(#1)}
%\newcommand{\pred}[1]{\operatorname{pred}(#1)}
%\DeclareMathOperator{\lcm}{lcm}

\DeclareMathOperator{\dee}{d}      % 

\newcommand{\mi}{\mathrm i}
\newcommand{\mpi}{\uppi}
\newcommand{\gr}{\upphi}  % golden ratio

\newcommand{\cc}[1]{\overline{#1}}  % complex conjugate
\newcommand{\norm}[1]{\operatorname{N}(#1)}
\newcommand{\tr}[1]{\operatorname{Tr}(#1)}
\newcommand{\inv}[1][]{#1^{-1}}
\newcommand{\edeg}[1]{\operatorname d(#1)}  % degree for Euclidean domain
\newcommand{\gi}{\Z[\mi]}
\newcommand{\roi}[1][K]{\mathfrak O_{#1}}  % ring of integers
\newcommand{\lat}[1][\alpha,\beta]{\langle#1\rangle} % lattice
\newcommand{\disc}[1]{\Delta(#1)}      % discriminant
\newcommand{\mLambda}{\mathit{\Lambda}}
\newcommand{\mPi}{\mathit{\Pi}}
\newcommand{\mSigma}{\mathit{\Sigma}}
\newcommand{\mMu}{M}
\newcommand{\mDelta}{\mathit{\Delta}}
\newcommand{\End}[1][\mLambda]{\operatorname{End}(#1)}  % Endomorphism-ring
\newcommand{\ord}[1][\mLambda]{\mathfrak O_{#1}}
\newcommand{\funit}[1][\mLambda]{\epsilon_{#1}}

\let\oldsqrt\sqrt
\renewcommand{\sqrt}[2][1]{\oldsqrt{\vphantom{#1}}#2}
\newcommand{\rft}{\sqrt{14}}
\newcommand{\rtt}{\sqrt{13}}

%\newcommand{\rten}{\sqrt{10}}
%\newcommand{\dsp}{\,}   % space between blocks of three digits

\newcommand{\sqf}{square-free}

\newcommand{\Fib}[1]{\operatorname{F}_{#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  Theorem-like environments  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newtheorem{theorem}{Theorem}
\newtheorem*{corollary}{Corollary}
\newtheorem*{porism}{Porism}
\newtheorem{lemma}{Lemma}
\newtheorem{problem}{Problem}
%\newtheorem*{fact}{Fact}
%\newtheorem*{exercise}{Exercise}
%\newtheorem*{remark}{Remark}

\theoremstyle{definition}
%\newtheorem*{example}{Example}

\newenvironment{solution}%
{\begin{proof}[Solution.]}%
{\end{proof}}

%\numberwithin{equation}{section}
%\renewcommand{\theequation}{\fnsymbol{equation}}


\begin{document}
  \maketitle

These are notes from %Elementary Number Theory~II 
Math~366 in the METU Mathematics Department, spring
semester, 2007/8.  
Class met Tuesdays at
13.40 for two hours
and Fridays at 13.40 (originally 12.40) for one hour.
I have typeset these notes after class, from memory and
from handwritten notes prepared before class.  I have done some polishing,
correcting, and rearrangement.  

The main published reference for the course is \cite{MR0476613}, which
has apparently been on reserve in the library since the last time this
course was offered several years ago.  I have that text only in the
form of a photocopy of chapters 6--11, used by Ay\c se Berkman when she was a
student.  The text is a rough guide only, and
I may change its terminology and notation.


All special symbols used in these notes are found at the head of the
index.

For continued fractions, the text \cite{Burton} used for
Math 365 is useful, as are \cite{MR568909} and \cite{MR0210649}.  I
also consult \cite{MR2135478} and \cite{MR0092794}, and occasionally
other works. 

Class was cancelled Friday, February 29, because I was in \.Istanbul
for my \emph{do\c centlik} exam.  Ay\c se taught for me on the
following Tuesday, since I was sick with a gastro-intestinal infection
from the trip.  I was sick again, with the flu, on May 13 and 16;
class was cancelled. 

There were examinations on the Mondays March 24, April 28, and May 26,
so there were no lectures covering new material on the previous Fridays.

Class on Tuesday, April 8, was only one hour, because of a special
seminar that day (on teaching conic sections). 

The section for April 22 is a reworking of what I presented vaguely
and incorrectly in class.  Theorem~\ref{thm:ultimate} was not given at
all in class.

\vfill
\begin{multicols}2
  \tableofcontents
\end{multicols}
\vfill
\newpage

\listoffigures
\vfill
\listoftables
\vfill
\begin{multicols}2
\tableoftopics
%\input{lectures.glo}
\end{multicols}
\vfill
\begin{comment}

\index{$K$ this is a test to see how the indexing program deals with
  symbols and long entries.  Can one add long comments to the index?}

\begin{center}
  \textsc{Notation}
\end{center}
\addcontentsline{toc}{section}{Notation}
$\mi$ (p.~\pageref{mi}) a solution of $x^2+1=0$, also denoted by
$\sqrt{{-1}}$; not $i$

$\varN$ (p.~\ref{varN}) the set $\{0,1,2,\dots\}$ of natural numbers

$K$ (p.~\ref{K}) a quadratic field

$\Q$ (p.~\ref{Q}) the field of rational numbers

$\C$ (p.~\ref{C}) the field of complex numbers

$\Q(\sqrt d)$ (p.~\ref{Q(rt d)} the smallest subfield of $\C$ that
contains $\sqrt d$; here $d$ is a \sqf{} integer different from $1$, and
henceforth $K$ denotes this field

$\Z$ the set of integers

$\gi$ (p.~\ref{gi}) the ring of Gaussian integers

$\mpi$ (p.~\ref{mpi}) the circumference of the unit circle (as opposed
to $\pi$, sometimes used for a prime)

$\omega$ (p.~\ref{omega})

\end{comment}


\newpage

\section{February 19, 2008 (Tuesday)}

\topic{Diophantine equations}

We begin with some \defn{Diophantine equation}s (that is, polynomial
equations in which all constants and
variables are integers).

\topic{Pythagorean triples}

\begin{problem}
  Solve
  \begin{equation}\label{eqn:Pyth}
    x^2+y^2=z^2
  \end{equation}
(that is, find all solutions).
\end{problem}

\begin{solution}
The following are equivalent:
\begin{enumerate}
\item
  $(a,b,c)$ is a solution;
\item
$(\size a,\size b,\size c)$
  is a solution;
\item
$(na,nb,nc)$ is a solution, where $n\neq0$;
\item
$(b,a,c)$ is a solution.
\end{enumerate}
Also,~\eqref{eqn:Pyth} is equivalent to 
\begin{equation*}
x^2=(z+y)(z-y).
\end{equation*}
Suppose $(a,b,c)$ is a solution of~\eqref{eqn:Pyth} such that
$a,b,c>0$ and
$\gcd(a,b,c)=1$.  Then $(a,b,c)$ may be called a \defn{primitive
  solution}, and all solutions can be obtained from primitive solutions.
Observe that not both $a$ and $b$ are even.  Also, if $a,b\equiv1\pmod
2$, then
$c^2\equiv a^2+b^2\equiv2\pmod4$, which is absurd.  So exactly one of $a$ and
$b$ is even.  Say $a$ is even.  Then $b$ and $c$ are odd, and
\begin{equation*}
  \left(\frac a2\right)^2=\left(\frac{c+b}2\right)\left(\frac{c-b}2\right).
\end{equation*}
Also $(c+b)/2$ and $(c-b)/2$ are co-prime, since their sum is $c$ and
their difference is $b$.  Hence each must be a square; say
\begin{equation*}
  \frac{c+b}2=n^2,\qquad\frac{c-b}2=m^2,
\end{equation*}
where $n,n>0$.  Then
\begin{equation*}
  c=n^2+m^2,\qquad b=n^2-m^2,\qquad a=2nm.
\end{equation*}
Moreover, $n$ and $m$ are co-prime, and exactly one of them is odd
(since $c$ is odd).

Conversely, suppose $n$ and $m$ are co-prime, exactly one of them is
odd, and $0<m<n$.  Then the triple $(2nm,n^2-m^2,n^2+m^2)$
solves~\eqref{eqn:Pyth}.
Moreover, every common prime factor of $n^2-m^2$
and $n^2+m^2$ is a factor of the sum $2n^2$ and the difference $2m^2$,
hence of $n$ and $m$.  So there is no common prime factor, and the
triple is a \emph{primitive} solution.

We conclude that there is a one-to-one correspondence between:
\begin{enumerate}
  \item
pairs $(m,n)$ of co-prime integers, where $0<m<n$, and exactly
one of $m$ and $n$ is odd;
\item
primitive solutions $(a,b,c)$ to~\eqref{eqn:Pyth}, where $a$ is even.
\end{enumerate}
The correspondence is $(x,y)\mapsto(2xy,y^2-x^2,y^2+x^2)$.
\end{solution}

\topic{Infinite descent}

\begin{problem}
  Solve
  \begin{equation}\label{eqn:Fermat}
    x^4+y^4=z^4.
  \end{equation}
\end{problem}

\begin{solution}
  Let $(a,b,c)$ be a solution, where $a,b,c>0$, and $\gcd(a,b,c)=1$.
  Then $(a^2,b^2,c^2)$ is a primitive \defn{Pythagorean triple}{}
  (that is, solution to~\eqref{eqn:Pyth}).  We may assume $a$ is even,
  and so
  \begin{equation*}
    a^2=2mn,\quad b^2=n^2-m^2,\quad c^2=n^2+m^2.
  \end{equation*}
In particular,
\begin{equation*}
  m^2+b^2=n^2.
\end{equation*}
Since $\gcd(a,b)=1$, and every prime factor of $m$ divides $a$, we
have $\gcd(m,b)=1$.  Hence $(m,b,n)$ is a primitive Pythagorean
triple.  Also $m$ is even, since $b$ is odd.  Hence
\begin{equation*}
  m=2de,\quad b=e^2-d^2,\quad n=e^2+d^2
\end{equation*}
for some $d$ and $e$.  Then
\begin{equation*}
  a^2=2mn=4de(e^2+d^2).
\end{equation*}
But $\gcd(d,e)=1$, so $e^2+d^2$ is prime to both $d$ and $e$.
Therefore each of $d$, $e$, and $e^2+d^2$ must be square: say
\begin{equation*}
  d=r^2,\quad e=s^2,\quad e^2+d^2=t^2.
\end{equation*}
This gives $t^2=e^2+d^2=s^4+r^4$; that is, $(s,r,t)$ is a solution to
\begin{equation}\label{eqn:F2}
  x^4+y^4=z^2.
\end{equation}
But $(a,b,c^2)$ is also a solution to this; moreover,
\begin{equation*}
  1\leq\size t\leq t^2=e^2+d^2=n\leq n^2<n^2+m^2=c^2.
\end{equation*}
We never used that $c^2$ is a square.  Thus, for every solution
to~\eqref{eqn:F2} with positive entries, there is a solution with
positive entries in which the third entry is smaller.  This is absurd;
therefore there is no such solution to~\eqref{eqn:F2}, or
to~\eqref{eqn:Fermat}. 
\end{solution}

We used here Fermat's method of \defn{infinite descent}. 

In Elementary Number Theory I, we proved that the Diophantine equation
\begin{equation*}
  x^2+y^2+z^2+w^2=n
\end{equation*}
is soluble for every positive integer $n$.

\begin{problem}
  Find those $n$ for which
  \begin{equation*}
    x^2+y^2=n
  \end{equation*}
is soluble.
\end{problem}

\begin{solution}
  Let $S$ be the set of such $n$.  Since%
\label{mi}\index{$\mi$ (not the variable $i$, but $\sqrt{{-1}}$)}
  \begin{align*}
    (a^2+b^2)(c^2+d^2)
&=\size{a+b\mi}^2\size{c+d\mi}^2\\
&=\size{(a+b\mi)(c+d\mi)}^2\\
&=\size{(ac-bd)+(ad+bc)\mi}^2\\
&=(ac-bd)^2+(ad+bd)^2,
  \end{align*}
$S$ is closed under multiplication.  We ask now:  Which primes are in
  $S$?

All squares are congruent to $0$ or $1$ \emph{modulo} $4$.  Hence elements of
$S$ are congruent to $0$, $1$, or $2$ \emph{modulo} $4$.  Therefore
$S$ contains no primes that are congruent to $3 \pmod 4$.

However, $S$ does contain $2$, since $2=1^2+1^2$.

Suppose $p\equiv1\pmod 4$.  Then $-1$ is a quadratic residue
\emph{modulo} $p$, so
\begin{equation*}
  -1\equiv a^2\pmod p
\end{equation*}
for some $a$, where we may assume $\size a<p/2$.  Hence
\begin{equation*}
  a^2+1=tp
\end{equation*}
for some positive $t$.  This means $tp\in S$.  Let $k$ be the least
positive number such that $kp\in S$.  Since
\begin{equation*}
  0<t=\frac{a^2+1}p<\frac{(p/2)^2+1}p=\frac p4+\frac 1p<p,
\end{equation*}
we have $0<k\leq t<p$.  By assumption,
\begin{equation}\label{eqn:kp}
  kp=b^2+c^2
\end{equation}
for some $b$ and $c$.  There are $d$ and $e$ such that
\begin{equation*}
  d\equiv b,\quad e\equiv c\pmod k;\qquad \size d,\size e\leq \frac k2.
\end{equation*}
Then 
$d^2+e^2\equiv b^2+c^2\equiv0\pmod k$, so
\begin{equation}
\label{eqn:km}
d^2+e^2=km
\end{equation}
for some $m$, where
\begin{equation*}
  0\leq m=\frac{d^2+e^2}k\leq\frac{2(k/2)^2}k=\frac k2<k.
\end{equation*}
But multiply~\eqref{eqn:kp} and~\eqref{eqn:km}, getting
\begin{align*}
  k^2mp
&=(b^2+c^2)(d^2+e^2)\\
&=(bd-ce)^2+(be+cd)^2\\
&=(bd+ce)^2+(be-cd)^2.
\end{align*}
Since
\begin{equation*}
  bd+ce\equiv b^2+c^2\equiv0,\quad
be-cd\equiv bc-cb\equiv 0\pmod k,
\end{equation*}
we can divide by $k^2$, getting
\begin{equation*}
  mp=\left(\frac{bd+ce}k\right)^2+\left(\frac{be-cd}k\right)^2.
\end{equation*}
This implies $mp\in S$.  By minimality of $k$, we have $m=0$.
Therefore $d^2+e^2=0$, so $d=0=e$.  Then $b,c\equiv 0\pmod k$, so
\begin{equation*}
  k^2\divides kp,
\end{equation*}
and therefore $k\divides p$.  This means $k=1$, so $p\in S$.

Finally, suppose $n\in S$ and $p\divides n$.  Then $n=a^2+b^2$ for
some $a$ and $b$, so
\begin{equation*}
  a^2+b^2\equiv 0\pmod p.
\end{equation*}
If $p\divides a$, then $p\divides b$, so $p^2\divides n$, which means
$n$ is not \sqf{}.  If $p\ndivides a$, then $a$ is invertible
\emph{modulo} $p$, so $1+(b/a)^2\equiv0\pmod p$, which means $-1$ is a
quadratic residue \emph{modulo} $p$, and so $p=2$ or else
$p\equiv1\pmod 4$. 

The conclusion is that $S$ contains just those numbers of the form
$n^2m$, where $m$ is \sqf{} and has no prime factors congruent to
$3$ \emph{modulo} $4$.
\end{solution}

\section{February 22, 2008 (Friday)}

\topic{Rational points}
Solving~\eqref{eqn:Pyth} in integers is related to finding
integrals like
\begin{equation*}
\int\frac{\dee\theta}{2+3\sin\theta}.
\end{equation*}
Indeed,
\begin{equation*}
  x^2+y^2=z^2\Iff \left(\frac xz\right)^2+\left(\frac
  yz\right)^2=1\lor x=y=z=0.
\end{equation*}
So finding Pythagorean triples corresponds to solving
\begin{equation*}
  x^2+y^2=1
\end{equation*}
in \emph{rationals.}  To do so, since the equation defines the unit
circle, consider also the line through $(-1,0)$ with slope $t$, 
\begin{figure}[ht]
    \begin{pspicture}(-3,-3)(3,3)
      \pscircle(0,0){2}
      \psline{->}(-3,0)(3,0)
      \psline{->}(0,-3)(0,3)
      \psline(-3,-0.5)(3,2.5)
      \psdots(-2,0)(0,1)(1.2,1.6)
      \uput[dr](0,1){$t$}
      \uput[ul](-2,0){$-1$}
      \uput[dl](3,0){$X$}
      \uput[dl](0,3){$Y$}
%      \uput[u](1.2,1.6){$(x,y)$}
    \end{pspicture}
\caption{Finding the rational points of the circle}\label{fig:circle}
\end{figure}
so
that its $Y$-intercept is also $t$, as in Figure~\ref{fig:circle}:
this line is given by 
\begin{equation}\label{eqn:Pyth-line}
  y=tx+t.
\end{equation}
The circle and the line meet at $(-1,0)$ and also $(x,y)$, where
\begin{gather*}
  x^2+(tx+t)^2=1,\\
(1+t^2)x^2+2t^2x+t^2-1=0,\\
x^2+\frac{2t^2}{1+t^2}\cdot x-\frac{1-t^2}{1+t^2}=0.
\end{gather*}
The constant term in the left member of the last equation is the
product of the roots; one of the roots is $-1$; so we get
\begin{equation*}
  (x,y)=\left(\frac{1-t^2}{1+t^2},\frac{2t}{1+t^2}\right).
\end{equation*}
If $t$ is rational, then so are the coordinates of this point, which
is therefore a \defn{rational point}{} of the circle.  Conversely, if
$x$ and $y$ are rational, then so is $t$, by~\eqref{eqn:Pyth-line}.
Hence the function
\begin{equation*}
  t\mapsto\left(\frac{1-t^2}{1+t^2},\frac{2t}{1+t^2}\right)
\end{equation*}
is a one-to-one correspondence, with inverse 
\begin{equation*}
(x,y)\mapsto\frac y{x+1},
\end{equation*}
between $\Q$\index{$\Q$ (the field of rational numbers)} and the set
of rational points (other than $(-1,0)$) of the unit circle.

Hence we can conclude that every integral solution of~\eqref{eqn:Pyth}
is a multiple of
\begin{equation*}
  (1-t^2,2t,1+t^2).
\end{equation*}
Taking $t=m/n$ and multiplying by $n^2$, we get
\begin{equation*}
  (n^2-m^2,2mn,n^2+m^2).
\end{equation*}

\asterism%{}

\topic{Continued fractions}
We can convert $\sqrt 2$ into a \tech{continued fraction}{} as
follows:
\begin{equation*}
  \sqrt 2=1+(\sqrt2-1)
%=1+\cfrac{1}{\frac1{\sqrt 2-1}}
=1+\cfrac{1}{\sqrt 2+1}
=1+\cfrac{1}{2+(\sqrt 2-1)}
=1+\cfrac{1}{2+\cfrac{1}{\sqrt 2+1}}=\cdots
%=1+\cfrac{1}{2+\cfrac{1}{2+\cfrac{1}{\sqrt 2-1}}}
%=\dots
\end{equation*}
In the general procedure, given a real number $x$, we define $a_n$ and
$\xi_n$ recursively as follows, where square brackets denote the
greatest-integer function:
\begin{alignat}{2}\label{eqn:a_0}
a_0&=[x], & \xi_0&=x-a_0;\\\notag
a_1&=\left[\frac1{\xi_0}\right],& \xi_1&=\frac1{\xi_0}-a_1;\\
%&\vdots&&\dots\\
\intertext{and generally}\label{eqn:a_n}
a_n&=\left[\frac1{\xi_{n-1}}\right],\quad& \xi_n&=\frac1{\xi_{n-1}}-a_n;
\end{alignat}
where $\xi_{n-1}$ must be non-zero for $a_n$ to be defined.
Then
\begin{equation*}
  x=a_0+\xi_0=a_0+\cfrac1{a_1+\xi_1}=a_0+\cfrac1{a_1+\cfrac1{a_2+\xi_2}}=\cdots
\end{equation*}
These are \defn{continued fraction}{s.}  Taking $x=\sqrt 3$, we get
\begin{alignat*}{3}
             &                       &a_0&=1,\quad&\xi_0&=\sqrt 3-1,\\
\frac1{\xi_0}&=\frac{\sqrt3+1}2,\quad&a_1&=1,     &\xi_1&=\frac{\sqrt 3-1}2,\\
\frac1{\xi_1}&=\sqrt 3+1,            &a_2&=2,     &\xi_2&=\sqrt 3-1,
\end{alignat*}
and now the process repeats:
\begin{equation*}
  \xi_n=
  \begin{cases}
    \sqrt 3-1,&\text{ if $n$ is even};\\
    \displaystyle\frac{\sqrt 3-1}2,&\text{ if $n$ is odd};\\
  \end{cases}\qquad
a_n=
\begin{cases}
  1,&\text{ if $n=0$, or $n$ is odd};\\
  2,&\text{ if $n$ is positive and even.}
\end{cases}
\end{equation*}
It appears that
\begin{equation}\label{eqn:rt3}
  \sqrt3=1+\cfrac1{1+\cfrac1{2+\cfrac1{1+\cfrac1{2+\cfrac1{\ddots}}}}}
\end{equation}
But to make this precise, we need some notion of \tech{convergence}.
To define this, we introduce some notation.  Here square brackets do
\emph{not} denote the greatest-integer function:
\begin{align}\notag
  [a_0]&=a_0,\\\notag
[a_0;a_1]&=a_0+\cfrac1{a_1},\\\notag
[a_0;a_1,a_2]&=a_0+\cfrac1{a_1+\cfrac1{a_2}},\\
\intertext{and so forth, so that}\label{eqn:brackets}
[a_0;a_1,\dots,a_{n+1}]&=[a_0;a_1,\dots,a_{n-1},a_n+\frac1{a_{n+1}}].
\end{align}
Here we must have $a_n\neq0$ when $n>0$; we shall assume also $a_n>0$
when $n>0$.  We can also use the notation in the infinite case.  For
example, from $\sqrt3$, we have obtained $[1;1,2,1,2,\dots]$, which we
can write as
\begin{equation*}
  [1;\overline{1,2}].
\end{equation*}
But again, we have not yet established that this notation defines a
particular number.

\section{February 26, 2008 (Tuesday)}

The process of obtaining the sequences $(a_n\colon n\in\varN)$%
\index{$\varN$ (another name for $\N$)}
and
$(\xi_n\colon n\in\varN)$ from $x$ as above can be compared with the
\defn{Euclidean algorithm}:  To find $\gcd(155,42)$, we compute
\begin{align*}
  155&=42\cdot3+29,\\ 
   42&=29\cdot1+13,\\
   29&=13\cdot2+3,\\
   13&=3\cdot4+1,\\
    3&=1\cdot 3+0.
\end{align*}
We can rewrite this as
\begin{alignat*}{2}
  \left[\frac{155}{42}\right]&=3,\quad&  \frac{155}{42}-3&=\frac{29}{42},\\
  \left[\frac{42}{29}\right]&=1,&  \frac{42}{29}-1&=\frac{13}{29},\\
  \left[\frac{29}{13}\right]&=2,&  \frac{29}{13}-2&=\frac3{13},\\
  \left[\frac{13}3\right]&=4,& \frac{13}3-4&=\frac13,\\
  \left[\frac31\right]&=3,& \frac31-3&=0.
\end{alignat*}
Thus, when $x=155/42$, then the sequence of
$a_n$ is just $(3,1,2,4,3)$, and
\begin{equation*}
  \frac{155}{42}=3+\cfrac1{1+\cfrac1{2+\cfrac1{4+\cfrac1{3}}}}.
\end{equation*}
Thus we can write every fraction as a (finite) \defn{continued fraction}{}
$[a_0;a_1,\dots,a_n]$, where the $a_k$ are integers, and all of them
are positive except perhaps $a_0$.  Such a continued fraction is
called \defn{simple}.  We shall work only with simple continued
fractions.  But the continued fraction obtained for
irrational $x$ does not terminate.

The $k$th \defn{convergent}{} of $[a_0;a_1,\dots]$ is
$[a_0;a_1,\dots,a_k]$.  For example, the convergents of
$[1;\overline{1,2}]$ are
\begin{equation*}
  1,\quad 2,\quad \frac53,\quad \frac74,\quad \frac{19}{11},\quad
  \frac{26}{15},\quad \frac{71}{41},\quad \frac{97}{56},\quad \dots 
\end{equation*}
by a tedious computation to be made easier in a moment.
How are these convergents as approximations of $\sqrt 3$?  We
have\label{rt3} 
\begin{alignat*}2
  \left(\frac53\right)^2&=\frac{25}9,&25-3\cdot9&=-2,\\
  \left(\frac74\right)^2&=\frac{49}{16},&49-3\cdot16&=1,\\
  \left(\frac{19}{11}\right)^2&=\frac{361}{121},&361-3\cdot121&=-2,\\
  \left(\frac{26}{15}\right)^2&=\frac{676}{225},&676-3\cdot225&=1,\\
  \left(\frac{71}{41}\right)^2&=\frac{5041}{1681},\quad&5041-3\cdot1681&=-2.
\end{alignat*}
We shall define $p_k$ and $q_k$ so that
\begin{equation}\label{eqn:convergent}
  \frac{p_k}{q_k}=[a_0;a_1,\dots,a_k],
\end{equation}
the $k$th convergent of $[a_0;a_1,\dots]$.  We start with
\begin{align}\notag
  \frac{p_0}{q_0}&=a_0,& p_0&=a_0,& q_0&=1;\\\label{eqn:p1q1}
\frac{p_1}{q_1}&=a_0+\frac1{a_1}=\frac{a_0a_1+1}{a_1},&
p_1&=p_0a_1+1,& q_1&=a_1;\\\notag
\frac{p_2}{q_2}&=a_0+\cfrac1{a_1+\cfrac1{a_2}}
=\frac{a_0a_1a_2+a_0+a_2}{a_1a_2+1},& p_2&=p_1a_2+p_0,&
q_2&=q_1a_2+q_0.
\end{align}
Following this pattern, we define
\begin{equation}\label{eqn:pq}
%\frac{p_{k+2}}{q_{k+2}}=\frac{p_{k+1}a_{k+2}+p_k}{q_{k+1}a_{k+2}+q_k},
  p_{k+2}=p_{k+1}a_{k+2}+p_k,\qquad q_{k+2}=q_{k+1}a_{k+2}+q_k.
\end{equation}

\begin{theorem}\label{varN}\label{thm:pq}
Equation~\eqref{eqn:convergent} holds for all $k$ in $\varN$.
\end{theorem}

\begin{proof}
Use induction.  The claim holds when $k=0$.  By assuming the claim for
some $k$, we can compute %$p_{k+3}/q_{k+3}$ 
$[a_0;a_1,\dots,a_{k+3}]$
from it, replacing $a_{k+2}$
with $a_{k+2}+1/a_{k+3}$:
\begin{align*}
%  \frac{p_{k+3}}{q_{k+3}}
[a_0;a_1,\dots,a_{k+3}]=
\frac{p_{k+1}\cdot
  \left(a_{k+2}+\displaystyle\frac1{a_{k+3}}\right)+p_k}
     {q_{k+1}\left(a_{k+2}+\displaystyle\frac1{a_{k+3}}\right)+q_k}
&=
\frac{p_{k+1}a_{k+2}a_{k+3}+p_{k+1}+p_ka_{k+3}}
     {q_{k+1}a_{k+2}a_{k+3}+q_{k+1}+q_ka_{k+3}}\\
&=
\frac{p_{k+2}a_{k+3}+p_{k+1}}{q_{k+2}a_{k+3}+q_{k+1}}.
\end{align*}
By induction, we have~\eqref{eqn:convergent} for all $k$.
\end{proof}

Is $p_k/q_k$ in lowest terms?

\begin{theorem}\label{thm:-1}
  The integers $p_k$ and $q_k$ are co-prime; in fact,
  \begin{equation*}
    \frac{p_{k+1}}{q_{k+1}}-\frac{p_k}{q_k}=\frac{(-1)^k}{q_{k+1}q_k},
  \end{equation*}
equivalently,
\begin{equation*}
  p_{k+1}q_k-p_kq_{k+1}=(-1)^k.
\end{equation*}
\end{theorem}

\begin{proof}
  Again use induction.  We have
  \begin{equation*}
    \frac{p_1}{q_1}-\frac{p_0}{q_0}=\frac1{a_1}=\frac{(-1)^0}{q_1q_0},
  \end{equation*}
so the claim holds when $k=0$.  Suppose it holds for some $k$.  Then
\begin{equation*}
  p_{k+2}q_{k+1}-p_{k+1}q_{k+2}
  =(p_{k+1}a_{k+2}+p_k)q_{k+1}-p_{k+1}(q_{k+1}a_{k+2}+q_k)  
  =p_kq_{k+1}-p_{k+1}q_k,
\end{equation*}
which is $=-(-1)^k$ or $(-1)^{k+1}$.  Thus
the claim holds for all $k$.
\end{proof}

\begin{corollary}
$\{p_{2n}/q_{2n}\}$ is increasing, and $\{p_{2n+1}/q_{2n+1}\}$ is
  decreasing, and
  \begin{equation*}
\frac{p_0}{q_0}<\frac{p_2}{q_2}<\dotsb<\frac{p_3}{q_3}<\frac{p_1}{q_1}.
  \end{equation*}
The two sequences converge to the same limit.  If the convergents are
obtained as above from $x$, then their limit is $x$.
\end{corollary}
Now we are justified in writing~\eqref{eqn:rt3}, for example.

\asterism{}

\topic{Pell equation}

With these tools, we turn now to the \defn{Pell equation},
\begin{equation}\label{eqn:pell}
  x^2-dy^2=1.
\end{equation}
We first take care of some trivial cases:
\begin{enumerate}
  \item
If $d<-1$, then $(x,y)=(\pm1,0)$.
\item
If $d=-1$, then $(x,y)$ is $(\pm1,0)$ or $(0,\pm1)$.
\item
If $d=0$, then $x=\pm1$, while $y$ is anything.
\item
If $d$ is a positive square, as $a^2$, then $1=(x+ay)(x-ay)$, so $x\pm
ay$ are alike $\pm1$, and therefore $y=0$ and $x=\pm1$.
\end{enumerate}
Henceforth we assume $d$ is a positive non-square.
Then~\eqref{eqn:pell} still has the solution $(\pm1,0)$; but perhaps
it has others too.  Indeed,
in case $d=3$, we found (on p.~\pageref{rt3}) solutions $(49,16)$ and
$(676,225)$, with a possibility of
finding more if the pattern continues.

Suppose $(a,b)$ and $(s,t)$ are solutions to~\eqref{eqn:pell}.  Then
\begin{equation*}
  a^2-db^2=1,\qquad s^2-dt^2=1,
\end{equation*}
so multiplication gives
\begin{equation}\label{eqn:pell-identity}
  1=  (a^2-db^2)(s^2-dt^2)=(as\pm dbt)^2-d(at\pm bs)^2,
\end{equation}
so $(as\pm dbt,at\pm bs)$ is a solution.  We can repeat this process
on $(a,b)$ as follows.  We can define the ordered pair $(a_n,b_n)$ of
integers by
\begin{equation*}
  a_n+b_n\sqrt d=(a+b\sqrt d)^n.
\end{equation*}
Then also $a_n-b_n\sqrt d=(a-b\sqrt d)^n$, so
\begin{equation*}
a_n{}^2-db_n{}^2=(a_n+b_n\sqrt d)(a_n-b_n\sqrt d)=(a+b\sqrt
d)^n(a-b\sqrt d)^n=(a^2-b^2d)^n=1,   
\end{equation*}
and $(a_n,b_n)$ is a solution.  If $a+b\sqrt d>1$, then these
solutions $(a_n,b_n)$ must all be distinct.

We ask now:  Is there \emph{one} solution $(a,b)$ such that $a+b\sqrt
d>1$? 

\begin{lemma}
  If $d$ is a positive non-square, then, for some positive $k$, the equation
  \begin{equation}\label{eqn:pell-k}
    x^2-dy^2=k
  \end{equation}
has infinitely many solutions.
\end{lemma}

\begin{proof}
  Let $(p_n/q_n\colon n\in\varN)$ be the sequence of convergents for
  $\sqrt d$.
  When $n$ is odd, we have
  \begin{align*}
    0<\frac{p_n}{q_n}-\sqrt d&<\frac{p_n}{q_n}-\frac{p_{n+1}}{q_{n+1}}=
    \frac1{q_{n+1}q_n}<\frac1{q_n{}^2}, \\
    0<\frac{p_n}{q_n}+\sqrt d&<\frac{2p_n}{q_n};
  \end{align*}
multiplying gives
\begin{equation*}
0<  \frac{p_n{}^2}{q_n{}^2}-d<\frac{2p_n}{q_n{}^3},\qquad
0<p_n{}^2-dq_n{}^2<\frac{2p_n}{q_n}<\frac{2p_1}{q_1}.
\end{equation*}
Thus there are finitely many possibilities for $p_n{}^2-dq_n{}^2$, so
one of them must be realized infinitely many times.
\end{proof}

If $(a,b)$ solves~\eqref{eqn:pell}, and each of $a$ and $b$ is
positive, then let us refer to $(a,b)$ as a \defn{positive}{} solution.

\begin{lemma}\label{lem:pos-sol}
If $d$ is a positive non-square,
then the equation~\eqref{eqn:pell} has a positive solution.  
\end{lemma}

\begin{proof}
  By the previous lemma, we may let $k$ be a positive number such
  that~\eqref{eqn:pell-k} has infinitely many solutions.  But there
  are just finitely many pairs $(a,b)$ such that $0\leq a<k$ and
  $0\leq b<k$.  Hence there must be one such pair for
  which~\eqref{eqn:pell-k} together with the congruences
  \begin{equation*}
    x\equiv a,\quad y\equiv b\pmod k
  \end{equation*}
have infinitely many solutions.  Let $(m,n)$ and $(s,t)$ be two such
solutions.  Then by the identity in~\eqref{eqn:pell-identity}, we have
\begin{equation*}
  k^2=(m^2-dn^2)(s^2-dt^2)=(ms-dnt)^2-d(mt-ns)^2.
\end{equation*}
But we have also
\begin{equation*}
  ms-dnt\equiv m^2-dn^2\equiv0,\quad mt-ns\equiv mn-nm\equiv0\pmod k.
\end{equation*}
So we can divide by $k^2$ to get
\begin{equation*}
  1=\left(\frac{ms-dnt}k\right)^2-d\left(\frac{mt-ns}k\right)^2.
\end{equation*}
Hence $(\size{ms-dnt}/k,\size{mt-ns}/k)$ is a positive solution
to~\eqref{eqn:pell}. 
\end{proof}

\begin{theorem}
  If $d$ is a positive non-square, 
let $(a,b)$ be the positive
  solution $(\ell,m)$ of~\eqref{eqn:pell} for which $\ell+m\sqrt d$ is
  minimized. 
Then the equation~\eqref{eqn:pell}
  has just the solutions $(s,t)$, where $(\size s,\size t)=(a_n,b_n)$
  for some non-negative integer $n$,
  where $a_n+b_n\sqrt d=(a+b\sqrt d)^n$.  
\end{theorem}

\begin{proof}
  Let $(a,b)$ be as in the statement.  (It exists by
  Lemma~\ref{lem:pos-sol}.)  Then $a+b\sqrt d>1$, so the powers of
  $a+b\sqrt d$ grow
  arbitrarily large.  We know that all of the $(a_n,b_n)$ are
  solutions of~\eqref{eqn:pell}.  Let $(s,t)$ be an arbitrary positive
  solution.  Then
  \begin{equation*}
    (a+b\sqrt d)^n\leq s+t\sqrt d<(a+b\sqrt d)^{n+1}
  \end{equation*}
for some non-negative $n$.  Since $(a+b\sqrt d)(a-b\sqrt d)=1$, and
$a+b\sqrt d$ is positive, so is $a-b\sqrt d$.  We can therefore
multiply by the $n$th power of this, getting
\begin{equation*}
  1\leq(s+t\sqrt d)(a-b\sqrt d)^n<a+b\sqrt d.
\end{equation*}
But we have
\begin{equation*}
  (s+t\sqrt d)(a-b\sqrt d)^n=\ell+m\sqrt d
\end{equation*}
for some $\ell$ and $m$, and then also $(s-t\sqrt d)(a+b\sqrt
d)^n=\ell-m\sqrt d$.  Hence $\ell^2-m^2d=1$, so $(\ell,m)$ is a
solution of~\eqref{eqn:pell}.  But we have
\begin{equation*}
  1\leq \ell+m\sqrt d<a+b\sqrt d.
\end{equation*}
Hence $0\leq\ell-m\sqrt d\leq 1$, so neither $\ell$ nor $m$ can be
negative.  By minimality of $a+b\sqrt d$, we must have $\ell+m\sqrt
d=1$, so $(s,t)=(a_n,b_n)$. 
\end{proof}

\section{March 4, 2008 (Tuesday)}

\topic{Quadratic fields}
If $F_1$ is a subfield of a field $F_2$, then $F_2$ is a
vector-space over $F_1$: the dimension is denoted by
\begin{equation*}
  [F_2:F_1].
\end{equation*}
\label{K}\index{$K$ (a quadratic field, usually $\Q(\sqrt d)$)} 
If $K$ is a field such that $\Q\included K$, and $[K:\Q]=2$, we say
$K$ is a \defn{quadratic field}.

Suppose $K$ is a quadratic field.  In particular, there is $x$ in
$K\setminus\Q$.  Then $1$ and $x$ are linearly independent over $\Q$,
so $\{1,x\}$ must be a basis of $K$ over $\Q$.  In particular,
\begin{equation*}
  x^2+bx+c=0
\end{equation*}
for some $b$ and $c$ in $\Q$, so
\begin{equation*}
  x=\frac{-b\pm\oldsqrt{b^2-4c}}2.
\end{equation*}
Then $\oldsqrt{b^2-4c}\in K\setminus\Q$.  We can write $b^2-4c$ as
$s^2d$, where $s\in\Q$ and $d$%
\index{$d$ (a \sqf{} element of $\Z$, not $1$)} 
is a \sqf{} integer different from $1$.
Then $\sqrt d\in 
K\setminus\Q$, so $\{1,\sqrt d\}$ is a basis of $K$, and
\begin{equation*}
  K=\{x+y\sqrt d\colon x,y\in\Q\}.
\end{equation*}
Also, $K$ is the smallest subfield of $\C$%
\label{C}\index{$\C$ (the field of complex numbers)} 
that contains $\sqrt d$; so we can denote $K$ by%
\label{Q(rt d)}\index{$\Q(\sqrt d)$} 
\begin{equation*}
  \Q(\sqrt d).
\end{equation*}
It is an exercise to check that, conversely, we always have
\begin{equation*}
  \Q(\sqrt d)=\{x+y\sqrt d\colon x,y\in\Q\}.
\end{equation*}
In particular, if $a,b\in\Q$, and $b\neq0$, then, assuming $d$ is not
a square, we have
\begin{equation*}
  \frac1{a+b\sqrt d}=\frac{a-b\sqrt d}{a^2-b^2d}= \frac
  a{a^2-b^2d}-\frac
  b{a^2-b^2d}\sqrt d.  
\end{equation*}
So non-zero elements of $\{x+y\sqrt d\colon
x,y\in\Q\}$ have multiplicative inverses. 

A rational number is an integer if and only if it satisfies an
equation
\begin{equation*}
  x+c=0,
\end{equation*}
where $c\in\Z$.\index{$\Z$ (the ring of rational integers)}  This is a
trivial observation, but it motivates the
following definition.
An element of a quadratic field is an
\defn{integer}{} of that field if it is an integer in the old sense, or
else it satisfies an equation
\begin{equation*}
  x^2+bx+c=0,
\end{equation*}
where $b,c\in\Z$.  Henceforth, integers in the old sense can be called
\defn{rational integer}{s.}  More generally, an \defn{algebraic
  integer}{} is the root of an equation
\begin{equation*}
  x^n+a_1x^{n-1}+\dotsb+a_{n-1}x+a_n=0,
\end{equation*}
where $a_i\in\Z$; but we shall not go beyond the quadratic case,
$n=2$. 

\asterism{}

\topic{Gaussian integers}

The integers of $\Q(\mi)$, that is,
$\Q(\sqrt{{-1}})$, are called the \defn{Gaussian integer}{s.}  The
subset $\{x+y\mi\colon x,y\in \Z\}$ of $\Q(\mi)$ is denoted
by\label{gi}\index{$\gi$ (the ring of Gaussian integers)} 
\begin{equation*}
  \gi.
\end{equation*}

\begin{theorem}
  The Gaussian integers compose the set $\gi$.
\end{theorem}

\begin{proof}
  Let $\alpha=m+n\mi$.  Then $(\alpha-m)^2=(n\mi)^2=-n^2$, so
  $\alpha^2-2m\alpha+
  m^2+n^2=0$, and $\alpha$ is a Gaussian
  integer. 

Suppose conversely $\alpha$ is a Gaussian integer.  Then
$\alpha^2+b\alpha+c=0$ (by definition) for some $b$ and $c$ in $\Z$.
Hence
\begin{equation*}
  \alpha=\frac{-b\pm\oldsqrt{b^2-4c}}2.
\end{equation*}
We must have $\alpha\in\Q(\mi)$.  So $\pm(b^2-4c)$ is a square in
  $\Z$.  Say $b^2-4c=\pm e^2$.  Then
  \begin{equation*}
    b^2\mp e^2=4c\equiv 0\pmod 4;\qquad b\equiv e\pmod 2.
  \end{equation*}
Also,
\begin{equation*}
  \alpha=\frac{-b\pm e}2\quad\text{ or }\quad\alpha=\frac{-b\pm e\mi}2.
\end{equation*}
If $b\equiv e\equiv 0\pmod 2$, then $\alpha$ is in $\Z$ or
$\Z\oplus\Z\mi$. If $b\equiv e\equiv 1\pmod2$, then $4\ndivides
b^2+e^2$, so $b^2-e^2=4c$, which means $b^2-4c=e^2$, so that
$\alpha\in\Z$. 
\end{proof}

It is an exercise
to check that $\gi$ is a ring.
But multiplicative inverses may fail to exist in
$\gi$.  For example, $2\in\gi$, but $1/2\notin\gi$.

The \defn{norm}{} on $\Q(\mi)$ is the function given by%
\index{$\norm x$}
\begin{equation}\label{eqn:norm}
  \norm{a+b\mi}=a^2+b^2=\size{a+b\mi}^2;
\end{equation}
so its values are non-negative rational numbers, and
\begin{equation*}
  \norm{\alpha\beta}=\norm{\alpha}\norm{\beta}.
\end{equation*}
Note that
\begin{equation*}
  \frac1{a+b\mi}=\frac{a-b\mi}{a^2+b^2}=\frac{a-b\mi}{\norm{a+b\mi}}.
\end{equation*}
Hence
  \begin{equation*}
  \frac1{a+b\mi}\in\gi\Iff
  \norm{a+b\mi}=\pm1\Iff \norm{a+b\mi}=1.  
  \end{equation*}
So $a+b\mi$ is a unit of
  $\gi$ if and only if $a^2+b^2=1$, and the unit Gaussian
  integers are $\pm1$ and $\pm\mi$.   


\section{March 7, 2008 (Friday)}

\topic{Euclidean domains}
An \defn{integral domain}{} (\emph{taml\i k alan\i}), or simply a
\defn{domain}, is a sub-ring of a field.  For us, the
field will usually be $\C$.  
As an example, $\gi$ is an integral domain.  
A \tech{Euclidean domain}{} is a domain
in which the Euclidean algorithm works.  This means we can perform
division with remainder, where the remainder is ``smaller''
than the divisor; and a sequence of remainders of decreasing size must
terminate.  Since decreasing sequences of natural numbers must
terminate, we shall use natural numbers to measure size.  So, formally, a
domain $R$ is a \defn{Euclidean domain}{} if there is a function
$x\mapsto\edeg x$,%
\index{$\edeg x$}
 the \defn{degree}, from $R\setminus\{0\}$ into
$\N$\index{$\N$ (the set $\{x\in\Z\colon x\geq 0\}$)}
such that, for all $\alpha$ and $\beta$ in $R$,
if $\beta\neq0$, then the system
\begin{equation*}
  \alpha=\beta x+y\land \edeg y<\edeg{\beta}
\end{equation*}
is soluble in $R$.

Gaussian integers have
a size, namely the absolute value, but this need not be a rational
integer.  The square is, however.  So we let $\edeg x$ be the norm
$\norm x$ as in~\eqref{eqn:norm}.

\begin{theorem}
  $\gi$ with $x\mapsto\norm x$ is a Euclidean domain.
\end{theorem}

\begin{proof}
  Given $\alpha$ and $\beta$ in $\gi$, where $\beta\neq0$, we must
  solve
\begin{equation*}
  \alpha=\beta x+y\land \norm y<\norm{\beta}
\end{equation*}
The Gaussian-integral multiples of $\beta$ compose a square \defn{lattice}{}
(\emph{kafes}) in $\C$, as in Figure~\ref{fig:Gmult}.
\begin{figure}[ht]
  \begin{pspicture}(-3,-2)(4,5)
%\psgrid
\psline{->}(-3,0)(4,0)
\psline{->}(0,-2)(0,5)
\psdots(-1,3.4)
\uput[l](-1,3.4){$\alpha$}
\psset{unit=4mm}
    \psdots
          (-6, 8)(-2,11)
   (-7, 1)(-3, 4)( 1, 7)(5,10)
   (-4,-3)( 0, 0)( 4, 3)(8, 6)
          ( 3,-4)( 7,-1)
\uput[r](4,3){$\beta$}
\uput[l](-3,4){$\beta\mi$}
\uput[l](-2,11){$\gamma$}
  \end{pspicture}
\caption{A lattice of Gaussian multiples}\label{fig:Gmult}
\end{figure}
Then $\alpha$ is in one of the squares whose vertices are among these
multiples.  
The closest vertex to $\alpha$
is some $\gamma$ such that
\begin{equation*}
  \size{\alpha-\gamma}\leq\frac{\sqrt 2}2\size{\beta},\qquad
\norm{\alpha-\gamma}\leq\frac12\norm{\beta}.
\end{equation*}
So our solution is $(\gamma/\beta,\alpha-\gamma)$.  
\end{proof}

Doing the proof more algebraically, we have $\alpha/\beta=r+s\mi$ for
some $r$ and $s$ in $\Q$.  There are $m$ and $n$ in $\Z$ such that
$\size{r-m},\size{s-n}\leq1/2$. Then
\begin{equation*}
  \norm{\alpha-\beta(m+n\mi)}
=\norm{\beta}\norm{\frac{\alpha}{\beta}-(m+n\mi)}
=\norm{\beta}\norm{r-m+(s-n)\mi}
\leq\frac12\norm{\beta}.
\end{equation*}

Now we can find \tech{greatest common divisor}s in $\gi$.  In any
domain, a \defn{greatest common divisor}{} of two elements $\alpha$
and $\beta$, not both $0$, is a common divisor that is divisible by
every other common divisor.  This greatest common divisor need not be
unique.  Two greatest common divisors divide each other and so are called
\defn{associate}{s.}  Conversely, the associate of a greatest common
divisor is a greatest common divisor.

\begin{problem}
  In $\gi$, find a greatest common divisor of $7+6\mi$ and
  $-1+7\mi$.
\end{problem}

  \begin{solution}
We can compute thus:
  \begin{gather*}
    \frac{7+6\mi}{-1+7\mi}=\frac{(7+6\mi)(-1-7\mi)}{50}=\frac{35-55\mi}{50}
=\frac{7-11\mi}{10}
%=\frac{10-3-(10+1)\mi}{10}
=1-\mi+\frac{-3-\mi}{10},\\
7+6\mi=(-1+7\mi)(1-\mi)+\frac{(-1+7\mi)(-3-\mi)}{10}
=(-1+7\mi)(1-\mi)+1-2\mi,\\
\frac{-1+7\mi}{1-2\mi}=
\frac{(-1+7\mi)(1+2\mi)}5=-3+\mi.
  \end{gather*}
So $1-2\mi$ is a greatest common divisor of  $7+6\mi$ and
  $-1+7\mi$.  The others are obtained by multiplying by the units of
  $\gi$, namely $\pm1$ and $\pm\mi$.  So the $\gcd$'s are
  $\pm(1-2\mi)$ and $\pm(2+\mi)$.
  \end{solution}


\section{March 11, 2008 (Tuesday)}

\topic{Unique-factorization domains}
All Euclidean domains are \tech{principal-ideal domain}{s,} and all
principal-ideal domains are \defn{unique-factorization domain}{s;}
therefore $\gi$ is a unique-factorization domain.  But we can prove
this directly, using that
\begin{equation*}
  \norm{\xi\eta}=\norm{\xi}\norm{\eta}.
\end{equation*}
First, an element of any domain, other than $0$ or a unit, is
\defn{irreducible}{} if its only divisors are itself and units.
Suppose $\alpha$ is a reducible Gaussian integer.  Then
\begin{equation*}
  \alpha=\beta\gamma
\end{equation*}
for some $\beta$ and $\gamma$, neither of which is a unit.  But then
$\norm{\beta}$ and $\norm{\gamma}$ are greater than $1$, so
\begin{equation*}
  1<\norm{\beta}<\norm{\alpha},\qquad
  1<\norm{\gamma}<\norm{\alpha}.
\end{equation*}
Since there is no infinite strictly decreasing sequence of natural
numbers, the process of factorizing the factors of $\alpha$ as
products of non-units must terminate.  Thus $\alpha$ can be written as
a product of irreducible factors.

The definition of unique-factorization domain requires that irreducible
factorizations must be unique.  This means, if
\begin{equation*}
  \alpha_0\alpha_1\dotsm\alpha_m=\beta_0\beta_1\dotsm\beta_n,
\end{equation*}
where each $\alpha_i$ and each $\beta_j$ are irreducible, then each
$\alpha_i$ must be an associate of some $\beta_j$.  To prove this for
$\gi$, it is enough to show that each irreducible Gaussian integer is
\tech{prime}.  In any domain, an element $\alpha$ (not $0$ or a unit)
is \defn{prime}, provided
\begin{equation*}
  \alpha\divides\beta\gamma\land\alpha\ndivides\beta\implies
  \alpha\divides\gamma.  
\end{equation*}
In $\gi$, suppose $\alpha$ is irreducible, and
$\alpha\divides\beta\gamma\land\alpha\ndivides\beta$.  Then the
greatest common divisors of $\alpha$ and $\beta$ are just the units,
and we have
\begin{equation*}
  \alpha\xi+\beta\eta=1
\end{equation*}
for some $\xi$ and $\eta$ in $\gi$.  But then
\begin{equation*}
  \alpha\gamma\xi+\beta\gamma\eta=\gamma,
\end{equation*}
and since $\alpha$ divides the two summands on the left, it divides
$\gamma$. 

\topic{Gaussian primes}
We now ask:  What are the primes of $\gi$?  Suppose $\pi$%
\index{$\pi$ (an arbitrary prime of $\gi$)}
is one of
them.  Then $\pi$ is not a unit, so $\norm{\pi}$ has rational-prime
factors.  But
\begin{equation*}
  \pi\cc{\pi}=\norm{\pi}.
\end{equation*}
Therefore, since $\pi$ is prime, we have
\begin{equation*}
  \pi\divides p
\end{equation*}
for some rational-prime factor of $\norm{\pi}$.  If $q$ is another
rational prime, then $ap+bq=1$ for some rational integers $a$ and
$b$.  Since $\pi\ndivides 1$, it must be that $\pi\ndivides q$.  Thus
$p$ is unique.

We now consider three cases:
\begin{enumerate}
  \item
$p=2$;
\item
$p\equiv 3\pmod 4$;
\item
$p\equiv 1\pmod 4$.
\end{enumerate}
We have
\begin{equation*}
  2=(1+\mi)(1-\mi).
\end{equation*}
Also, $1\pm\mi$ must be irreducible, since $\norm{1\pm\mi}=2$ (so if
$1\pm\mi=\alpha\beta$, then $\alpha$ or $\beta$ must have norm $1$ and
so be a unit).  So we have the unique prime factorization of $2$.
Also $1+\mi$ and $1-\mi$ are associates.  Hence the only prime
divisors of $2$ are the four associates
\begin{equation*}
  1+\mi,\quad 1-\mi,\quad -1+\mi,\quad-1-\mi.
\end{equation*}
Now suppose $p\equiv3\pmod 4$, and $\pi\divides p$.  Then
$\norm{\pi}\divides\norm p$, that is,
\begin{equation*}
  \pi\cc{\pi}\divides p^2.
\end{equation*}
So $\pi\cc{\pi}$ is either $p^2$ or $p$.  But the latter is
impossible, since $\norm{\pi}=x^2+y^2\equiv0,1,$ or $2\pmod 4$.
Therefore 
\begin{equation*}
  \pi\cc{\pi}=p^2.
\end{equation*}
But $\pi\cc{\pi}$ is a prime factorization, so it is unique.
Therefore $\pi$ and $\cc{\pi}$ are associates of $p$ and hence of each
other.  In short, $p$ is a Gaussian prime.

Finally, suppose $p\equiv1\pmod 4$.  Then $-1$ is a quadratic residue
\emph{modulo} $p$, so $-1\equiv x^2\pmod p$ for some $x$, that is,
$p\divides 1+x^2$, and therefore
\begin{equation*}
  p\divides(1+x\mi)(1-x\mi).
\end{equation*}
But $(1\pm x\mi)/p$ is \emph{not} a Gaussian integer.  Therefore $p$
must not be a Gaussian prime.  Consequently, if $\pi$ is a prime
factor of $p$, then $\norm{\pi}=p$, that is,
\begin{equation*}
  \pi\cc{\pi}=p.
\end{equation*}
This is a prime factorization.  Moreover, $\pi$ and $\cc{\pi}$ are not
associates.  Indeed, $\pi=x+y\mi$ for some rational integers $x$ and
$y$, so that
\begin{equation*}
  \frac{\pi}{\cc{\pi}}=\frac{(x+y\mi)^2}p=\frac{x^2-y^2+2xy\mi}p.
\end{equation*}
If this is a Gaussian integer, then $p\divides 2xy$, so $p\divides xy$
(since $p$ is odd), so $p<x^2+y^2=p$, which is absurd.  We have now
shown:

\begin{theorem}
  The Gaussian primes are precisely the associates of the following:
  \begin{enumerate}
    \item
$1+\mi$;
\item
the rational primes $p$, where $p\equiv3\pmod 4$;
\item
$\alpha$, where $\norm{\alpha}$ is a rational prime $p$ such that
  $p\equiv1\pmod 4$ (and two such non-associated $\alpha$ exist for
  every such $p$). 
  \end{enumerate}
\end{theorem}

If $n$ is a positive rational integer, then the Diophantine equation
\begin{equation}\label{eqn:x2y2n}
  x^2+y^2=n
\end{equation}
is soluble if and only if the equation
\begin{equation}\label{eqn:norm=n}
  \norm{\xi}=n
\end{equation}
is soluble, where $\xi$ is a Gaussian integer.  Moreover, there is a
bijection $(x,y)\mapsto x+y\mi$ between the solution-sets.  We now have an
alternative proof, using general theory, that, when $n$ is a rational
prime $p$, then~\eqref{eqn:x2y2n} has a solution if and only if $p=2$
or $p\equiv 
1\pmod 4$.

Indeed, if $n=p\equiv1\pmod4$, then~\eqref{eqn:norm=n} has exactly 8
solutions: the associates of $\pi$ for some prime $\pi$, and the
associates of $\cc{\pi}$.  Then the solutions when $n=p^2$ are the
associates of $\pi^2$, of $\pi\cc{\pi}$, and of ${\cc{\pi}}^2$, so
there are 12 solutions.  But if $p\neq q\equiv1\pmod4$, then there are
16 solutions when $n=pq$.

\begin{lemma}\label{lem:4}
  The number of solutions of~\eqref{eqn:x2y2n} is $4(a-b)$, where
  \begin{equation*}
    a=\size{\{x\in\N\colon x\divides n\land n\equiv 1\}},\qquad
    b=\size{\{x\in\N\colon x\divides n\land n\equiv 3\}},
  \end{equation*}
the modulus being $4$.
\end{lemma}

\begin{proof}
  Exercise.
\end{proof}

\index{$\mpi$ (the circumference of the unit circle)}% 
\begin{theorem}\label{mpi}
Let $\mpi$ be the circumference of the unit circle; then
\begin{equation*}
\frac{\mpi}{4}=1-\frac13+\frac15-\frac17+\dotsb
\end{equation*}
\end{theorem}

\begin{proof}
  The area of a circle of radius $r$ is $\mpi r^2$.  Hence
  \begin{equation*}
    \mpi
    r^2\approx\size{\{\xi\in\gi\colon1\leq\size{\xi}\leq
    r\}}
=\sum_{n=1}^{r^2}\size{\{\xi\in\gi\colon\norm{\xi}=n\}}.
  \end{equation*}
(See Figure~\ref{fig:counting}.)
  \begin{figure}[ht]
    \begin{pspicture}(-4,-4)(4,4)
      \pscircle(0,0)3
%\psset{fillstyle=solid,fillcolor=black}
\multirput*(-4,-4)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-4,-3)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-4,-2)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-4,-1)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-4,0)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-4,1)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-4,2)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-4,3)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-4,4)(1,0)9{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
    \end{pspicture}
\caption{Estimating the area of a circle}\label{fig:counting}
  \end{figure}
By Lemma~\ref{lem:4}, to this number, each positive $4m+1$ contributes
$4$ for each of its multiples between $1$ and $r^2$, while each
positive $4m+3$ takes away $4$ for each such multiple.  Therefore
\begin{equation*}
\frac{\mpi r^2}4
\approx\sum_{n=0}^{\infty}\left(\left[\frac{r^2}{4n+1}\right]-
\left[\frac{r^2}{4n+3}\right]\right)
=r^2-\left[\frac{r^2}3\right]+
    \left[\frac{r^2}5\right]-\left[\frac{r^2}7\right]+\dotsb
\end{equation*}
Dividing by $r^2$ and taking the limit yields the claim.
(For details, see~\cite{MR0046650}.)
\end{proof}

\asterism{}

Recall%
\topic{Arbitrary quadratic fields}
the Pell equation~\eqref{eqn:pell},
\begin{equation}\label{eqn:pell-again}
  1=x^2-dy^2=(x+y\sqrt d)(x-\sqrt d).
\end{equation}
This factorization suggests looking at $\Q(\sqrt d)$.  Let us assume
$d$ is \sqf{}. 

We may write $K$ for $\Q(\sqrt d)$; here $K$ is for the German
\emph{K\"orper} ``body'', the name in most languages (besides English)
for a field.

On $K$ we define $\xi\mapsto\xi'$ by
\begin{equation*}
  (a+b\sqrt d)'=a-b\sqrt d.
\end{equation*}
When $d<0$, this is complex conjugation.
We then define:
\begin{enumerate}
  \item\index{$\tr x$}
$\tr{\alpha}=\alpha+\alpha'$, the \defn{trace}{} of $\alpha$;
\item\index{$\norm x$}
$\norm{\alpha}=\alpha\alpha'$, the \defn{norm}{} of $\alpha$.
\end{enumerate}
These are rational numbers.  Indeed, if $\alpha=a+b\sqrt d$, then
\begin{equation*}
  \tr{\alpha}=2a,\qquad\norm{\alpha}=a^2-b^2d.
\end{equation*}
Also, $\alpha$ is a root of
\begin{equation*}
  (x-\alpha)(x-\alpha')
=x^2-(\alpha+\alpha')x+\alpha\alpha'=x^2-\tr{\alpha}x+\norm{\alpha}. 
\end{equation*}
If $\alpha\not\in\Q$, then this must be the \defn{minimal
  polynomial}{} of $\alpha$ over $\Q$, that is, the polynomial of
  least degree with rational coefficients, and leading coefficient
  $1$, of which $\alpha$ is a root.  (This must exist, since the ring
  $\Q[x]$ of polynomials is a Euclidean domain with respect to
  degree.)  Therefore, if $\alpha\in\Q(\sqrt d)\setminus\Q$, then the
  following are equivalent:
  \begin{enumerate}
    \item
$\alpha^2-m\alpha-n=0$ for some rational integers $m$ and $n$;
\item
$\tr{\alpha}$ and $\norm{\alpha}$ are rational integers.
  \end{enumerate}
So we have two equivalent conditions for being a an integer of
$\Q(\sqrt d)$.  The set of these integers can be denoted by%
\index{$\roi$}
\begin{equation*}
  \roi.
\end{equation*}
This is a ring, hence an integral domain, since if
$\tr{\alpha_i}$ and $\norm{\alpha_i}$ are in $\Z$, then so are
$\tr{\alpha_0+\alpha_1}$ and $\norm{\alpha_0+\alpha_1}$ and
$\tr{\alpha_0\alpha_1}$ and $\norm{\alpha_0\alpha_1}$ (exercise).

\section{March 14, 2008 (Friday)}

Moreover, $\norm{\alpha\beta}=\norm{\alpha}\norm{\beta}$.  This is
simply because $(\alpha\beta)'=\alpha'\beta'$.

Immediately, 
\begin{equation*}
\Z[\sqrt d]=\{x+y\sqrt d\colon x,y\in\Z\}\included\roi.
\end{equation*}
How about the reverse?  Suppose $\alpha=a+b\sqrt d\in\roi$.  Then
$2a,a^2-b^2d\in\Z$.  Consider two cases:
\begin{enumerate}
  \item
If $a\in\Z$, then $b^2d\in\Z$, so $b\in\Z$ (since $d$ is \sqf{}),
which means $\alpha\in\Z[\sqrt d]$.
\item
Suppose $a\not\in\Z$.  Then $2a$ is odd, so, \emph{modulo} $4$, we
have $4a^2\equiv(2a)^2\equiv1$.  But also $4a^2-4b^2d\equiv0$, so that
$(2b)^2d\equiv4b^2d\equiv4a^2\equiv1$.  Since $(2b)^2\equiv0$ or $1$,
we conclude $(2b)^2\equiv1$, hence $d\equiv1$.
\end{enumerate}

But now suppose $d\equiv1$.  We have shown, if $\alpha\not\in\Z[\sqrt
  d]$, that $2a$ and $2b$ are odd, so that
\begin{equation*}
  \alpha=a-b+b+b\sqrt d=a-b+2b\cdot\frac{1+\sqrt
  d}2\in\Z\Bigl[\frac{1+\sqrt d}2\Bigr].
\end{equation*}
Conversely, if $\alpha=(1+\sqrt d)/2$, then $(2\alpha-1)^2=d$, so
$4\alpha^2-4\alpha+1-d=0$, hence $\alpha^2-\alpha+(1-d)/4=0$, which
means $\alpha\in\roi$ (since $d\equiv1\pmod4$).  Thus:

\begin{theorem}
The ring of integers of $K$ is given by
  \begin{equation*}
\roi=
  \begin{cases}
    \Z[\sqrt d],&\text{ if }d\equiv2\text{ or }3\pmod 4;\\
\Z\Bigl[\displaystyle\frac{1+\sqrt
  d}2\Bigr],&\text{ if }d\equiv1\pmod 4.
  \end{cases}
  \end{equation*}
\end{theorem}

\asterism%\mbox{}

\topic{Quadratic forms}
Assuming $a,b,c\in\Q$, let
\begin{equation}\label{eqn:abc}
  f(x,y)=ax^2+bxy+cy^2;
\end{equation}
this is a \defn{binary quadratic form}.  We shall
investigate the rational-integral solutions of
\begin{equation*}
  f(x,y)=m,
\end{equation*}
where $m\in\Q$.  The Pell equation~\eqref{eqn:pell-again} is a special
case.  We can
factorize $f$ over a quadratic field by completing the square:
\begin{align*}
  f(x,y)
&=a\Bigl(x^2+\frac ba\cdot xy+\frac{b^2}{4a^2}\cdot
  y^2\Bigr)-\Bigl(\frac{b^2}{4a}-c\Bigr)y^2 \\
&=a\Bigl(x+\frac b{2a}\cdot y\Bigr)^2-\Bigl(\frac{b^2}{4a}-c\Bigr)y^2 \\
&=\frac1a\Bigl(ax+\frac b{2}\cdot
  y\Bigr)^2-\frac1a\Bigl(\frac{b^2}{4}-ac\Bigr)y^2 \\ 
&=\frac1a\biggl[\Bigl(ax+\frac b{2}\cdot
  y\Bigr)^2-\frac D4\cdot y^2\biggr]\\
\intertext{where $D=b^2-4ac$, the \defn{discriminant}{} of $f$.  Then}
f(x,y)
&=\frac1a\Bigl(ax+\frac b2\cdot y+\frac{\sqrt D}2\cdot y\Bigr)
\Bigl(ax+\frac b2\cdot y-\frac{\sqrt D}2\cdot y\Bigr)\\
&=\frac1a\Bigl(ax+\frac{b+\sqrt D}2\cdot y\Bigr)
\Bigl(ax+\frac{b-\sqrt D}2\cdot y\Bigr).
\end{align*}
We can write $D$ as  $s^2d$, where $s\in\Q$, but $d$ is a \sqf{}
rational integer.  Working in $\Q(\sqrt d)$, letting
\begin{equation*}
  \alpha=a,\qquad \beta=\frac{b+\sqrt D}2=\frac{b+s\sqrt d}2,
\end{equation*}
we have
\begin{equation*}
  f(x,y)=\frac1a(\alpha x+\beta y)(\alpha'x+\beta'y)
  =\frac1a\norm{\alpha x+\beta y}.
\end{equation*}
Moreover, $\alpha$ and $\beta$ are linearly independent over $\Q$;
that is, the only rational solution to $\alpha x+\beta y=0$ is
$(0,0)$.  

For any $\alpha$ and $\beta$ in $K$ (which is $\Q(\sqrt d)$), let us
denote the set $\{\alpha 
x+\beta y:x,y\in\Z\}$ of all 
rational-integral linear combinations of $\alpha$ and $\beta$ by
\begin{equation*}
  \Z\alpha+\Z\beta\quad\text{ or }\quad\lat.
\end{equation*}\index{$\lat$}
If $\alpha$ and $\beta$ are linearly independent over $\Q$, then
  $\lat$ is a \defn{lattice}{} in $K$: that is, 
  $\lat$ is a \tech{free abelian subgroup}{} of $K$, and the
  number of generators is the dimension $[K:\Q]$.  For example, as a
  group, $\roi$ is the lattice $\lat[1,\omega]$,
  where\label{omega}\index{$\omega$ (generator of $\roi$ over $\Z$)}
  \begin{equation*}
    \omega=
    \begin{cases}
      \sqrt d,& \text{ if }d\equiv 2 \text{ or }3\pmod 4;\\
\displaystyle\frac{1+\sqrt d}2,& \text{ if }d\equiv1\pmod 4.
    \end{cases}
  \end{equation*}
Henceforth $\omega$ will always have this meaning.

In general, if $\mLambda$ is a lattice in $K$, let%
\index{$\End$}
\begin{equation*}
  \End=\{\xi\in\C\colon \xi\mLambda\included\mLambda\}.
\end{equation*}
This set is a sub-ring of $K$ and and can be understood as the ring of
\defn{endomorphism}{s} of the abelian group $\mLambda$.  That is, the
function $\xi\mapsto\alpha\xi$ is an endomorphism of $\mLambda$ if and
only if $\alpha\in\End$.
For example, if $\mLambda=\lat[1,\mi]$ in $\Q(\mi)$, then
$\End=\lat[1,\mi]$.  

But suppose $\mLambda=\lat[1,\tau]$,
where
\begin{equation*}
\tau=\frac{-1+\sqrt{{-7}}}4.
\end{equation*}
Then $(4\tau+1)^2=-7$, so $16\tau^2+8\tau+8=0$, or
$2\tau^2+\tau+1=0$.  Suppose $x+y\tau\in\End$.  Equivalently,
$\mLambda$ contains both $x+y\tau$ and $(x+y\tau)\tau$.  But
\begin{equation*}
  (x+y\tau)\tau=x\tau+y\tau^2=x\tau+y\frac{-\tau-1}2
  =-\frac y2+\Bigl(x-\frac y2\Bigr)\tau.
\end{equation*}
So $y$ must be even.  Conversely, this is enough to ensure
$x+y\tau\in\End$.  Thus
\begin{equation*}
  \End=\lat[1,2\tau].
\end{equation*}
See Figure~\ref{fig:lat-end}.
\begin{figure}[ht]
  \begin{pspicture}(-3,-3.5)(3,3)
%\psgrid
\psline{->}(-3,0)(3.5,0)
\psline{->}(0,-3)(0,3)
\multirput*(0,0)(-0.25,0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(1,0)(-0.25,0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(2,0)(-0.25,0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(3,0)(-0.25,0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-1,0)(-0.25,0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-2,0)(-0.25,0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
%
\multirput*(0,0)(0.25,-0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(1,0)(0.25,-0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(2,0)(0.25,-0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-3,0)(0.25,-0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-1,0)(0.25,-0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-2,0)(0.25,-0.661){5}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\rput*(3,2.646){\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\rput*(-3,-2.646){\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\uput[ur](1,0){$1$}
\uput[dl](-0.25,0.661){$\tau$}
  \end{pspicture}
\mbox{$\qquad\qquad$}
  \begin{pspicture}(-3,-3.5)(3,3)
%\psgrid
\psline{->}(-3,0)(3.5,0)
\psline{->}(0,-3)(0,3)
\psset{fillstyle=solid}
\multirput*(0,0)(-0.5,1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(1,0)(-0.5,1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(2,0)(-0.5,1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(3,0)(-0.5,1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-1,0)(-0.5,1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-2,0)(-0.5,1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
%
\multirput*(0,0)(0.5,-1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(1,0)(0.5,-1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(2,0)(0.5,-1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-3,0)(0.5,-1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-1,0)(0.5,-1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\multirput*(-2,0)(0.5,-1.323){3}{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\rput*(3,2.646){\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\rput*(-3,-2.646){\pscircle[fillstyle=solid,fillcolor=black]{0.05}}
\uput[ur](1,0){$1$}
\uput[dl](-0.50,1.323){$2\tau$}
  \end{pspicture}
\caption{A lattice and its endomorphisms}\label{fig:lat-end}
\end{figure}

\section{March 18, 2008 (Tuesday)}

\topic{Lattices and elliptic curves}
To give a sense for where things may lead (though not in this course;
but see for example~\cite{MR890960}):
In a more general sense, a \defn{lattice}{} is a subgroup
$\Z\alpha+\Z\beta$ or $\lat$ of $\C$ such that
$\alpha\neq0$ and $\beta/\alpha\not\in\R$.%
\index{$\R$ (the field of real numbers)}
  Let $\mLambda$ be such
a lattice.  Then we can form the quotient group $\C/\mLambda$.
Geometrically, this is the parallelogram with vertices $0$, $\alpha$,
$\beta$, and $\alpha+\beta$ (as in Figure~\ref{fig:fund-paral}),
with opposite edges identified:  
\begin{figure}[ht]
  \begin{pspicture}(-0.5,-0.5)(4.5,3.5)
    \psline(0,0)(3,1)(4,3)(1,2)(0,0)
    \uput[dl](0,0){$0$}
    \uput[ur](4,3){$\alpha+\beta$}
    \uput[dr](3,1){$\alpha$}
    \uput[ul](1,2){$\beta$}
  \end{pspicture}
\caption{A fundamental parallelogram of a lattice}\label{fig:fund-paral}
\end{figure}
thus it
is a \defn{torus}.  There is a function $\wp$, that is,
$\wp_{\mLambda}$: the \defn{Weierstra\ss{} function}, given by
\begin{equation*}
  \wp(z)=\frac1{z^2}+
  \sum_{\zeta\in\mLambda\setminus\{0\}}\Bigl(\frac1{(z-\zeta)^2}
  -\frac1{\zeta^2}\Bigr).
\end{equation*}
This is \defn{doubly periodic}, with period $\mLambda$: that is,
\begin{equation*}
  \zeta\in\mLambda\Iff\wp(z+\zeta)=\wp(z)\text{ for all }z.
\end{equation*}
Hence $\wp$ is well-defined as a function on the torus $\C/\mLambda$.
There are $g_2$ and $g_3$ (depending on $\mLambda$) in $\C$ such that
$(\wp(z),\wp'(z))$ solves the 
equation
\begin{equation*}
  y^2=4x^3-g_2x-g_3.
\end{equation*}
This equation defines an \defn{elliptic curve}{} (Figure~\ref{fig:elliptic}).  
\begin{figure}[ht]
  \begin{pspicture}(-3,-3)(3,3)
%\psgrid[subgriddiv=10]
\psset{linewidth=1.2pt,plotpoints=200}
\psplot{-2.103}{2.3}{x x x mul mul x 3 mul sub 3 add sqrt}
\psplot{-2.103}{2.3}{x x x mul mul x 3 mul sub 3 add sqrt neg}
\psline(-2.103,-0.1)(-2.103,0.1)
\psline(-3,-1)(3,-2)
\psdots(-1.97,-1.17)(0.21,-1.53)(1.77,-1.78)
\uput[dl](-1.97,-1.17){$P$}
\uput[ul](0.21,-1.53){$Q$}
\uput[ur](1.77,-1.78){$R$}
  \end{pspicture}
\caption{An elliptic curve}\label{fig:elliptic}
\end{figure}
This curve can be
made into a group by the rule that, if a straight line meets the curve
in $P$, $Q$, and $R$, then $P+Q+R=0$.  (Also, a vertical line meets the
curve at the `point at
infinity', which is defined to be the $0$ of the group.)  Then
$(\wp,\wp')$ is an isomorphism from $\C/\mLambda$ to
the elliptic curve.

An analytic endomorphism of $\C/\mLambda$ is a function $z\mapsto\alpha
z$, where $\alpha\in\C$, such that $\alpha\mLambda\included\mLambda$.
The set of these $\alpha$ 
is what we are calling $\End$.  Always $\Z\included\End$.  You can
show that $\Z=\End$ if and only if $\beta/\alpha$ is not
quadratic---not the root of some $x^2+bx+c$, where $b,c\in\Q$.

\asterism{}

We\topic{Quadratic lattices}
are interested in the quadratic case.  Again suppose $K=\Q(\sqrt
d)$, where $d$ is \sqf{}.  Say $\alpha,\beta\in K$, and $\lat$ is
a lattice $\mLambda$.  In particular then, $\alpha\neq0$ and
$\beta/\alpha\not\in\Q$. 
Every element $\alpha x+\beta y$ of $\mLambda$ is a matrix
product:
\begin{equation*}
  \alpha x+\beta y=
  \begin{pmatrix}
    x&y
  \end{pmatrix}
  \begin{pmatrix}
    \alpha\\\beta
  \end{pmatrix}.
\end{equation*}
Then
  $\lat[\gamma,\delta]\included\lat$ if and only if
\begin{equation*}
  \begin{pmatrix}
    \gamma\\\delta
  \end{pmatrix}=
  \begin{pmatrix}
    x&y\\z&w
  \end{pmatrix}
  \begin{pmatrix}
    \alpha\\\beta
  \end{pmatrix}
\end{equation*}
for some $x$, $y$, $z$, and $w$ in $\Z$.  Then 
  $\lat[\gamma,\delta]=\lat$ if and only if
\begin{equation*}
  \begin{pmatrix}
    \gamma\\\delta
  \end{pmatrix}=M
  \begin{pmatrix}
    \alpha\\\beta
  \end{pmatrix}
\end{equation*}
for some \emph{invertible} matrix $M$ over $\Z$: this means $\det
M=\pm1$.

Along with the sub-ring $\End$ of $K$, we have the sub-ring $\roi$.
What is the relation between the two rings?

\begin{lemma}\label{lem:end-in-roi}
  $\End\included\roi$.
\end{lemma}

\begin{proof}
  Suppose $\gamma\in\End$. Then there are $x$, $y$, $z$, and $w$ in
  $\Z$ such that
  \begin{equation*}
    \begin{pmatrix}
      x&y\\z&w
    \end{pmatrix}
    \begin{pmatrix}
      \alpha\\\beta
    \end{pmatrix}
=
    \gamma
    \begin{pmatrix}
      \alpha\\\beta
    \end{pmatrix}
=
\begin{pmatrix}
  \gamma&0\\0&\gamma
\end{pmatrix}
    \begin{pmatrix}
      \alpha\\\beta
    \end{pmatrix},\quad
    \begin{pmatrix}
      0\\0
    \end{pmatrix}
=
    \begin{pmatrix}
  \gamma-x&-y\\-z&\gamma-w    
    \end{pmatrix}
    \begin{pmatrix}
      \alpha\\\beta
    \end{pmatrix}.
  \end{equation*}
Hence the last square matrix is not invertible over any field, so its
determinant is $0$: that is,
\begin{equation*}
0=  (\gamma-x)(\gamma-w)-yz=\gamma^2-(x+w)\gamma+xw-yz.
\end{equation*}
Since the coefficients here belong to $\Z$, we have that
$\gamma\in\roi$.
\end{proof}

\asterism{}

\begin{problem}\label{prob:Pell}
\topic{Pell equation examples}
  Solve the Pell equation 
\begin{equation}\label{eqn:14}
x^2-14y^2=1.
\end{equation}
\end{problem}

\begin{solution}
We first find the continued fraction expansion
of $\rft$ by our algorithm:
\begin{alignat*}3
&&  a_0&=3,&\quad\xi_0&=\rft-3;\\
\frac1{\rft-3}&=\frac{\rft+3}5,\quad&\quad
a_1&=1,\quad&\quad\xi_1&=\frac{\rft-2}5;\\ 
\frac 5{\rft-2}&=\frac{\rft+2}2,&\quad
a_2&=2,&\quad\xi_2&=\frac{\rft-2}2;\\
\frac2{\rft-2}&=\frac{\rft+2}5,&\quad a_3&=1,&\quad\xi_3&=\frac{\rft-3}5;\\
\frac5{\rft-3}&=\rft+3,&\quad a_4&=6,&\quad\xi_4&=\rft-3=\xi_0;
\end{alignat*}
therefore
\begin{equation*}
  \rft=[3;\overline{1,2,1,6}].
\end{equation*}
For the convergents $p_n/q_n$, we have
\begin{equation*}
  \frac{p_0}{q_0}=\frac31,\qquad\frac{p_1}{q_1}=\frac41,\qquad
\frac{p_n}{q_n}=\frac{a_np_{n-1}+p_{n-2}}{a_nq_{n-1}+q_{n-2}},
\end{equation*}
so the list is
\begin{equation*}
  \frac31,\quad\frac41,
  \quad\frac{11}3,\quad\frac{15}4,\quad\frac{101}{27},\quad\dots  
\end{equation*}
Check for a solution to~\eqref{eqn:14}:
\begin{align*}
  3^2-14\cdot1^2&=-5,\\
4^2-14\cdot 1^2&=2,\\
11^2-14\cdot3^2&=121-126=-5,\\
15^2-14\cdot4^2&=225-(15-1)(15+1)=1.
\end{align*}
Then $15/4=[3;1,2,1]$, and $(15,4)$ solves~\eqref{eqn:14}.  This
is the positive solution $(a,b)$ for which $a+b\rft$ is least: we
shall prove this later, but meanwhile you can
check it by trying all pairs $(a,b)$ such that $0<a<15$
and $0<b<4$.  Then every positive solution is 
\begin{equation*}
(a_n,b_n), \text{ where }
a_n+b_n\rft=(15+4\rft)^n.
\end{equation*} 
Moreover, each of these solutions is $(p_{4n+3},q_{4n+3})$, and
\begin{equation*}
\frac{p_{4n+3}}{q_{4n+3}}=
  [3;\underbrace{\underbrace{1,2,1,6},\dots,\underbrace{1,2,1,6}}_n,1,2,1]
\end{equation*}
Indeed, if $(k,\ell)$ is a solution, then by the computation
\begin{equation*}
  (15+4\rft)(k+\ell\rft)=15k+56\ell+(4k+15\ell)\rft,
\end{equation*}
we have that $(15k+56\ell,4k+15\ell)$ is a solution.  But also,
writing $(p_{4n+3},q_{4n+3})$ as $(a,b)$, we have
\begin{multline*}
  \frac{p_{4n+7}}{q_{4n+7}}
=\Bigl[3;1,2,1,3+%\frac{p_{4n+3}}{q_{4n+3}}
\frac ab\Bigr]
=3+\cfrac1{1+\cfrac1{2+\cfrac1{1+\cfrac1{3+\cfrac ab}}}}
=3+\cfrac1{1+\cfrac1{2+\cfrac1{1+\cfrac b{a+3b}}}}\\
%=3+\cfrac1{1+\cfrac1{2+\cfrac1{\cfrac{a+4b}{a+3b}}}}
=3+\cfrac1{1+\cfrac1{2+\cfrac{a+3b}{a+4b}}}
%=3+\cfrac1{1+\cfrac1{\cfrac{3a+11b}{a+4b}}}
=3+\cfrac1{1+\cfrac{a+4b}{3a+11b}}
%=3+\cfrac1{\cfrac{4a+15b}{3a+11b}}
=3+\cfrac{3a+11b}{4a+15b}
=\frac{15a+56b}{4a+15b}.
\end{multline*}
By induction, our claim is proved.
\end{solution}

The expansion $[3;\overline{1,2,1,6}]$ of $\rft$ has the period
$(1,2,1,6)$ of length $4$, which is even.  But
\begin{equation}\label{eqn:rt13}
  \rtt=[3;\overline{1,1,1,1,6}]
\end{equation}
with a period of odd length $5$.  The convergents $p_n/q_n$ of $\sqrt
d$ are alternately above and below $\sqrt d$ (assuming this is
irrational); in particular, the convergents $p_{2n}/q_{2n}$ are
below.  Therefore $[3;1,1,1,1]$ cannot provide a solution to
$x^2-13y^2=1$.  But
\begin{equation*}
    [3;1,1,1,1,6,1,1,1,1]
\end{equation*}
does provide the fundamental solution
that generates the others: the solutions here are
$p_{10n+9}/q_{10n+9}$. 

\section{March 25, 2008 (Tuesday)}

\topic{A quadratic form example}
A problem on last night's examination was to find solutions to the
Diophantine equation 
\begin{equation}\label{eqn:232}
  2x^2-3y^2=2.
\end{equation}
Let us define
\begin{align*}
f(x,y)
&=  2x^2-3y^2\\
&=2(x^2-\frac32y^2)\\
&=2(x+\sqrt[\sum]\frac32\cdot y)(x-\sqrt[\sum]\frac32\cdot y)\\
&=\frac12(2x+\sqrt 6\cdot y)(2x-\sqrt 6\cdot y).
\end{align*}
Working in $\Q(\sqrt 6)$, we have
\begin{equation*}
  f(x,y)=\frac12\norm{2x+\sqrt 6\cdot y}=\frac12\norm{\alpha x+\beta y},
\end{equation*}
where $\alpha=2$ and $\beta=\sqrt 6$.  We have a bijection
$(x,y)\mapsto\alpha x+\beta y$ between:
\begin{enumerate}
  \item
the solution-set of~\eqref{eqn:232};
\item
the set of $\xi$ in $\lat$ such that $\norm{\xi}=4$.
\end{enumerate}
In particular, $(5,4)$ is a solution of~\eqref{eqn:232}, and
$\norm{5\alpha+4\beta}=4$.  Then other solutions to $\norm{\xi}=4$
include $\epsilon\cdot(5\alpha+4\beta)$, provided:
\begin{enumerate}
  \item
$\norm{\epsilon}=1$;
\item
 $\epsilon\cdot(5\alpha+4\beta)\in\lat$,---and this is achieved if
 $\epsilon\lat\included\lat$, that is, $\epsilon\in\End[\lat]$. 
\end{enumerate}

\asterism\topic{Discriminants}

Let $f(x,y)=ax^2+bxy+cy^2$ for some $a$, $b$, and $c$ in $\Q$ (as
in~\eqref{eqn:abc}).  Again, the discriminant of $f$ is given by
\begin{equation*}
  D=b^2-4ac=s^2d,
\end{equation*}
where $s\in\Q\setminus\{0\}$, $d\in\Z$, and $d$ is \sqf{} or
$0$.  Let us assume $d\neq0$ or $1$: equivalently, $\sqrt
D\not\in\Q$.  Then $a\neq0$.  By the quadratic formula,
\begin{align*}
  f(x,y)&=a\Bigl(x-\frac{-b+\sqrt D}{2a}y\Bigr)\Bigl(x-\frac{-b-\sqrt
    D}{2a}y\Bigr)\\ 
&=\frac1a\Bigl(ax+\frac{b-\sqrt D}{2}y\Bigr)\Bigl(x+\frac{b+\sqrt
    D}{2}y\Bigr)\\ 
&=\frac1a(\alpha'x+\beta'y)(\alpha x+\beta y)\\
&=\frac1a\norm{\alpha x+\beta y},
\end{align*}
where $\alpha=a$ and $\beta=(b+\sqrt D)/2$, and the computations are
in $K$, where $K=\Q(\sqrt d)$.  Since $\sqrt D$ is irrational, we have
$\beta/\alpha\not\in\Q$, that is, $\alpha$ and $\beta$ are linearly
independent over $\Q$; equivalently, $\{\alpha,\beta\}$ is a basis of
$K$ over $\Q$. 

Now suppose conversely $\alpha,\beta\in K$.  Let
\begin{equation*}
  f(x,y)
=\norm{\alpha x+\beta y}
=(\alpha x+\beta y)(\alpha'x+\beta'y)
=\norm{\alpha}x+\tr{\alpha\beta'}xy+\norm{\beta}y^2.
\end{equation*}
Then
\begin{equation}\label{eqn:D-as-det}
  D=\tr{\alpha\beta'}^2-4\norm{\alpha\beta}
  =(\alpha\beta'+\alpha'\beta)^2-4\alpha\beta\alpha'\beta'
=(\alpha\beta'-\alpha'\beta)^2
=
\begin{vmatrix}
  \alpha&\alpha'\\\beta&\beta'
\end{vmatrix}^2.
\end{equation}

\begin{lemma}\label{lem:D}
Let $K$ be a quadratic field $\Q(\sqrt d)$, where $d$ is a \sqf{}
  rational integer (different from $1$).  Let $\alpha,\beta\in K$, and 
  let $D$ be the discriminant of the quadratic form $\norm{\alpha
  x+\beta y}$.  Then $D=s^2d$ for some $s$ in $\Q$.
The following are equivalent:
  \begin{enumerate}
    \item\label{item:Dnot0}
$D\neq0$;
\item\label{item:lin-ind}
$\alpha$ and $\beta$ are linearly independent over $\Q$;
\item\label{item:irrat}
$\sqrt D$ is irrational.
  \end{enumerate}
\end{lemma}

\begin{proof}
  If $\alpha=0$, then~\eqref{item:Dnot0},~\eqref{item:lin-ind},
  and~\eqref{item:irrat} all fail.  Suppose $\alpha\neq0$.  Then we
  can write $\beta/\alpha$ as $r+t\sqrt d$ for some $r$ and $t$ in $\Q$.
  From~\eqref{eqn:D-as-det}, we have
  \begin{equation*}
    D=\biggl(\alpha\alpha'\Bigl(\frac{\beta'}{\alpha'}
    -\frac{\beta}{\alpha}\Bigr)\biggr)^2 
=\norm{\alpha}^2\biggl(\Bigl(\frac{\beta}{\alpha}\Bigr)'
    -\Bigl(\frac{\beta}{\alpha}\Bigr)\biggr)^2
=\norm{\alpha}^2\cdot4t^2d
=(2t\norm{\alpha})^2\cdot d.
  \end{equation*}
Since $2t\norm{\alpha}\in\Q$, we have
\begin{equation*}
  \sqrt D\in\Q\Iff D=0\Iff t=0\Iff\beta/\alpha\in\Q.
\end{equation*}
Thus,~\eqref{item:Dnot0},~\eqref{item:lin-ind},
  and~\eqref{item:irrat} are again equivalent.
\end{proof}

We have observed that two lattices $\lat$ and $\lat[\gamma,\delta]$ of
$K$ are the same lattice $\mLambda$ if and only if
\begin{equation*}
  \begin{pmatrix}
    \gamma\\\delta
  \end{pmatrix}=
  \begin{pmatrix}
    a&b\\c&d
  \end{pmatrix}
  \begin{pmatrix}
    \alpha\\\beta
  \end{pmatrix}
\end{equation*}
for some $a$, $b$, $c$, and $d$ in $\Z$ such that $ad-bc=\pm1$.  In
this case, 
\begin{equation*}
  \begin{pmatrix}
    \gamma&\gamma'\\\delta&\delta'
  \end{pmatrix}=
  \begin{pmatrix}
    a&b\\c&d
  \end{pmatrix}
  \begin{pmatrix}
    \alpha&\alpha'\\\beta&\beta'
  \end{pmatrix},
\end{equation*}
so that
\begin{equation*}
  \begin{vmatrix}
    \gamma&\gamma'\\\delta&\delta'
  \end{vmatrix}^2=
  \begin{vmatrix}
    \alpha&\alpha'\\\beta&\beta'
  \end{vmatrix}^2.
\end{equation*}
Then this number is the \defn{discriminant}{} of $\mLambda$, and we
write%
\index{$\disc{\mLambda}$, $\disc{\alpha,\beta}$}
\begin{equation*}
  \disc{\mLambda}=\disc{\alpha,\beta}=  
\begin{vmatrix}
    \alpha&\alpha'\\\beta&\beta'
  \end{vmatrix}^2.
\end{equation*}
So this is the discriminant of the quadratic forms $\norm{\alpha
  x+\beta y}$ and $\norm{\gamma
  x+\delta y}$.

\begin{lemma}\label{lem:2-gen}
  Suppose $\alpha,\beta\in K$.  Then
  \begin{enumerate}
    \item\label{item:dab}
$\disc{\alpha,\beta}\in\Q$;
\item\label{item:abroi}
$\alpha,\beta\in\roi\implies\disc{\alpha,\beta}\in\Z$;
\item\label{item:d=0}
$\{\alpha,\beta\}$ is a basis for $K$ if and only if
  $\disc{\alpha,\beta}\neq0$. 
  \end{enumerate}
\end{lemma}

\begin{proof}
  We have~\eqref{item:dab} and~\eqref{item:d=0} by Lemma~\ref{lem:D}.
  As for~\eqref{item:abroi}, if $\alpha,\beta\in\roi$, then
  $\disc{\alpha,\beta}\in\roi\cap\Q=\Z$ (exercise).
\end{proof}

\asterism\topic{A quadratic form example}

Suppose 
\begin{equation*}
f(x,y)=2x^2+6xy+3y^2.
\end{equation*}
Then $D=36-24=12=2^2\cdot3$.  Also
\begin{align*}
  f(x,y)
&=2\Bigl(x^2+3xy+\frac32y^2\Bigr) 
=2\Bigl(x-\frac{-3+2\sqrt3}2y\Bigr)\Bigl(x-\frac{-3+2\sqrt 3}2y\Bigr)\\
&=\frac12\bigl(2x+(3+2\sqrt3)y\bigr)\bigl(2x+(3-2\sqrt3)y\bigr). 
\end{align*}
So we have a bijection $(x,y)\mapsto 2x+(3+2\sqrt3)y$ between
$\{(x,y)\in\Z\times\Z\colon f(x,y)=m\}$ and
$\{\xi\in\lat[2,3+2\sqrt3]\colon\norm{\xi}=2m\}$, where the norm is
computed in $\Q(\sqrt3)$.  We can write the form as a matrix product:
\begin{equation*}
  f(x,y)=
  \begin{pmatrix}
    x&y
  \end{pmatrix}
  \begin{pmatrix}
    2&3\\3&3
  \end{pmatrix}
  \begin{pmatrix}
    x\\y
  \end{pmatrix}.
\end{equation*}
Then making a change of variable, as by
\begin{equation*}
  \begin{pmatrix}
    x\\y
  \end{pmatrix}=
  \begin{pmatrix}
    a&b\\c&d
  \end{pmatrix}
  \begin{pmatrix}
    u\\v
  \end{pmatrix},
\end{equation*}
means forming a new product
\begin{equation*}
  \begin{pmatrix}
    u&v
  \end{pmatrix}
  \begin{pmatrix}
    a&c\\b&d
  \end{pmatrix}
  \begin{pmatrix}
    2&3\\3&3
  \end{pmatrix}
  \begin{pmatrix}
    a&b\\c&d
  \end{pmatrix}
  \begin{pmatrix}
    u\\v
  \end{pmatrix}.
\end{equation*}
Such a change may be useful particularly if what we want to understand
is the possible values of $f(x,y)$.

\asterism\topic{Lattices}

As usual, let $d$ be \sqf{}, and different from $1$; and
$K=\Q(\sqrt d)$.

\begin{lemma}\label{lem:lat-cond}
  Let $L$ be a subset of $K$.  Then $L$ is a lattice of $K$ if and
  only if:
  \begin{enumerate}
    \item\label{item:+}
$L$ is an additive subgroup of $K$ (that is, $K$ contains $0$ and is
      closed under addition and subtraction);
\item\label{item:span}
as a vector-space, $K$ is spanned by $L$ (over $\Q$);
\item\label{item:nL}
$nL\included\roi$ for some $n$ in $\Z\setminus\{0\}$.
  \end{enumerate}
\end{lemma}

\begin{proof}
  Suppose $L$ is a lattice of $K$.  Then~\eqref{item:+}
  and~\eqref{item:span} hold by definition of lattice.  Also $L=\lat$
  for some $\alpha$ and $\beta$ in $K$.  But $\roi$ is a lattice
  $\lat[1,\omega]$ for some $\omega$.  In particular, $(1,\omega)$
  spans $K$.  So $\alpha=k+\ell\omega$ and $\beta=r+s\omega$ for some
  $k$, $\ell$, $r$, and $s$ in $\Q$.  Let $n$ be a common multiple of
  their denominators.  Then $n\alpha,n\beta\in\roi$, so
  $nL\included\roi$. 

Now suppose conversely that~\eqref{item:+},~\eqref{item:span},
and~\eqref{item:nL} hold.  Then $L$ contains $\alpha$ and $\beta$ such
that $\{\alpha,\beta\}$ is a basis for $K$; and there is $n$ in
$\Z\setminus\{0\}$ such that, for every such basis,
$n\alpha,n\beta\in\roi$.  By Lemma~\ref{lem:2-gen}, this means
$\disc{n\alpha,n\beta}\in\Z$.  Also $\disc{\alpha,\beta}\neq0$.  So we
may suppose $\alpha$ and $\beta$ have been chosen from $L$ so as to
minimize $\size{\disc{n\alpha,n\beta}}$, which is
$n^4\size{\disc{\alpha,\beta}}$.  We shall show $L=\lat$.  Suppose
$\gamma\in L$.  Then $\gamma\in K$, so 
\begin{equation*}
  \gamma=\alpha r+\beta s
\end{equation*}
for some $r$ and $s$ in $\Q$.  We want to show $r,s\in\Z$.  Since
\begin{equation*}
  \gamma-\alpha[r]=\alpha(r-[r])+\beta s,
\end{equation*}
we have
\begin{multline*}
  \disc{\gamma-\alpha[r],\beta}
=
\begin{vmatrix}
  \gamma-\alpha[r]&\gamma'-\alpha'[r]\\
\beta&\beta'
\end{vmatrix}^2
=\begin{vmatrix}
\alpha(r-[r])+\beta s  &\alpha'(r-[r])+\beta' s\\
\beta&\beta'
\end{vmatrix}^2\\
=\begin{vmatrix}
\alpha(r-[r])&\alpha'(r-[r])\\
\beta&\beta'
\end{vmatrix}^2
=(r-[r])^2\begin{vmatrix}
\alpha&\alpha'\\
\beta&\beta'
\end{vmatrix}^2
=(r-[r])^2\disc{\alpha,\beta}.
\end{multline*}
By minimality of $\size{\disc{\alpha,\beta}}$, we must have
$r-[r]=0$, so $r\in\Z$.  By symmetry, $s\in\Z$.
\end{proof}

\section{March 28, 2008 (Friday)}

If $\mLambda$ is a lattice of $K$, then the ring $\End$ is also called
the \defn{order}{} of $\mLambda$ and denoted by%
\index{$\ord$}
\begin{equation*}
  \ord.
\end{equation*}
By Lemma~\ref{lem:end-in-roi}, we know that this is a sub-ring of $\roi$.

\begin{lemma}
  Let $\mLambda$ be a lattice of $K$.  Then $\ord$ is also a lattice of
  $K$. 
\end{lemma}

\begin{proof}
  By Lemma~\ref{lem:lat-cond}, it is enough to show that $\ord$ spans $K$
  over $\Q$.  Write $\mLambda$ as $\lat$.  Let $\gamma\in K$.  Then
  \begin{equation*}
\gamma
    \begin{pmatrix}
      \alpha\\\beta
    \end{pmatrix}=
    \begin{pmatrix}
      r&s\\t&u
    \end{pmatrix}
    \begin{pmatrix}
      \alpha\\\beta
    \end{pmatrix}
  \end{equation*}
for some rational numbers $r$, $s$, $t$, and $u$.  Let $n$ be a common
multiple of their denominators.  Then
$n\gamma\mLambda\included\mLambda$, that is, $n\gamma\in\ord$.  But
$\gamma=(1/n)n\gamma$. 
\end{proof}

\begin{theorem}\label{thm:cond}
  $\ord=\lat[1,c\omega]$ for some positive rational integer $c$.
\end{theorem}

\begin{proof}
  We know $1\in\ord$ and $\ord\included\lat[1,\omega]$.  Since $\ord$
  is a lattice, we must therefore have $m+n\omega\in\ord$ for some
  integers $m$ and $n$, where $n\neq0$.  Hence $n\omega\in\ord$.  Let
  $c$ be the least positive integer such that $c\omega\in\ord$.  Then
  $\lat[1,c\omega]\included\ord$.  Conversely, suppose
  $m+n\omega\in\ord$.  Then $n\omega\in\ord$, hence
  $\gcd(c,n)\omega\in\ord$.  By minimality of $c$, we must have
  $\gcd(c,n)=c$, so $c\divides n$.  Thus
  $\ord\included\lat[1,c\omega]$. 
\end{proof}

The number $c$ in the theorem is called the \defn{conductor}{} of
$\ord$. 

\begin{lemma}\label{lem:homothety}
  $\ord[\gamma\mLambda]=\ord$ for all non-zero $\gamma$ in $K$.
\end{lemma}

\begin{proof}
  Since $\xi\mapsto\gamma\xi$ is a bijection from $K$ to itself, we
  have $\xi\mLambda\included\mLambda\Iff
  \xi\gamma\mLambda\included\gamma\mLambda$. 
\end{proof}

In looking for $\ord$, we may therefore assume that
$\mLambda=\lat[1,\tau]$ for some $\tau$.  Then
  \begin{equation*}
    a\tau^2+b\tau+c=0
  \end{equation*}
for some $a$, $b$, and $c$ in $\Z$, where $\gcd(a,b,c)=1$ and $a>0$.
Then
\begin{equation*}
  a\tau^2=-b\tau-c,
\end{equation*}
which shows $\lat[1,a\tau]\included\ord$.  That this inclusion is an
equality can be seen in some examples.  If $b=0$ and $c=1$, then we
may assume $\tau=\mi/\sqrt a$: see Figure~\ref{fig:lat-end-1}.
\begin{figure}[ht]
  \begin{pspicture}(-2.5,-0.5)(2.5,2.5)
    \psline{->}(-2.5,0)(2.5,0)
    \psline{->}(0,-0.5)(0,2.5)
\psdots(-2,0)(0,0)(2,0)(-2,2)(0,2)(2,2)
\uput[ur](0,2){$\mi$}
\uput[dl](2,0){$1$}
  \end{pspicture}
\hfill
  \begin{pspicture}(-2.5,-0.5)(2.5,2.5)
    \psline{->}(-2.5,0)(2.5,0)
    \psline{->}(0,-0.5)(0,2.5)
\psdots(-2,0)(0,0)(2,0)(-2,1.414)(0,1.414)(2,1.414)
\uput[ur](0,1.414){$\mi/\sqrt 2$}
\uput[dl](2,0){$1$}
  \end{pspicture}
\hfill
  \begin{pspicture}(-2.5,-0.5)(2.5,2.5)
    \psline{->}(-2.5,0)(2.5,0)
    \psline{->}(0,-0.5)(0,2.5)
\psdots(-2,0)(0,0)(2,0)(-2,1.155)(0,1.155)(2,1.155)
\uput[ur](0,1.155){$\mi/\sqrt 3$}
\uput[dl](2,0){$1$}
  \end{pspicture}
\caption{Lattices $\lat[1,\mi/\sqrt a]$}\label{fig:lat-end-1}
\end{figure}
If $b=-1$ and $c=1$, then $\size{\tau}=1/\sqrt a$, and we may assume
$\tau=(1+\mi\oldsqrt{4a-1})/2a$: see Figure~\ref{fig:lat-end-2}.
\begin{figure}[ht]
  \begin{pspicture}(-2.5,-0.5)(2.5,2.8)
%\psgrid
    \psline{->}(-2.5,0)(2.5,0)
    \psline{->}(0,-0.5)(0,2.5)
\psdots(-2,0)(0,0)(2,0)(-1,1.732)(1,1.732)
\uput[ur](1,1.732){$\displaystyle\frac{1+\mi\sqrt 3}2$}
\uput[dl](2,0){$1$}
  \end{pspicture}
\hfill
  \begin{pspicture}(-2.5,-0.5)(2.5,2.8)
%\psgrid
    \psline{->}(-2.5,0)(2.5,0)
    \psline{->}(0,-0.5)(0,2.5)
\psdots(-2,0)(0,0)(2,0)(-1.5,1.323)(0.5,1.323)
\uput[ur](0.5,1.323){$\displaystyle\frac{1+\mi\sqrt 7}4$}
\uput[dl](2,0){$1$}
  \end{pspicture}
\hfill
  \begin{pspicture}(-2.5,-0.5)(2.5,2.8)
%\psgrid
    \psline{->}(-2.5,0)(2.5,0)
    \psline{->}(0,-0.5)(0,2.5)
\psdots(-2,0)(0,0)(2,0)(-1.667,1.106)(0.333,1.106)
\uput[ur](0.333,1.106){$\displaystyle\frac{1+\sqrt{11}}6$}
\uput[dl](2,0){$1$}
  \end{pspicture}
\begin{comment}


  \begin{pspicture}(-2.5,-0.5)(2,2)
    \psdots(-2,0)(0,0)(2,0)(1,1.732)(-1,1.732)
\uput[d](-2,0){$-1$}
\uput[d](0,0){$0$}
\uput[d](2,0){$1$}
\uput[ur](1,1.732){$\tau$}
\uput[ul](-1,1.732){$\tau^2$}
\uput[d](0,1){$a=1$}
  \end{pspicture}
\hfill
  \begin{pspicture}(-2,-0.5)(2,1.5)
    \psdots(-2,0)(0,0)(2,0)(0.5,1.323)(-1.5,1.323)
\uput[d](-2,0){$-1$}
\uput[d](0,0){$0$}
\uput[d](2,0){$1$}
\uput[ur](0.5,1.323){$\tau$}
\uput[ul](-1.5,1.323){$2\tau^2$}
\uput[d](0,1){$a=2$}
  \end{pspicture}
\hfill
  \begin{pspicture}(-2,-0.5)(2.2,1.5)
    \psdots(-2,0)(0,0)(2,0)(0.333,1.106)(-1.666,1.106)
\uput[d](-2,0){$-1$}
\uput[d](0,0){$0$}
\uput[d](2,0){$1$}
\uput[ur](0.333,1.106){$\tau$}
\uput[ul](-1.666,1.106){$3\tau^2$}
\uput[d](0,1){$a=3$}
  \end{pspicture}


\end{comment}
\caption{Lattices
  $\lat[1,(1+\mi\protect\oldsqrt{4a-1})/2a]$}\label{fig:lat-end-2} 
\end{figure}

\begin{theorem}\label{thm:conductor}
  Suppose $\mLambda=\lat$.  Let $\tau=\beta/\alpha$, so that
  \begin{equation*}
    a\tau^2+b\tau+c=0
  \end{equation*}
for some $a$, $b$, and $c$ in $\Z$, where $\gcd(a,b,c)=1$.  Then
\begin{equation*}
  \ord=\lat[1,a\tau].
\end{equation*}
\end{theorem}

\begin{proof}
We have the following equivalences:
\begin{align*}
  \theta\in\ord
&\Iff\theta\lat[1,\tau]\included\lat[1,\tau]\\
&\Iff\theta\in\lat[1,\tau]\land\theta\tau\in\lat[1,\tau]\\
&\Iff\theta=x+y\tau\land x\tau+y\tau^2\in\lat[1,\tau]\text{ for some
    $x$ and $y$ in $\Z$}\\
&\Iff\theta=x+y\tau\land y\tau^2\in\lat[1,\tau]\text{ for some
    $x$ and $y$ in $\Z$}\\
&\Iff\theta=x+y\tau\land
  \frac{yb}a\tau+\frac{yc}a\in\lat[1,\tau]\text{ for some 
    $x$ and $y$ in $\Z$}\\
&\Iff\theta=x+y\tau\land
  a\divides{yb}\land a\divides{yc}\text{ for some 
    $x$ and $y$ in $\Z$}\\
&\Iff\theta=x+y\tau\land
  a\divides y\text{ for some 
    $x$ and $y$ in $\Z$}.
\end{align*}
In short, $\theta\in\ord\Iff\theta\in\lat[1,a\tau]$.
\end{proof}

\section{April 1, 2008 (Tuesday)}

What then is the conductor of $\ord$?  Since $\tau\in K$, we have
\begin{equation*}
  \tau=\frac{-b\pm\oldsqrt{b^2-4ac}}{2a}=\frac{-b\pm s\sqrt d}{2a}
\end{equation*}
for some $s$ in $\Z$.  Hence
\begin{equation*}
  \ord=\Bigl\langle1,\frac{-b\pm s\sqrt d}2\Bigl\rangle.
\end{equation*}
But we have
\begin{equation*}
  s^2d\equiv b^2\pmod 4.
\end{equation*}
If $d\equiv 2$ or $3$, then (since squares are congruent to $0$ or
$1$), we must have $s^2\equiv0$, so $s$ is even, and also $b$ is even,
so that
\begin{equation*}
  \ord=\Bigl\langle1,\frac s2\sqrt d\Bigr\rangle
=\Bigl\langle1,\frac s2\omega\Bigr\rangle.
\end{equation*}
If $d\equiv1$, then $s^2\equiv b^2$, so $b\pm s$ is even, and hence
\begin{equation*}
  \ord=\Bigl\langle1,\frac{-b\mp s\pm s\pm s\sqrt d}2\Bigr\rangle
=\Bigl\langle1,\pm s\frac{1\pm\sqrt d}2\Bigr\rangle;
%=\lat[1,s\omega].
\end{equation*}
this is either $\lat[1,s\omega]$ immediately, or $\lat[1,-s\omega']$,
which is $\lat[1,s\omega-s]$, which is $\lat[1,s\omega]$.


\asterism\topic{Units}

We now ask which elements of $\ord$ satisfy $\norm{\xi}=1$.

\begin{lemma}
  The units of $\ord$ are just those elements that satisfy
  $\norm{\xi}=\pm1$. 
\end{lemma}

\begin{proof}
  We know $\ord\included\roi$, so $\norm{\alpha}\in\Z$ for all
  $\alpha$ in $\ord$.  Suppose $\alpha$ is a unit of $\ord$.  Then
  $\alpha\neq0$, and $\alpha\inv\in\ord$.  But
  $1=\norm1=\norm{\alpha\alpha\inv}=\norm{\alpha}\norm{\alpha\inv}$,
  and since these factors are in $\Z$, we have that $\norm{\alpha}$ is
  a unit in $\Z$, that is, $\norm{\alpha}=\pm1$.

Suppose conversely $\alpha\in\ord$ and $\norm{\alpha}=\pm1$.  This
means $\alpha\alpha'=\pm1$, so $\alpha\inv=\pm\alpha'$.  But
$\ord=\lat[1,c\omega]$ for some $c$, so $\ord$ is closed
under $\xi\mapsto\xi'$.  Therefore
$\alpha\inv\in\ord$, so $\alpha$ is a unit of $\ord$.  
\end{proof}

Since $\ord=\lat[1,c\omega]$, the units of $\ord$ are those elements
$x+c\omega y$ such that $\norm{x+c\omega y}=\pm1$, that is,
\begin{equation}\label{eqn:units}
\pm1=
\begin{cases}
x^2-dc^2y^2,&\text{ if $d\equiv 2$ or $3\pmod 4$;}\\
(x+cy/2)^2-dc^2y^2/4,&\text{ if $d\equiv 1$.}
\end{cases}
\end{equation}

\topic{The imaginary case}
The easier case to consider is $d<0$, when $\norm{\xi}=\size{\xi}^2$.
Then all units of $\ord$ lie on the unit circle: see
Figure~\ref{fig:units}. 
\begin{figure}[ht]
  \begin{pspicture}(-2.8,-2.8)(2.8,2.8)
%\psgrid
    \pscircle(0,0)2
    \psdots[dotsize=2pt 3]
(2,0)(1,1.732)(0,2)(-1,1.732)(-2,0)(-1,-1.732)(0,-2)(1,-1.732)
\uput[dr](2,0){$1$}
\uput[ur](1,1.732){$\displaystyle\frac{1+\mi\sqrt 3}2$}
\uput[ur](0,2){$\mi$}
\uput[ul](-1,1.732){$\displaystyle\frac{-1+\mi\sqrt 3}2$}
\uput[ul](-2,0){$-1$}
\uput[dl](-1,-1.732){$\displaystyle\frac{-1-\mi\sqrt 3}2$}
\uput[dl](0,-2){$-\mi$}
\uput[dr](1,-1.732){$\displaystyle\frac{1-\mi\sqrt 3}2$}
\psline{->}(-2.8,0)(2.8,0)
\psline{->}(0,-2.8)(0,2.8)
  \end{pspicture}
\caption{Units in imaginary quadratic fields}\label{fig:units}
\end{figure}
If $d\equiv2$ or
$3$, then~\eqref{eqn:units} has the solutions
\begin{enumerate}
  \item
$(\pm1,0)$, if $c>1$ or $d<-1$;
\item
$(\pm1,0)$ and $(0,\pm1)$, if $c=1$ and $d=-1$.
\end{enumerate}
If $d\equiv1$, then either $d=-3$, or else $d\leq-7$.  In the latter
case, the only solutions to~\eqref{eqn:units} are $(\pm1,0)$.  But if
$d=-3$, so that~\eqref{eqn:units} becomes
\begin{equation*}
\Bigl(x+\frac c2y\Bigr)^2+\frac34c^2y^2=\pm1,  
\end{equation*}
then the solutions are
\begin{enumerate}
  \item
$(\pm1,0)$, if $c>1$;
\item
$(\pm1,0),(\pm1,\mp1),(0,\pm1)$, if $c=1$.
\end{enumerate}
Thus we have shown:

\begin{theorem}
  When $d<0$, then the units of $\lat[1,c\omega]$ are:
  \begin{enumerate}
    \item
$\pm1$, $\pm\omega$, when $c=1$ and $d=-1$;
\item
$\pm1$, $\pm\omega'$, $\pm\omega$, when $c=1$ and $d=-3$;
\item
$\pm1$, in all other cases.
  \end{enumerate}
\end{theorem}

\begin{problem}\label{prob:qDe1}
Solve the quadratic Diophantine equation
\begin{equation}\label{eqn:unit-example}
x^2+xy+y^2=3.
\end{equation}
\end{problem}

\begin{solution}
Evidently $(1,1)$ is a solution.  What are the others?  We have
\begin{align*}
  x^2+xy+y^2
&=x^2+xy+\frac14y^2+\frac34y^2\\
&=\Bigl(x+\frac12y\Bigr)^2+\Bigl(\frac{\sqrt 3}2y\Bigr)^2\\
&=\Bigl(x+\frac12y+\frac{\mi\sqrt3}2\Bigr)
  \Bigl(x+\frac12y-\frac{\mi\sqrt3}2\Bigr)\\
&=(x+\omega y)(x+\omega'y)\\
&=\norm{x+\omega y},
\end{align*}
where we work in $\Q(\sqrt{{-3}})$.  Let
$\mLambda=\lat[1,\omega]$, so that $\ord=\mLambda=\roi$, which has the
six units $\pm1$, $\pm\omega$, and $\pm\omega'$, all of norm $1$.
Since $1+\omega$ is a solution of
\begin{equation*}
  \norm{\xi}=3
\end{equation*}
from $\mLambda$, so are $\pm(1+\omega)$, $\pm\omega(1+\omega)$, and
$\pm\omega'(1+\omega)$.  
Since $\omega^2-\omega+1=0$, and $\omega+\omega'=1$, these solutions
are 
$\pm(1+\omega)$, $\pm(2\omega-1)$, and $\pm(2-\omega)$, as in
Figure~\ref{fig:unit-example}.
\begin{figure}
  \begin{pspicture}(-3,-2.6)(3,2.6)
    \pscircle(0,0){1.732}
\psdots(-3,0)(-2,0)(-1,0)(0,0)(1,0)(2,0)(3,0)
(-2,1.732)(-1,1.732)(0,1.732)(1,1.732)(2,1.732)
(-2,-1.732)(-1,-1.732)(0,-1.732)(1,-1.732)(2,-1.732)
(-2.5,0.866)(-1.5,0.866)(-0.5,0.866)(0.5,0.866)(1.5,0.866)(2.5,0.866)
(-2.5,-0.866)(-1.5,-0.866)(-0.5,-0.866)(0.5,-0.866)(1.5,-0.866)(2.5,-0.866)
(-1.5,2.598)(-0.5,2.598)(0.5,2.598)(1.5,2.598)
(-1.5,-2.598)(-0.5,-2.598)(0.5,-2.598)(1.5,-2.598)
%\uput[d](0,0){$0$}
%\uput[d](1,0){$1$}
%\uput[d](0.5,0.866){$\omega$}
\uput[ur](1.5,0.866){$1+\omega$}
\uput[u](0,1.732){$-1+2\omega$}
\uput[ul](-1.5,0.866){$-2+\omega$}
\uput[dl](-1.5,-0.866){$-1-\omega$}
\uput[d](0,-1.732){$1-2\omega$}
\uput[dr](1.5,-0.866){$2-\omega$}
  \end{pspicture}
\caption{Solutions of $\norm{\xi}=3$ from $\lat[1,\omega]$ in
  $\Q(\sqrt{{-3}})$}\label{fig:unit-example}  
\end{figure}
  The
corresponding 6 solutions of~\eqref{eqn:unit-example} are
\begin{equation*}
  (\pm1,\pm1),\quad(\mp1,\pm2),\quad(\pm2,\mp1),
\end{equation*}
as in Figure~\ref{fig:unit-example-2}.
\begin{figure}[ht]
  \begin{pspicture}(-3,-3)(3,3)
\parametricplot{0}{360}{1.732 t cos mul t sin sub t sin 2 mul}
\psdots(-3,0)(-2,0)(-1,0)(0,0)(1,0)(2,0)(3,0)
(-3,1)(-2,1)(-1,1)(0,1)(1,1)(2,1)
(-2,-1)(-1,-1)(0,-1)(1,-1)(2,-1)(3,-1)
(-3,2)(-2,2)(-1,2)(0,2)(1,2)
(-3,3)(-2,3)(-1,3)(0,3)
(-1,-2)(0,-2)(1,-2)(2,-2)(2,-2)(3,-2)
(0,-3)(1,-3)(2,-3)(2,-3)(3,-3)
\uput[ur](1,1){$(1,1)$}
\uput[u](-1,2){$(-1,2)$}
\uput[ul](-2,1){$(-2,1)$}
\uput[dl](-1,-1){$(-1,-1)$}
\uput[d](1,-2){$(1,-2)$}
\uput[dr](2,-1){$(2,-1)$}
  \end{pspicture}
\caption{Solutions of $x^2+xy+y^2=3$}\label{fig:unit-example-2}
\end{figure}
It is easy to see from Figure~\ref{fig:unit-example} that there are no
 other solutions.  Also, we can rewrite~\eqref{eqn:unit-example} as
\begin{equation*}
  \frac{(x+y/2)^2}3+\frac{y^2}4=1,
\end{equation*}
which defines the ellipse in Figure~\ref{fig:unit-example-2}; then we
just look for the integer points on the ellipse---there are only
finitely many.  However, it is not see easy to tell at a glance which
integer points \emph{are} on the ellipse.
\end{solution}


\begin{problem}\label{prob:qDe2}
Solve
\begin{equation}\label{eqn:another-unit-example}
  4x^2+2xy+y^2=7.
\end{equation}
\end{problem}

\begin{solution}
Again, one solution is $(1,1)$.  We can try to factorize:
\begin{align}\notag
  4x^2+2xy+y^2
&=3x^2+(x+y)^2\\\notag
&=(\sqrt 3x+\mi(x+y))(\sqrt 3x-\mi(x+y))\\\label{eqn:factors}
&=((\sqrt3+\mi)x+\mi y)((\sqrt3-\mi)x-\mi y),
\end{align}
but this is not over a quadratic field.  Indeed, a field
that contains $\sqrt 3+\mi$ and $\mi$ contains also $\sqrt 3$.  But
$[\Q(\sqrt3,\mi):\Q]=4$ (see Figure~\ref{fig:fields}).
\begin{figure}[ht]
\begin{equation*}
  \xymatrix
{& \Q(\sqrt3,\mi) \\
\Q(\sqrt3) \ar@{-}[ur]^2 &&\Q(\mi) \ar@{-}[ul]_2\\
&\Q \ar@{-}[ul]^2 \ar@{-}[ur]_2}
\end{equation*}
\caption{Subfields of $\Q(\sqrt 3,\mi)$}\label{fig:fields}
\end{figure}
We can fix this problem by multiplying each factor
in~\eqref{eqn:factors} by the appropriate unit, such as $-\mi$ and $\mi$.
What amounts to the same thing is to compute as follows.  We have
\begin{align*}
3x^2+(x+y)^2
&=(x+y)^2+3x^2\\
&=(x+y+\mi\sqrt 3x)(x+y-\mi\sqrt3x)\\
&=(2\omega x+y)(2\omega'x+y)\\
&=\norm{2\omega x+y},
\end{align*}
again in $\Q(\sqrt{{-3}})$.  Let
$\mLambda=\lat[2\omega,1]=\lat[1,2\omega]$.  We want to find the
solutions of
\begin{equation}\label{eqn:another-unit-example-2}
  \norm{\xi}=7
\end{equation}
in $\mLambda$.  We know one solution, namely $1+2\omega$.
Since $(2\omega)^2-2(2\omega)+4=0$, we have
$\ord=\lat[1,2\omega]=\mLambda$.  The only units of $\roi$ in this are
$\pm1$.  Hence we have the solutions $\pm(1+2\omega)$
of~\eqref{eqn:another-unit-example-2}.  To find any others, again we
can draw a picture, Figure~\ref{fig:another-unit-example}.
\begin{figure}[ht]
  \begin{pspicture}(-3,-3.5)(3,3.5)
\pscircle(0,0){2.646}
\psset{dotsize=2pt 3}
    \psdots
(-4,0)(-3,0)(-2,0)(-1,0)(0,0)(1,0)(2,0)(3,0)(4,0)
%(-3,1.732)
(-2,1.732)(-1,1.732)(0,1.732)(1,1.732)(2,1.732)%(3,1.732)
%(-3,-1.732)
(-2,-1.732)(-1,-1.732)(0,-1.732)(1,-1.732)(2,-1.732)%(3,-1.732)
(-2,3.464)(-1,3.464)(0,3.464)(1,3.464)(2,3.464)
(-2,-3.464)(-1,-3.464)(0,-3.464)(1,-3.464)(2,-3.464)
\psset{dotstyle=o}
\psdots
(-2.5,2.598)(-1.5,2.598)(-0.5,2.598)(0.5,2.598)(1.5,2.598)(2.5,2.598)
(-3.5,0.866)(-2.5,0.866)(-1.5,0.866)(-0.5,0.866)(0.5,0.866)(1.5,0.866)(2.5,0.866)(3.5,0.866) 
(-2.5,-2.598)(-1.5,-2.598)(-0.5,-2.598)(0.5,-2.598)(1.5,-2.598)(2.5,-2.598)
(-3.5,-0.866)(-2.5,-0.866)(-1.5,-0.866)(-0.5,-0.866)(0.5,-0.866)(1.5,-0.866)(2.5,-0.866)(3.5,-0.866)
\uput[ur](2,1.732){$1+2\omega$}
\uput[ul](-2,1.732){$2\omega-3$}
\uput[dl](-2,-1.732){$-1-2\omega$}
\uput[dr](2,-1.732){$3-2\omega$}
  \end{pspicture}
\caption{Solutions of $\norm{\xi}=7$ from
  $\lat[1,2\omega]$ in $\Q(\sqrt{{-3}})$}\label{fig:another-unit-example} 
\end{figure}
So~\eqref{eqn:another-unit-example-2} has the solutions $\pm(1+2\omega)$
and $\pm(3-2\omega)$, and no others.  The solutions
of~\eqref{eqn:another-unit-example} are therefore $(\pm1,\pm1)$ and
$(\mp1,\pm3)$.  These appear on the graph
of~\eqref{eqn:another-unit-example} in
Figure~\ref{fig:another-unit-example-2}.
\begin{figure}[ht]
  \begin{pspicture}(-2,-4)(2,4)
    \parametricplot{0}{360}{7 3 div sqrt t cos mul 7 sqrt t sin mul 7 3 div
    sqrt t cos mul sub}
\psdots
(-2,0)(-1,0)(0,0)(1,0)(2,0)
(-2,1)(-1,1)(0,1)(1,1)(2,1)
(-2,2)(-1,2)(0,2)(1,2)(2,2)
(-2,3)(-1,3)(0,3)(1,3)
(-2,4)(-1,4)(0,4)
(-2,-1)(-1,-1)(0,-1)(1,-1)(2,-1)
(-2,-2)(-1,-2)(0,-2)(1,-2)(2,-2)
(-1,-3)(0,-3)(1,-3)(2,-3)
(0,-4)(1,-4)(2,-4)
\uput[ur](1,1){$(1,1)$}
\uput[ul](-1,3){$(-1,3)$}
\uput[dl](-1,-1){$(-1,-1)$}
\uput[dr](1,-3){$(1,-3)$}
  \end{pspicture}
\caption{Solutions to $4x^2+2xy+1=7$}\label{fig:another-unit-example-2}
\end{figure}
\end{solution}


In the same way, we can solve any quadratic Diophantine equation
\begin{equation*}
  ax^2+bxy+cy^2=m,
\end{equation*}
provided $b^2-4ac<0$.  For in this case, the equation defines an
ellipse, which is bounded, so that there are only finitely many
possible solutions to check.

\asterism\topic{The real case}

Now we move to the case where $d>0$, so $K\included\R$.  We have
\begin{equation*}
  \lat[1,c\sqrt d]\included\lat[1,c\omega]=\ord.
\end{equation*}
A unit of $\ord$ of the form $x+cy\sqrt d$ thus corresponds to a
solution of
\begin{equation*}
  x^2-dc^2y^2=\pm1.
\end{equation*}
The Pell equation $x^2-dc^2y^2=\pm1$ has infinitely many solutions,
and therefore $\ord$ has infinitely many units.  We want to find them.

Suppose $\epsilon$ is a unit of $\ord$.  Since there are infinitely
many units, there are units other than $\pm1$.  So we may assume
$\epsilon\neq\pm1$.  If $\epsilon<0$, then $-\epsilon$ is a unit
greater than $0$.  So we may assume $\epsilon>0$.  If $0<\epsilon<1$,
then $\epsilon\inv$ is a unit greater than $1$.  So we may assume
$\epsilon>1$.  Also $\epsilon<n$ for some $n$.  But
\begin{equation*}
  \epsilon^2-(\epsilon+\epsilon')\epsilon+\epsilon\epsilon'=0,
\end{equation*}
that is, $\epsilon^2-\tr{\epsilon}\epsilon+\norm{\epsilon}=0$.  Since
$\pm1=\norm{\epsilon}=\epsilon\epsilon'$, we have
$\size{\epsilon'}=\epsilon\inv$.  Hence
\begin{equation*}
 \size{\tr{\epsilon}}= \size{\epsilon+\epsilon'}\leq\epsilon+\epsilon\inv<n+1.
\end{equation*}
This shows that there are only finitely many possibilities for the
equation $x^2-\tr{\epsilon}x+\norm{\epsilon}=0$.  Hence there are only
finitely many units of $\ord$ between $1$ and $n$.  Therefore there is
a least such unit, the \defn{fundamental unit}, which we may denote
by%
\index{$\funit$}
\begin{equation*}
  \funit.
\end{equation*}
Then $(\funit^n:n\in\Z)$ is an increasing sequence,
$\displaystyle\lim_{n\to\infty}\funit^n=\infty$, and
$\displaystyle\lim_{n\to-\infty}\funit^n=0$.
Suppose $\zeta$ is a positive unit of $\ord$.  Then
\begin{equation*}
  \funit{}^n\leq\zeta<\funit{}^{n+1}
\end{equation*}
for some $n$.  Hence $1\leq\funit{}^{-n}\zeta<\funit$.  But
$\funit{}^{-n}\zeta$ is a unit too.  By minimality of $\funit$, we
conclude that $\zeta=\funit{}^n$.  We have proved:

\begin{theorem}\label{thm:unit}
  When $d>0$, then the units of $\ord$ compose the multiplicative
  group generated by $\funit$ and $-1$.  In particular, every unit is
  $\pm\funit{}^n$ for some $n$ in $\Z$.  If $\norm{\funit}=1$, then
  every unit has norm $1$.  If $\norm{\funit}=-1$, then the units of
  norm $1$ are $\pm\funit{}^{2n}$.
\end{theorem}

How do we find $\funit$?

\begin{lemma}\label{lem:not5}
  Assuming $d>0$, let $\epsilon$ be a unit $x+\omega y$ of $\roi$ such
  that $\epsilon>1$.  Then either $x,y>0$, or else $d=5$ and
  $\epsilon=\omega=(1+\sqrt 5)/2$.
\end{lemma}

\begin{proof}
  We have
  \begin{equation*}
  (\omega-\omega')y=\epsilon-\epsilon'\geq\epsilon-\size{\epsilon\inv}>0,
  \end{equation*}
and $\omega>\omega'$, so $y>0$.  Also
\begin{equation*}
1>\size{\epsilon'}=\size{x+\omega'y}; 
\end{equation*}
so since $\omega'<0$, and
hence $\omega'y<0$, we must have $x\geq0$, since $x\in\Z$.  If $x>0$,
we are done.  Suppose $x=0$.  Then
\begin{equation*}
  \pm1=\norm{\omega y}=
  \begin{cases}
    -dy^2,&\text{ if $d\equiv 2$ or $3\pmod 4$;}\\
\displaystyle\frac{1-d}4y^2,&\text{ if }d\equiv 1.
  \end{cases}
\end{equation*}
The only way this can happen is if $d=5$ and $y=1$ (since $y>0$).
\end{proof}

\section{April 4, 2008 (Friday)}

When $d=5$, then $\omega=\gr$, the so-called \defn{Golden Ratio}:%
\index{$\gr$ (the Golden Ratio)}
\begin{equation*}
  \gr=\frac{1+\sqrt 5}2.
\end{equation*}
This has an intimate connexion with the sequence $(\Fib n\colon n\in\varN)$
of \defn{Fibonacci number}{s,}%
\index{$\Fib n$}
 given by 
\begin{equation*}
\Fib 0=0,\quad
\Fib 1=1,\quad
\Fib {n+2}=\Fib n+\Fib {n+1}.
\end{equation*}
We can continue the sequence backwards, so that, if $n<0$, then
\begin{equation*}
  \Fib n=\Fib {n+2}-\Fib {n+1}.
\end{equation*}
Then the bi-directional sequence is
\begin{equation*}
\dots,\quad13,\quad-8,\quad5,\quad-3,\quad2,\quad-1,\quad1,\quad
0,\quad1,\quad1,\quad2,\quad3,\quad5,\quad8,\quad13,\quad\dots 
\end{equation*}

\begin{theorem}\label{thm:Fib}
  The units of the ring of integers of $\Q(\sqrt 5)$
are $\pm\gr^n$; and
\begin{equation}\label{eqn:Fib}
  \gr^n=\Fib {n-1}+\Fib n\gr.
\end{equation}
\end{theorem}

\begin{proof}
Let $K=\Q(\sqrt 5)$.
  By Lemma~\ref{lem:not5}, $\gr$ is the least unit of $\roi$ that is
  greater than~$1$.  Then every unit is $\pm\gr^n$ for some $n$ in
  $\Z$, by Theorem~\ref{thm:unit}.
Trivially~\eqref{eqn:Fib} holds when $n=1$.  Also, $\gr$ is a root
  of
  \begin{equation*}
    x^2-x-1=0,
  \end{equation*}
so $\gr^2=1+\gr$, which means
\begin{equation}\label{eqn:F-proof}
  (x+y\gr)\gr=x\gr+y\gr^2=y+(x+y)\gr.
\end{equation}
Hence, if~\eqref{eqn:Fib} holds when $n=k$,
then
\begin{equation*}
  \gr^{k+1}=(\Fib {k-1}+\Fib k\gr)\gr=\Fib k+(\Fib {k-1}+\Fib k)\gr=\Fib k+\Fib {k+1}\gr,
\end{equation*}
so it holds when $n=k+1$.  Therefore~\eqref{eqn:Fib} holds for all
positive $n$.  But from~\eqref{eqn:F-proof} we have
\begin{equation*}
  x+y\gr=(y+(x+y)\gr)\gr\inv.
\end{equation*}
By letting $y=u$ and $x=v-u$, we get
\begin{equation*}
v-u+u\gr=(u+v\gr)\gr\inv.
\end{equation*}
Thus, if~\eqref{eqn:Fib} holds for some $k$, then
\begin{equation*}
  \gr^{k-1}=(\Fib {k-1}+\Fib k\gr)\gr\inv=\Fib k-\Fib {k-1}+\Fib {k-1}\gr=\Fib {k-2}+\Fib {k-1}\gr, 
\end{equation*}
so~\eqref{eqn:Fib} holds when $n=k-1$.  Thus~\eqref{eqn:Fib} holds for all
$n$ in $\Z$.
\end{proof}

\section{April 8, 2008 (Tuesday)}

\begin{problem}\label{prob:qDe3}
  Solve the quadratic Diophantine equation
  \begin{equation}\label{eqn:qDe}
    4x^2+2xy-y^2=4.
  \end{equation}
\end{problem}

\begin{solution}
  We have
  \begin{align*}
    4x^2+2xy-y^2
&=4x^2+2xy+\frac14y^2-\frac54y^2\\
&=\Bigl(2x+\frac12y\Bigr)^2-\frac54y^2\\
%&=(2x+\frac12y+\frac{\sqrt 5}2y)(2x+\frac12y-\frac{\sqrt 5}2y)\\
&=(2x+y\gr)(2x+y\gr')\\
&=\norm{2x+y\gr}
  \end{align*}
in $\Q(\sqrt 5)$.  Let $\mLambda=\lat[2,\gr]$.  Then
$\ord=\End[{\lat[2,\gr]}]=\End[{\lat[1,\gr/2]}]$ by
Lemma~\ref{lem:homothety}.  Since 
\begin{equation*}
  4\Bigl(\frac{\gr}2\Bigr)^2-2\cdot\frac{\gr}2-1=0,
\end{equation*}
we have by Theorem~\ref{thm:conductor} that
$\ord=\lat[1,2\gr]$.  Since $\norm{\gr}=-1$, the positive elements of
$\ord$ of norm $1$ are 
the powers of the least power $\gr^{2n}$ (where $n>0$) that belongs to
$\lat[1,2\gr]$.  By Theorem~\ref{thm:Fib}, we have
\begin{equation*}
  \begin{array}{c||c|c|c}
n    &2&4&6\\\hline
\gr^n&1+\gr&2+3\gr&5+8\gr
  \end{array}
\end{equation*}
So every element of $\ord$ of norm $1$ is $\pm(5+8\gr)^n$ for some $n$
in $\Z$.  This means, if $\gamma$ is a solution of
\begin{equation*}
  \norm{\xi}=4
\end{equation*}
from $\mLambda$, then so is $\pm(5+8\gr)^n\gamma$.  But we can choose
$n$ so that
\begin{equation*}
  1\leq(5+8\gr)^n\size{\gamma}<5+8\gr.
\end{equation*}
Let $(5+8\gr)^n\size{\gamma}=2k+\ell\gr$.  Then $(k,\ell)$ is a point
on the graph of
\begin{equation*}
  1\leq 2x+y\gr<5+8\gr;
\end{equation*}
that is, $(k,\ell)$ lies between the straight lines given by
\begin{equation}\label{eqn:boundaries}
  2x+y\gr=1;\qquad 2x+y\gr=5+8\gr.
\end{equation}
(See Figure~\ref{fig:parallelogram}.)
But also, $(k,\ell)$ lies on the hyperbola given by
\begin{equation}\label{eqn:hyp}
4=\Bigl(2x+\frac12y\Bigr)^2-\frac54y^2=(2x+y\gr)(2x+y\gr'),
\end{equation}
whose asymptotes are given by
\begin{equation*}
(2x+y\gr)(2x+y\gr')=0.  
\end{equation*}
One of the asymptotes, given by $2x+y\gr=0$, is parallel to the
bounding lines given by~\eqref{eqn:boundaries}.  Directly
from~\eqref{eqn:hyp}, the hyperbola itself
meets the bounding line given by $2x+y\gr=1$ at this line's
intersection with the line given by $2x+y\gr'=4$, parallel to the
other asymptote.  This means $(k,\ell)$ lies within the parallelogram
in Figure~\ref{fig:parallelogram}.
\begin{figure}
  \begin{pspicture}%(-3.3,-2)(5,10)
(-1,-2.5)(5,9.5)
\psgrid[subgriddiv=1,griddots=4,gridlabels=0pt](0,0)(-1,-2)(5,9)
\psaxes[labels=none](0,0)(-1,-2)(5,9)
\psline(-0.618,-2)(2.781,9)
\uput[d](-0.618,-2){$2x+y\gr'=0$}
\psline(-1,1.236)(1.618,-2)
\uput[l](-1,1.236){$2x+y\gr=0$}
\psline(-1,1.854)(2.118,-2)
\uput[l](-1,1.854){$2x+y\gr=1$}
\psline(1.382,-2)(4.781,9)
\uput[u](4.781,9){$2x+y\gr'=4$}
\psline(1.69,9)(5,4.910)
\uput[ul](1.69,9){$2x+y\gr=5+8\gr$}
\psdots(1,0)(2,0)(1,1)(2,1)(1,2)(2,2)(1,3)(2,3)(2,4)(3,4)(2,5)(3,5)(2,6)(3,6)(3,7)
\uput[ur](1,0){$4$}
\uput[ur](1,1){$5$}
\uput[ur](1,2){$4$}
\uput[ul](1,3){$1$}
%\uput[dr](2,0){$16$}
%\uput[u](2,1){$19$}
%\uput[ur](2,2){$20$}
%\uput[ur](2,3){$19$}
\uput[ur](2,4){$16$}
\uput[ur](2,5){$11$}
\uput[ur](2,6){$4$}
%\uput[u](3,4){$44$}
%\uput[ur](3,5){$41$}
%\uput[ur](3,6){$36$}
%\uput[ul](3,7){$29$}
\parametricplot[linestyle=dashed]{-2}{9}{t -1 mul 5 t t mul mul 16 add
  sqrt add 4 div t} 
\parametricplot[linestyle=dashed]{-2}{0}{t -1 mul 5 t t mul mul 16 add
  sqrt sub 4 div t} 
  \end{pspicture}
  \begin{comment}
    

  \hfill
  \begin{pspicture}(-1,-2)(5,10)
\psaxes[labels=none](0,0)(-1,-2)(5,9)
\psline(-0.618,-2)(2.781,9)
\psline(-1,1.236)(1.618,-2)
\psline(-1,1.854)(2.118,-2)
\psline(1.382,-2)(4.781,9)
\psline(1.69,9)(5,4.910)
\parametricplot{-2}{9}{t -1 mul 5 t t mul mul 16 add sqrt add 4 div t}
  \end{pspicture}
\hfill\mbox{}


  \end{comment}
\caption{Solutions of $4x^2+2xy-y^2=4$}\label{fig:parallelogram}
\end{figure}
There are finitely many integer points in that parallelogram; for
every such point $(x,y)$, we compute $\norm{2x+y\gr}$.  In fact, once
we have computed the norms indicated in the figure, we can see that
the only points for which the corresponding norm is $4$ are $(1,0)$,
$(1,2)$, and $(2,6)$.  Therefore the solutions to~\eqref{eqn:qDe} are
those $(x,y)$ such that $2x+y\gr=\pm(5+8\gr)^n\gamma$, where $n\in\Z$
and $\gamma\in\{2,2+2\gr,4+6\gr\}$.
\end{solution}

\section{April 11, 2008 (Friday)}

Theorem~\ref{thm:Fib} can be understood in terms of matrices.
Multiplication in $\lat[1,\gr]$ by $\gr$ corresponds to a matrix 
multiplication: 
\begin{equation*}
\begin{pmatrix}
  0&1\\1&1
\end{pmatrix}
\begin{pmatrix}
  x\\y
\end{pmatrix}
=
  \begin{pmatrix}
    y\\x+y
  \end{pmatrix}
\end{equation*}
Inverting the matrix, we have
\begin{equation*}
\begin{pmatrix}
  -1&1\\1&0
\end{pmatrix}
\begin{pmatrix}
  x\\y
\end{pmatrix}
=
  \begin{pmatrix}
    y-x\\x
  \end{pmatrix}.
\end{equation*}
corresponding to multiplication by $\gr\inv$.

We have
\begin{equation*}
  (x+y\gr)(5+8\gr)=5x+(8x+5y)\gr+8y\gr^2=5x+8y+(8x+13y)\gr,
\end{equation*}
and
\begin{equation*}
\begin{pmatrix}
  5&8\\8&13
\end{pmatrix}\inv=
\begin{pmatrix}
  13&-8\\-8&5
\end{pmatrix}.
\end{equation*}
We also have the correspondence $(x,y)\mapsto 2x+y\gr$ between
solutions to~\eqref{eqn:qDe} and elements of $\lat[2,\gr]$ of norm
$4$.  If $(a,b)$ is a solution, we compute
\begin{equation*}
\quad
  \begin{pmatrix}
  5&8\\8&13
\end{pmatrix}
  \begin{pmatrix}
    2a\\b
  \end{pmatrix}=
  \begin{pmatrix}
    10a+8b\\16a+13b
  \end{pmatrix},
\quad
\begin{pmatrix}
  13&-8\\-8&5    
  \end{pmatrix}
\begin{pmatrix}
  2a\\b
\end{pmatrix}=
\begin{pmatrix}
  26a-8b\\
-16a+5b
\end{pmatrix},
\end{equation*}
so that $(5a+4b,16a+13b)$ and $(13a-4b,-16a+5b)$ are also solutions.
Hence the three bi-directional sequences of solutions (along the right-hand
branch of the hyperbola depicted in Figure~\ref{fig:parallelogram}) can be
written thus:
\begin{equation*}
\setlength{\arraycolsep}{1pt}
\begin{array}{*9c}
\dots,&(4181,-5168),&(233,-288),&(13,-16),&(1,0),&(5,16),&(89,288),&(1597,5168),&\dots\\
\dots,&(1597,-1974),&(89,-110),&(5,-6),&(1,2),&(13,42),&(233,754),&(4181,13530),&\dots\\
\dots,&(610,-754),&(34,-42),&(2,-2),&(2,6),&(34,110),&(610,1974),&(10946,35422),&\dots
\end{array}
\end{equation*}
We may note that each entry (except $0$) appears more than once.  And
we can combine these solutions into one sequence, thus:
\begin{equation*}
\dots,(34,-42),(13,-16),(5,-6),(2,-2),(1,0),(1,2),(2,6),(5,16),(13,42),(34,110),\dots
\end{equation*}
Dividing the second coordinates by $2$ leaves
\begin{equation*}
\dots,(34,-21),(13,-8),(5,-3),(2,-1),(1,0),(1,1),(2,3),(5,8),(13,21),(34,55),\dots
\end{equation*}
Here we see all of the Fibonacci numbers.  We can obtain all
solutions of~\eqref{eqn:qDe} from $(1,0)$ by the composition of operations
\begin{equation*}
  (x,2y)
\mapsto(x,y)
\mapsto(x+y,x+2y)
\mapsto(x+y,2x+4y),
\end{equation*}
along with the inverse of this composition.  The middle operation in
this composition corresponds to multiplication by $1+\gr$:
\begin{equation*}
  (x+y\gr)(1+\gr)=x+(x+y)\gr+y\gr^2=x+y+(x+2y)\gr.
\end{equation*}
Thus every solution of~\eqref{eqn:qDe} is $(x,y)$, where
$2x+y\gr=\pm2(1+\gr)^n$ for some $n$ in $\Z$.  Note however that
$1+\gr\not\in\lat[1,2\gr]$, that is, $1+\gr\not\in\ord$ when
$\mLambda=\lat[2,\gr]$. 

\section{April 15, 2008 (Tuesday)}

If we convert a quadratic Diophantine equation to\topic{Finding units}
the form $\norm{x\alpha+y\beta}=m$, where $\alpha,\beta\in K$, then we
can solve as in Problems~\ref{prob:qDe1},~\ref{prob:qDe2},
and~\ref{prob:qDe3}, provided we can find the units of
$\roi$.  The case where $d>0$ is the challenging case.  What is the
fundamental unit $\epsilon$ (such that every unit of $\roi$ is
$\pm\epsilon^n$ for some $n$)? 

We have $\roi=\lat[1,\omega]$, and
\begin{equation*}
  \norm{x+y\omega}=
  \begin{cases}
    x^2-dy^2,&\text{ if $d\equiv2$ or $3\pmod 4$};\\
(x+y/2)^2-dy^2/4,&\text{ if }d\equiv1.
  \end{cases}
\end{equation*}
We know $\epsilon=a+b\omega$ for some positive $a$ and $b$, unless
$d=5$.  Assuming
$d\neq5$, we shall show that $a/b$ is a convergent of $\sqrt d$, if
$d\equiv2$ or $3$; otherwise, $(2a+b)/b$ is a convergent of $\sqrt d$.

\begin{lemma}\label{lem:q_{n+1}}
  Assuming $\sqrt d=[a_0;a_1,a_2,\dots]$, let
  $p_n/q_n=[a_0;a_1,\dots,a_n]$, the $n$th convergent.  Suppose
  $a,b\in\Z$ and $1\leq b<q_{n+1}$.  Then
  \begin{equation*}
    \size{p_n-q_n\sqrt d}\leq\size{a-b\sqrt d},
  \end{equation*}
so that
\begin{equation*}
  q_n\xsize{\frac{p_n}{q_n}-\sqrt d}\leq b\xsize{\frac ab-\sqrt d}.
\end{equation*}
\end{lemma}

\begin{proof}
By Theorem~\ref{thm:-1}, we have
  \begin{equation*}
    (-1)^n=p_{n+1}q_n-p_nq_{n+1}=
    \begin{vmatrix}
      p_{n+1}&p_n\\ q_{n+1}&q_n
    \end{vmatrix}.
  \end{equation*}
So there are $s$ and $t$ in $\Z$ such that
\begin{equation*}
  \begin{pmatrix}
    a\\b
  \end{pmatrix}
=
\begin{pmatrix}
      p_{n+1}&p_n\\ q_{n+1}&q_n
\end{pmatrix}
\begin{pmatrix}
  s\\t
\end{pmatrix}
=
\begin{pmatrix}
  sp_{n+1}+tp_n\\sq_{n+1}+tq_n
\end{pmatrix}.
\end{equation*}
Then
\begin{equation*}
  a-b\sqrt d
= sp_{n+1}+tp_n-sq_{n+1}\sqrt d-tq_n\sqrt d
=s(p_{n+1}-q_{n+1}\sqrt d)
+t(p_n-q_n\sqrt d).
\end{equation*}
So it is enough to show that $t\neq0$ and the two terms here,
$s(p_{n+1}-q_{n+1}\sqrt d)$ and
$t(p_n-q_n\sqrt d)$ have the same sign.
But the factors
$p_{n+1}-q_{n+1}\sqrt d$ and
$p_n-q_n\sqrt d$ have opposite sign.  So it is enough to show
$t\neq0$ and $st\leq0$.

To show $t\neq0$, we note
\begin{equation*}
  \begin{pmatrix}
    s\\t
  \end{pmatrix}
=(-1)^n
\begin{pmatrix}
      q_n&-p_n\\-q_{n+1}&p_{n+1}
\end{pmatrix}
\begin{pmatrix}
  a\\b
\end{pmatrix},
\end{equation*}
so
\begin{equation*}
  t=(-1)^n(-aq_{n+1}+bp_{n+1}).
\end{equation*}
If $t=0$, then $aq_{n+1}=bp_{n+1}$; but $\gcd(p_{n+1},q_{n+1})=1$, so
  $q_{n+1}\divides b$, hence $q_{n+1}\leq b$.

To show $st\leq0$, suppose $s\neq0$.  We have
\begin{equation*}
  b=sq_{n+1}+tq_n.
\end{equation*}
If $s<0$ and $1\leq b$, then $t>0$; if $s>0$ and $b<q_{n+1}$, then
$t<0$. 
\end{proof}

The lemma uses only that $\sqrt d$ \emph{has} convergents up to
$p_{n+1}/q_{n+1}$.  The following theorem requires only that all
convergents of $\sqrt d$ exist, that is, $\sqrt d$ must be irrational.

\begin{theorem}\label{thm:criterion}
  If $a$ and $b$ are positive rational integers, and 
  \begin{equation*}
    \xsize{\frac ab-\sqrt d}<\frac1{2b^2},
  \end{equation*}
then $a/b$ is a convergent of $\sqrt d$.
\end{theorem}

\begin{proof}
  Since $(q_n\colon n\in\varN)$ increases to $\infty$, we can find $n$
  such that
  \begin{equation*}
    q_n\leq b<q_{n+1}.
  \end{equation*}
By Lemma~\ref{lem:q_{n+1}}, we have
\begin{align*}
  q_n\xsize{\frac{p_n}{q_n}-\sqrt d}
&\leq b\xsize{\frac ab-\sqrt d}<\frac1{2b},\\
\xsize{\frac{p_n}{q_n}-\sqrt d}
&<\frac1{2bq_n}.
\end{align*}
Then
\begin{align*}
  \frac1{bq_n}\size{aq_n-bp_n}
&=\xsize{\frac ab-\frac{p_n}{q_n}}
\leq\xsize{\frac ab-\sqrt d}+\xsize{\sqrt d-\frac{p_n}{q_n}}
<\frac1{2b^2}+\frac1{2bq_n}
\leq\frac1{bq_n},\\
\size{aq_n-bp_n}
&<1,
\end{align*}
so $aq_n=bp_n$ and $a/b=p_n/q_n$.
\end{proof}

\begin{theorem}\label{thm:units-from-convergents}
%Let $K=\Q(\sqrt d)$, where $d$ is a positive \sqf{} rational integer
%different from $1$.  
Assuming $d>0$, let $a+b\omega$ be a unit of
$\roi$, where $a,b>0$. 
\begin{enumerate}
  \item\label{item:d=2,3}
If $d\equiv2$ or $3\pmod 4$, then $a/b$ is a convergent of $\sqrt d$.
\item\label{item:d=1}
If $d\equiv1$, then $(2a+b)/b$ is a convergent of $\sqrt d$, provided
either $d\geq17$, or else $d=13$ and $a+b\omega$ is the fundamental
unit of $\roi$.
\end{enumerate}
Also, $a$ is the nearest integer to $-b\omega'$.
\end{theorem}

\begin{proof}
  Suppose first $d\equiv2$ or $3$, so that
  \begin{equation}\label{eqn:a^2-db^2=pm1}
    a^2-db^2=\pm1.
  \end{equation}
  By Theorem~\ref{thm:criterion}, it is enough to show
  \begin{equation*}
    \xsize{\frac ab-\sqrt d}<\frac1{2b^2},
  \end{equation*}
that is,
\begin{equation*}
  \size{a-b\sqrt d}<\frac1{2b},
\end{equation*}
that is (multiplying by $a+b\sqrt d$ and
using~\eqref{eqn:a^2-db^2=pm1}), 
\begin{equation*}
  1<\frac{a+b\sqrt d}{2b}=\frac12\Bigl(\frac ab+\sqrt d\Bigr).
\end{equation*}
But we have (again from~\eqref{eqn:a^2-db^2=pm1})
\begin{gather*}
  a^2-db^2\geq-1,\\
\Bigl(\frac ab\Bigr)^2\geq d-\frac 1{b^2}\geq d-1,\\
\frac ab\geq\oldsqrt{d-1},\\
\frac12\Bigl(\frac ab+\sqrt d\Bigr)\geq \frac12(\oldsqrt{d-1}+\sqrt d)>1
\end{gather*}
since $d\geq2$.

In case $d\equiv1$, we try to proceed as before.  We have
\begin{equation*}
  (2a+b)^2-db^2=\pm4,
\end{equation*}
so that
\begin{equation}\label{eqn:ineqn}
  \Bigl(\frac{2a+b}b\Bigr)^2\geq d-\frac4{b^2}\geq d-4.
\end{equation}
We should like to show
\begin{equation}\label{eqn:4<}
  4<\frac12\Bigl(\frac{2a+b}b+\sqrt d\Bigr).
\end{equation}
It is enough if we can show
\begin{equation*}
  4<\frac12(\oldsqrt{d-4}+\sqrt d).
\end{equation*}
We have this if $d\geq21$.  It remains to consider the cases when $d$
is $13$ or $17$.  We can do this with the second part of the 
theorem.

Indeed, since $a,b>1$, we have $a+b\omega>2$.  Since
\begin{equation*}
  1=(a+b\omega)\size{a+b\omega'},
\end{equation*}
we conclude
\begin{equation*}
  \size{a+b\omega'}<\frac12,
\end{equation*}
so $a$ is the nearest integer to $-b\omega'$.


In case $d=13$, we have $-\omega'\approx 1.3$, to which $1$ is the
nearest integer; and $1+\omega$ is indeed a unit (of norm $-1$) and is
the least possible unit greater than $1$, so it is the fundamental
unit of $\roi$.  But
$(2\cdot1+1)/1=3$, which is the first convergent of $\sqrt13$.

When $d=17$, we have $-\omega'\approx1.56$, to which $2$ is
nearest; but  $\norm{2+\omega}=2$.  So $b>1$.  Then instead
of~\eqref{eqn:ineqn} we have
\begin{equation*}
  \Bigl(\frac{2a+b}b\Bigr)^2\geq d-\frac4{b^2}\geq d-1.
\end{equation*}
So it is enough if we have
\begin{equation*}
  4<\frac12(\oldsqrt{d-1}+\sqrt d);
\end{equation*}
but we do have this.
\end{proof}

\section{April 18, 2008 (Friday)}

The argument for Case~\eqref{item:d=1} of
Theorem~\ref{thm:units-from-convergents} does not work when $d=13$,
because $13$ is too small.  We cannot show~\eqref{eqn:4<}, because we
do not have
\begin{equation*}
  4<\frac12(\sqrt d+\sqrt d),
\end{equation*}
when $d=13$.  
But we can show $\sqrt{13}=[3;1,1,1,1,6]$ (this was~\eqref{eqn:rt13})
and obtain the convergents listed in Table~\ref{tab:13}.
\begin{table}[ht]
\begin{equation*}
%\renewcommand{\arraystretch}{1.5}
  \begin{array}{|c||*{5}{c|}}\hline
n&0&1&2&3&4\\\hline
    \displaystyle \displaystyle\frac{p_n}{q_n}%\text{ or }\frac{2a+b}b
\vphantom{\displaystyle\frac{\sqrt 1}{q\sqrt 1}}
& \displaystyle\frac 31&
    \displaystyle\frac41& \displaystyle\frac72&
    \displaystyle\frac{11}3& \displaystyle\frac{18}5\\\hline
p_n{}^2-13q_n{}^2
\vphantom{\sqrt 1}
& -4& 3& -3& 4& -1\\\hline
\displaystyle\frac{2a+b}b
\vphantom{\displaystyle\frac{\sqrt 1}{q\sqrt 1}}
&\displaystyle\frac31&&
&\displaystyle\frac{11}3
&\displaystyle\frac{36}{10}
\\\hline 
    (1+\omega)^k, \text{ or }a+b\omega 
&1+\omega &&
&4+3\omega
&13+10\omega \\\hline
k&1&&&2&3\\\hline\hline
n&5&6&7&8&9\\\hline
\displaystyle \displaystyle\frac{p_n}{q_n}%\text{ or }\frac{2a+b}b
\vphantom{\displaystyle\frac{\sqrt 1}{q\sqrt 1}}
&   \displaystyle\frac{119}{33}& \displaystyle\frac{137}{38}&
    \displaystyle\frac{256}{71}& \displaystyle\frac{393}{109}&
    \displaystyle\frac{649}{180}\\\hline
p_n{}^2-13q_n{}^2
\vphantom{\sqrt 1}
& 4& -3& 3& -4& 1\\\hline
\displaystyle\frac{2a+b}b
\vphantom{\displaystyle\frac{\sqrt 1}{q\sqrt 1}}
&\displaystyle\frac{119}{33}&&
&\displaystyle\frac{393}{109}
&\displaystyle\frac{1298}{360}\\\hline 
    (1+\omega)^k, \text{ or }a+b\omega 
&43+33\omega&&
&142+109\omega 
&469+360\omega  \\\hline
k&4&&&5&6\\\hline
  \end{array}
\end{equation*}
\caption{Convergents of $\sqrt d$, units of $\roi$, when $d=13$}\label{tab:13}
\end{table}
Also, the positive units of $\roi$ (when $d=13$) are the powers of
$1+\omega$, and we have
\begin{equation*}
\omega=\frac{1+\sqrt{13}}2,\qquad\Bigl(\omega-\frac12\Bigr)^2=\frac{13}4,\qquad
\omega^2=3+\omega,
\end{equation*}
so that
\begin{equation*}
  (x+y\omega)(1+\omega)=x+(x+y)\omega+y(3+\omega)=x+3y+(x+2y)\omega.
\end{equation*}
This gives the rest of Table~\ref{tab:13}.

\begin{theorem}\label{thm:13}
  Assuming $d=13$, let
$p_k/q_k$ be the $k$th convergent of $\sqrt d$, and let
  \begin{equation*}
    a_{\ell}+b_{\ell}\omega=(1+\omega)^{\ell}.
  \end{equation*}
Then
\begin{equation*}
  \frac{2a_{3m+i}+b_{3m+i}}{b_{3m+i}}=
    \begin{cases}
      p_{5m}/q_{5m},&\text{ if }i=1;\\
      p_{5m+3}/q_{5m+3},&\text{ if }i=2;\\
      p_{5m+4}/q_{5m+4},&\text{ if }i=3.
    \end{cases}
\end{equation*}
\end{theorem}

\begin{proof}
  Use the method of Problem~\ref{prob:Pell}.  The claim holds when
  $m=0$.  Writing $p/q$ for $p_k/q_k$, and $p'/q'$ for
  $p_{k+5}/q_{k+5}$, we have
  \begin{align*}
    \frac{p'}{q'}
&=\Bigl[3;1,1,1,1,3+\frac pq\Bigr]\\
&=\Bigl[3;1,1,1,1+\frac q{p+3q}\Bigr]\\
&=\Bigl[3;1,1,1+\frac{p+3q}{p+4q}\Bigr]\\
&=\Bigl[3;1,1+\frac{p+4q}{2p+7q}\Bigr]\\
&=\Bigl[3;1+\frac{2p+7q}{3p+11q}\Bigr]\\
&=3+\frac{3p+11q}{5p+18q}\\
&=\frac{18p+65q}{5p+18q}.
  \end{align*}
Writing $a+b\omega$ for $a_{\ell}+b_{\ell}\omega$, and $a'+b'\omega$
for $a_{\ell+3}+b_{\ell+3}\omega$, we have
\begin{align*}
  a'+b'\omega
=&(a+b\omega)(13+10\omega)\\
=&13a+(10a+13b)\omega+10b(3+\omega)\\
=&13a+30b+(10a+23b)\omega.
\end{align*}
Therefore, if
\begin{equation*}
  \frac pq=\frac{2a+b}b,
\end{equation*}
so that
\begin{equation*}
  \frac{p-q}{2q}=\frac ab,
\end{equation*}
then
\begin{align*}
  \frac{2a'+b'}{b'}
&=\frac{26a+60b+10a+23b}{10a+23b}\\
&=\frac{36a+83b}{10a+23b}\\
&=\frac{36(p-q)+83\cdot2q}{10(p-q)+23\cdot2q}\\
&=\frac{36p-36q+166q}{10p-10q+46q}\\
&=\frac{36p+130q}{10p+36q}\\
&=\frac{18p+65q}{5p+18q}
=\frac{p'}{q'}.
\end{align*}
Therefore the claim holds for all $m$.
\end{proof}

But not all units of $\roi$ are obtained from convergents of $\sqrt d$
when $d=5$:

\begin{theorem}\label{thm:5}
  The $n$th convergent of $\sqrt 5$ is
  $(2\Fib{3n+2}+\Fib{3n+3})/\Fib{3n+3}$. 
\end{theorem}

\begin{proof}
  Exercise.
\end{proof}

\section{April 22, 2008 (Tuesday)}

We can give 
\topic{Deeper into continued fractions}
alternative proofs of Theorems~\ref{thm:13}
and~\ref{thm:5}, avoiding the computations, by developing more of the
theory of continued fractions.  Along the way, we shall establish
that, whenever
$d$ is a positive non-square, then $\sqrt d$ is indeed
$[a_0;\overline{a_1,\dots,a_n}]$ for some $n$; and, moreover, $(a,b)$ is a
positive solution to the Pell equation~\eqref{eqn:pell} if and only if 
$(a,b)=(p_{n-1},q_{n-1})$
for some \emph{even} $n$ such that $\sqrt
d=[a_0;\overline{a_1,\dots,a_n}]$. 

Part of the last claim follows from the \emph{proof} of
case~\eqref{item:d=2,3} of Theorem~\ref{thm:units-from-convergents}:

\begin{porism}
  If $(a,b)$ is a positive solution of~\eqref{eqn:pell}, then
  $(a,b)=(p_n,q_n)$ for some convergent $p_n/q_n$ of $\sqrt d$.
\end{porism}

\begin{proof}
  We have $a/b=p_n/q_n$ from the proof of
  Theorem~\ref{thm:units-from-convergents}; then $a=p_n$ and
  $b=q_n$ since each fraction must be in lowest terms (the latter by
  Theorem~\ref{thm:-1}). 
\end{proof}

The computation of the continued-fraction expansions of particular
$\sqrt d$ (as in Problem~\ref{prob:Pell}) suggests the following. 

\begin{lemma}\label{lem:st}
Let $d$ be a positive non-square, and,
in the notation of~\eqref{eqn:a_0} and~\eqref{eqn:a_n}, let $x=\sqrt
d$.  Then
  \begin{equation*}
    \xi_n=\frac{\sqrt d-t_n}{s_n},
  \end{equation*}
where $s_n$ and $t_n$ are rational integers.
\end{lemma}

\begin{proof}
  It is easy to establish that $s_n$ and $t_n$ are rational
  numbers.  Indeed, the claim holds when $n=0$, since $\xi_0=\sqrt
  d-a_0$.  Suppose the claim holds when $n=k$.  Then
  \begin{align*}
    \xi_{k+1}
&=\frac1{\xi_k}-a_{k+1}\\
&=\frac{s_k}{\sqrt d-t_k}-a_{k+1}\\
&=\frac{\sqrt
      d+t_k}{\Bigl(\displaystyle\frac{d-t_k{}^2}{s_k}\Bigr)}-a_{k+1}\\
&=\frac{\sqrt d-
      \Bigl(a_{k+1}\displaystyle\frac{d-t_k{}^2}{s_k}-t_k\Bigr)}
       {\displaystyle\frac{d-t_k{}^2}{s_k}},
  \end{align*}
so we have
\begin{equation*}
  s_{k+1}=\frac{d-t_k{}^2}{s_k},\qquad
t_{k+1}=a_{k+1}s_{k+1}-t_k.
\end{equation*}
In particular, these are rational.  Also, since $s_0=1$ and $t_0=a_0$,
we have $s_1=d-a_0{}^2$, and all of these are integers.  
Suppose $s_k$, $t_k$, and
$s_{k+1}$ are integers.  Immediately, $t_{k+1}\in\Z$.  Also,
\begin{equation*}
  s_{k+1}\divides d-t_k{}^2,
\end{equation*}
so that, \emph{modulo} $s_{k+1}$,
  \begin{equation*}
  d-t_{k+1}{}^2\equiv d-(a_{k+1}s_{k+1}-t_k)^2
\equiv d-t_k{}^2\equiv0,
  \end{equation*}
and therefore $s_{k+2}\in\Z$.
\end{proof}

\begin{lemma}\label{lem:x}
If $x$ is irrational, with infinite continued-fraction expansion
$[a_0;a_1,\dots]$, then
\begin{equation*}
x=[a_0;a_1,\dots,a_{n-1},a_n+\xi_n]
\end{equation*}
for all $n$.
\end{lemma}

\begin{proof}
  The claim is trivially true when $n=0$, and also
  \begin{align*}
    [a_0;a_1,\dots,a_k,a_{k+1}+\xi_{k+1}]
&=[a_0;a_1,\dots,a_{k-1},a_k,\frac1{\xi_k}]\\
&=[a_0;a_1,\dots,a_{k-1},a_k+\xi_k]
  \end{align*}
by~\eqref{eqn:a_n} and~\eqref{eqn:brackets}.
\end{proof}

\begin{theorem}\label{thm:s}
  If $p_n/q_n$ is the $n$th convergent of $\sqrt d$, and $s_{n+1}$ is as
  in Lemma~\ref{lem:st}, then $(p_n,q_n)$ is a solution of
  \begin{equation*}
    x^2-dy^2=(-1)^{n+1}s_{n+1}.
  \end{equation*}
\end{theorem}

\begin{proof}
  We use Lemmas~\ref{lem:st} and~\ref{lem:x}.  In case $n=0$, 
  \begin{equation*}
    p_0{}^2-dq_0{}^2=a_0{}^2-d=-s_1.
  \end{equation*}
By~\eqref{eqn:pq}, when $k\geq1$, we have
\begin{equation*}
  \frac{p_{k+1}}{q_{k+1}}=\frac{p_ka_{k+1}+p_{k-1}}{q_ka_{k+1}+q_{k-1}}.
\end{equation*}
Since $\sqrt d=[a_0;a_1,\dots,a_k,a_{k+1}+\xi_{k+1}]$, this means
\begin{gather*}
  \sqrt d=
\frac{p_k(a_{k+1}+\xi_{k+1})+p_{k-1}}{q_k(a_{k+1}+\xi_{k+1})+q_{k-1}},\\
(q_ka_{k+1}+q_{k-1})\sqrt d+q_k\xi_{k+1}\sqrt d
=p_ka_{k+1}+p_{k-1}+p_k\xi_{k+1},\\
s_{k+1}(q_ka_{k+1}+q_{k-1})\sqrt d+q_k(\sqrt d-t_{k+1})\sqrt d
=s_{k+1}(p_ka_{k+1}+p_{k-1})+p_k(\sqrt d-t_{k+1}),\\
\bigl(s_{k+1}(q_ka_{k+1}+q_{k-1})-q_kt_{k+1}\bigr)\sqrt d +q_kd
=\bigl(s_{k+1}(p_ka_{k+1}+p_{k-1})-p_kt_{k+1}\bigr)+p_k\sqrt d.
\end{gather*}
Since only $\sqrt d$ is irrational, we obtain
\begin{equation*}
\left\{
  \begin{aligned}
p_k&=    s_{k+1}(q_ka_{k+1}+q_{k-1})-q_kt_{k+1},\\
q_kd&= s_{k+1}(p_ka_{k+1}+p_{k-1})-p_kt_{k+1}.
  \end{aligned}
\right.
\end{equation*}
Multiplying by $p_k$ and $q_k$ respectively, then subtracting, yields
\begin{equation*}
  p_k{}^2-dq_k{}^2=s_{k+1}(p_kq_{k-1}-q_kp_{k-1})=(-1)^{k+1}s_{k+1}
\end{equation*}
by Theorem~\ref{thm:-1}.
\end{proof}

\begin{corollary}
  $s_n>0$.
\end{corollary}

\begin{proof}
By Theorem~\ref{thm:-1} and its corollary,
\begin{align*}
  (-1)^{n+1}=1
&\Iff\frac{p_n}{q_n}>\sqrt d\\
&\Iff p_n-q_n\sqrt d>0\\
&\Iff p_n{}^2-dq_n{}^2>0,
\end{align*}
which yields the claim.
\end{proof}

\begin{lemma}\label{lem:frac-lin}
If $[a_0;a_1,\dots,a_{n-1},b]=[a_0;a_1,\dots,a_{n-1},c]$, then $b=c$.
\end{lemma}

\begin{proof}
  Let $[a_0;a_1,\dots,a_{n-1},x]=y$.  The claim is easy if $0\leq
  n\leq 1$.  Suppose $n>1$.  By Theorem~\ref{thm:pq}, we have
  \begin{equation*}
    y=\frac{p_{n-1}x+p_{n-2}}{q_{n-1}x+q_{n-2}}.
  \end{equation*}
Then we can recover $x$ by
\begin{equation*}
  x=\frac{\phantom{-}q_{n-2}y-p_{n-2}}{-q_{n-1}y+p_{n-1}},
\end{equation*}
since $y\neq p_{n-1}/q_{n-1}$
by Theorem~\ref{thm:-1}.
\end{proof}


\begin{theorem}\label{thm:rt-d-periodic}
  If $d$ is a positive non-square, then
  \begin{equation}\label{eqn:rt-d-periodic}
    \sqrt d=[a_0;\overline{a_1,\dots,a_n}]
  \end{equation}
for some $n$.  If $m$ is the least such $n$, then the positive
solutions of the Pell equation~\eqref{eqn:pell} are precisely
$(p_{km-1},q_{km-1})$, where $k>0$ and $km$ is even.
\end{theorem}

\begin{proof}
  The Pell equation has a positive solution by
  Lemma~\ref{lem:pos-sol}.  This solution is $(p_{n-1},q_{n-1})$ for
  some $n$, by the porism from
  Theorem~\ref{thm:units-from-convergents}.  Then $n$ is even, and
  and $s_n=1$, by Theorem~\ref{thm:s} and its corollary.  Then
  $\xi_{n}=\sqrt d-t_{n}$ by Lemma~\ref{lem:st}, and $t_{n}$ is unique
  such
  that $0<\sqrt d-t_{n}<1$.  But $0<\sqrt d-a_0<1$, so $t_n=a_0$, and
$\xi_{n}=\xi_0$.  Therefore $a_{n+1}=a_1$, and $\xi_{n+1}=\xi_1$, and
  so forth, so~\eqref{eqn:rt-d-periodic} holds.  If $m$ is the least
  such $n$, 
  then, for any such $n$, we must have $m\divides n$.

Conversely, suppose $\sqrt d=[a_0;\overline{a_1,\dots,a_m}]$.  Then
\begin{align*}
  \sqrt d
&=[a_0;a_1,\dots,a_{km-1},a_{km},\overline{a_1,\dots,a_m}]\\
&=[a_0;a_1,\dots,a_{km-1},a_{km}-a_0+a_0,\overline{a_1,\dots,a_m}]\\
&=[a_0;a_1,\dots,a_{km-1},a_{km}-a_0+\sqrt d].\\
\intertext{But also}
\sqrt d&=[a_0;a_1,\dots,a_{km-1},a_{km}+\xi_{km}],
\end{align*}
 by
Lemma~\ref{lem:x}; hence, by Lemma~\ref{lem:frac-lin}, $\xi_{km}=\sqrt
d-a_0$.  In particular, $s_{km}=1$,  so $(p_{km-1},q_{km-1})$
solves~\eqref{eqn:pell} by Theorem~\ref{thm:s}, as long as $km$ is even.
\end{proof}

\begin{porism}
  If~\eqref{eqn:rt-d-periodic}, then $\xi_{n+k}=\xi_k$ for all $k$.
\end{porism}

\begin{proof}
  Under the assumption, $p_{n-1}{}^2-dq_{n-1}{}^2=(-1)^n$, so $s_n=1$,
  and $\xi_n=\xi_0$.  Hence the claim.
\end{proof}

Some of the computations in Theorems~\ref{thm:13} and~\ref{thm:5} are
special cases of the following.

\begin{theorem}
  If $\sqrt d=[a_0;\overline{a_1,\dots,a_n}]$, then
    \begin{equation*}
      p_{k+n}+q_{k+n}\sqrt d=(p_{n-1}+q_{n-1}\sqrt d)(p_k+q_k\sqrt d),
    \end{equation*}
equivalently,
\begin{equation*}
  \begin{pmatrix}
    p_{k+n}\\q_{k+n}
  \end{pmatrix}=
  \begin{pmatrix}
    p_{n-1}&dq_{n-1}\\q_{n-1}&p_{n-1}
  \end{pmatrix}
  \begin{pmatrix}
    p_k\\q_k
  \end{pmatrix}.
\end{equation*}
\end{theorem}

\begin{proof}
  We shall use that
  \begin{align*}
    \sqrt
    d&=[a_0;a_1,\dots,a_{n-1},a_n-a_0+a_0,\overline{a_1,\dots,a_n}]\\
&=[a_0;a_1,\dots,a_{n-1},a_n-a_0+\sqrt d].
  \end{align*}
By Theorem~\ref{thm:pq} we have
\begin{align*}
  [a_0;a_1,\dots,a_{n-1},a_n-a_0+x]
&=\frac{(a_n-a_0+x)p_{n-1}+p_{n-2}}{(a_n-a_0+x)q_{n-1}+q_{n-2}}\\
&=\frac{p_{n-1}x+(a_n-a_0)p_{n-1}+p_{n-2}}{q_{n-1}x+(a_n-a_0)q_{n-1}+q_{n-2}}.
\end{align*}
(Here, if $n=1$, then $p_{n-2}=1$ and $q_{n-2}=0$.)  Letting $x=\sqrt
d$, and using that this is irrational, we have
\begin{gather*}
  \sqrt d=
\frac{p_{n-1}\sqrt d+(a_n-a_0)p_{n-1}+p_{n-2}}{q_{n-1}\sqrt
  d+(a_n-a_0)q_{n-1}+q_{n-2}},\\
\left\{
\begin{aligned}
  dq_{n-1}&=(a_n-a_0)p_{n-1}+p_{n-2},\\
p_{n-1}&=(a_n-a_0)q_{n-1}+q_{n-2}.
\end{aligned}
\right.
\end{gather*}
Combining all of this, we have
\begin{equation*}
  [a_0;a_1,\dots,a_{n-1},a_n-a_0+x]
  =\frac{p_{n-1}x+dq_{n-1}}{q_{n-1}x+p_{n-1}}.
\end{equation*}
Now letting $x=p_k/q_k$, we get
\begin{equation*}
  \frac{p_{k+n}}{q_{k+n}}=
  \Bigl[a_0;a_1,\dots,a_{n-1},a_n-a_0+\frac{p_k}{q_k}\Bigr] 
=\frac{p_{n-1}p_k+dq_{n-1}q_k}{q_{n-1}p_k+p_{n-1}q_k}.
\end{equation*}
We are done, once we establish that the last fraction is in lowest
terms.  Writing this fraction as $a/b$, by
Theorem~\ref{thm:rt-d-periodic} we have
\begin{gather*}
  q_{n-1}a-p_{n-1}b=-(-1)^nq_k,\\
p_{n-1}a-dq_{n-1}b=(-1)^np_k,
\end{gather*}
so $\gcd(a,b)=1$ since $\gcd(p_k,q_k)=1$.
\end{proof}

Finally, as a refinement of Theorem~\ref{thm:rt-d-periodic}, we have
the following.

\begin{theorem}\label{thm:ultimate}
  If $d$ is a positive non-square, then
  \begin{equation*}
    \sqrt d=[a_0;\overline{a_1,\dots,a_{n-1},2a_0}]
  \end{equation*}
for some $n$, where
\begin{equation}\label{eqn:a_k}
a_k=a_{n-k}
%  (a_1,\dots,a_{n-1})=(a_{n-1},\dots,a_1).
\end{equation}
when $0<k<n$.
\end{theorem}

\begin{proof}
  By Theorem~\ref{thm:rt-d-periodic}, we
  have~\eqref{eqn:rt-d-periodic}.
We shall show first
\begin{equation}\label{eqn:xi_k}
  \xi_k=\frac1{-\xi_{n-(k+1)}{}'}
\end{equation}
whenever $0\leq k<n$.
By Lemma~\ref{lem:st}, we have
\begin{equation*}
  \frac1{\xi_k}=\frac{s_k}{\sqrt d-t_k}=\frac{\sqrt d+t_k}{s_{k+1}}.
\end{equation*}
Now using also Lemma~\ref{lem:x}, as well as~\eqref{eqn:pq} and
Theorem~\ref{thm:pq}, we have
\begin{gather*}
  \qquad s_{k+1}\cdot\frac1{\xi_k}=\sqrt d+t_k
=\Bigl[a_0+t_k;a_1,\dots,a_k,\frac1{\xi_k}\Bigr]
=\frac{p_k\cdot\displaystyle\frac1{\xi_k}+p_{k-1}}
      {q_k\cdot\displaystyle\frac1{\xi_k}+q_{k-1}},\\
s_{k+1}q_k\cdot\Bigl(\frac1{\xi_k}\Bigr)^2
+(s_{k+1}q_{k-1}-p_k)\cdot\frac1{\xi_k}-p_{k-1}=0. 
\end{gather*}
Thus $1/\xi_k$ and hence $1/\xi_k{}'$ are the roots of the quadratic
polynomial 
\begin{equation*}
s_{k+1}q_kx^2+(s_{k+1}q_{k-1}-p_k)x-p_{k-1}.
\end{equation*}
Call this $f(x)$.  Then $f(-1)=s_{k+1}(q_k-q_{k-1})+p_k-p_{k-1}>0$,
while $f(0)=-p_{k-1}<0$, so $f$ has a root between $-1$ and $0$.  That
root must be $1/\xi_k{}'$, since
$1/\xi_k>0$.  Therefore
\begin{equation*}
  0<\frac1{-\xi_k{}'}<1.
\end{equation*}
We also have
\begin{equation*}
  0<\xi_k<1.
\end{equation*}
We can now establish~\eqref{eqn:xi_k} by induction.
Since $1/\xi_{n-1}=a_n+\xi_n=\xi_0+a_n=\sqrt d-a_0+a_n$ by the porism to
Theorem~\ref{thm:rt-d-periodic}, so that $1/{-\xi_{n-1}{}'}=\sqrt
d+a_0-a_n$; while $\xi_0=\sqrt d-a_0$; we must have
\begin{equation*}
\xi_0=\frac1{-\xi_{n-1}{}'},\qquad a_n=2a_0.
\end{equation*}
In particular, we have~\eqref{eqn:xi_k} when $k=0$.  Suppose we have
it when $k=j$, where $j+1<n$.  Then
\begin{equation*}
  \xi_{j+1}+a_{j+1}
  =\frac1{\xi_j}=-\xi_{n-(j+1)}{}'
  =-\Bigl(\frac1{\xi_{n-(j+2)}}-a_{n-(j+1)}\Bigr)' 
  =\frac1{\xi_{n-(j+2)}{}'}-a_{n-(j+1)}.
\end{equation*}
Thus we have~\eqref{eqn:xi_k} when $k=j+1$.  By induction, we have it
for all $k$ such that $0\leq k<n$, and incidentally we
have~\eqref{eqn:a_k} when $0<k<n$.
\end{proof}

\section{April 29, 2008 (Tuesday)}

We\topic{Lattices as ideals} know $\roi$ is a Euclidean domain when
$d\in\{-1,-3\}$.  But when
$d=-5$, then
\begin{equation}\label{eqn:3215}
  3\cdot2=(1+\sqrt{{-5}})(1-\sqrt{{-5}}),
\end{equation}
although each factor is irreducible. To prove this, suppose for
example
\begin{equation*}
  1+\sqrt{{-5}}=\alpha\beta.
\end{equation*}
Then
$\norm{\alpha}\norm{\beta}=\norm{\alpha\beta}=\norm{1+\sqrt{{-5}}}=6$.
But no element of $\roi$ has norm $2$, since the equation
\begin{equation*}
  x^2+5y^2=2
\end{equation*}
is insoluble.  Hence one of $\norm{\alpha}$ and $\norm{\beta}$ is $1$,
so $\alpha$ or $\beta$ is a unit.  Thus there can be irreducibles that
are not prime.

To avoid such problems, instead of working with the \emph{numbers} in
a quadratic field, we shall work with `ideal numbers,' that is,
\tech{ideal}{s.}  Recall that an \defn{ideal}{} of a commutative ring
$R$ is an additive subgroup of $R$ that is closed under multiplication
by elements of $R$.  In other words, it is an $R$-submodule of $R$.
(The definition of $R$-module is the same as the definition of a real
vector-space, with $\R$ replaced by $R$.) 

We shall generalize this definition slightly so that every lattice
$\mLambda$ of the quadratic field $K$ is an ideal of $\ord$, even if
$\mLambda\nincluded\ord$.  Let $\ord[]$ be an \defn{order}{} of $K$,
that is, a sub-ring of $\roi$ that spans $K$ as a vector-space over
$\Q$.  Then $\ord[]$ is a lattice $\mLambda$ by
Lemma~\ref{lem:lat-cond}, and $\ord=\ord[]$ (exercise).
An additive subgroup $G$ of
$K$ is an \defn{ideal}{} of $\ord[]$ if it is closed under multiplication
by elements of $\ord[]$, \emph{and} $\alpha G\included\ord[]$ for some
non-zero $\alpha$ in $K$; we also require $G\neq\{0\}$.

\begin{theorem}
  Ideals of $\ord[]$ are lattices of $K$.
\end{theorem}

\begin{proof}
Let $L$ be an ideal of $\ord[]$.  We have $\ord[]=\lat[1,c\omega]$ for
  some positive rational integer $c$ by
  Theorem~\ref{thm:cond}. 
  Now use Lemma~\ref{lem:lat-cond}.  There,~\eqref{item:+} is
  immediate.  For~\eqref{item:span}, note that $L$ contains some
  non-zero $\alpha$, hence also $\alpha c\omega$.  But
  $\{\alpha,\alpha c\omega\}$ is a basis of $K$ over $\Q$.
  For~\eqref{item:nL}, we have $\beta L\included\ord[]$ for some
  non-zero $\beta$.  Multiplying $\beta$ by some positive rational
  integer, we may assume $\beta\in\ord[]$.  Then $\beta'\in\ord[]$, so
$\norm{\beta}L=\beta'\beta L\included\beta'\ord[]\included\ord[]$.
\end{proof}

So ideals are nothing new for us.  Instead of saying that $\mLambda$ is
an ideal of $\ord$, we may say that $\mLambda$ \defn{belong}{s to} $\ord$.

Given an order, we aim to develop something like unique
factorization for the lattices belonging to it.  To do this, we shall
use a \tech{norm}{} for lattices.

In the old sense of norm, in any quadratic field $K$, if $n\in\Z$, then
$\norm n=n^2$.  But the smallest ideal of $\roi$ that contains $n$ is
$n\roi$ or $\lat[n,n\omega]$, and the quotient group $\roi/n\roi$ or
$\lat[1,\omega]/\lat[n,n\omega]$ has size $n^2$.  Indeed, every
coset of $\lat[n,n\omega]$ is $a+b\omega+\lat[n,n\omega]$ for some $a$
and $b$ in $\Z$, but
\begin{equation*}
  a+b\omega+\lat[n,n\omega]=s+t\omega+\lat[n,n\omega]\Iff a\equiv
  s\land b\equiv t\pmod n,
\end{equation*}
so there are just $n^2$ distinct cosets.  Generalizing this idea, we
define
\begin{equation*}
  \norm{\mLambda}=\size{\ord/\mLambda}=(\ord:\mLambda),
\end{equation*}
assuming $\mLambda\included\ord$; in this case, $\mLambda$ is an
\defn{integral}{} lattice.

Suppose $\mLambda$ and $\mMu$ are arbitrary lattices of $K$, and
$\mLambda\included\mMu$.  What is $(\mMu:\mLambda)$?  We can write
$\mMu$ as $\lat$; then
\begin{equation*}
  \mLambda=\lat[e\alpha+f\beta,g\alpha+h\beta].
\end{equation*}
By the Euclidean algorithm, we can eliminate $\beta$ from one
generator.  Indeed, suppose $\gcd(f,h)=a$, so that
\begin{equation*}
  fx+hy=a
\end{equation*}
for some $x$ and $y$ in $\Z$.  Then
\begin{equation*}
  \begin{vmatrix}
    h/a&-f/a\\x&y
  \end{vmatrix}=1,\qquad
  \begin{pmatrix}
    h/a&-f/a\\x&y
  \end{pmatrix}
  \begin{pmatrix}
    e\alpha+f\beta\\g\alpha+h\beta
  \end{pmatrix}=
  \begin{pmatrix}
    (he-fg)\alpha/a\\(ex+gy)\alpha+a\beta
  \end{pmatrix}.
\end{equation*}
Thus
\begin{equation}\label{eqn:mLambda}
  \mLambda=\lat[b\alpha,c\alpha+a\beta],
\end{equation}
where $b=(he-fg)/a$ and $c=ex+gy$.  In particular,
\begin{equation}\label{eqn:ab=efgh}
  \size{ab}=
\Bigl\lvert\det
  \begin{pmatrix}
    e&f\\g&h
  \end{pmatrix}
\Bigr\rvert.
\end{equation}
We may then assume that $b>0$ and $0\leq c<b$,
while~\eqref{eqn:mLambda} and~\eqref{eqn:ab=efgh} continue to hold.  Then
the cosets of $\mLambda$ in $\mMu$ are in one-to-one correspondence
with the pairs $(i,j)$ such that $0\leq i<a$ and $0\leq j<b$.  That
is, every element of $\mMu$ is congruent \emph{modulo} $\mLambda$ to
some unique $j\alpha+i\beta$, where $0\leq i<a$ and $0\leq j<b$.  Thus
\begin{equation*}
  (\mMu:\mLambda)=ab=\Bigl\lvert\det
  \begin{pmatrix}
    e&f\\g&h
  \end{pmatrix}
\Bigr\rvert
=\oldsqrt{
  \begin{vmatrix}
    e&f\\g&h
  \end{vmatrix}^2}.
\end{equation*}
For example, say $\mMu=\lat[1,\mi]$ and $\mLambda=\lat[3,1+2\mi]$.
Then $(\mMu:\mLambda)=\size{\mMu/\mLambda}=6$.  See
Figure~\ref{fig:ML}.
\begin{figure}[ht]
  \begin{pspicture}(-0.5,-0.5)(4.5,2.5)
\multirput*(0,0)(1,0)5{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}    
\multirput*(0,1)(1,0)5{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}    
\multirput*(0,2)(1,0)5{\pscircle[fillstyle=solid,fillcolor=black]{0.05}}    
\psline(-0.25,-0.5)(1.25,2.5)
\psline(2.75,-0.5)(4.25,2.5)
\psline(-0.5,0)(4.5,0)
\psline(-0.5,2)(4.5,2)
\uput[dr](1,0){$1$}
\uput[l](0,1){$\mi$}
\uput[dr](0,0){$0$}
  \end{pspicture}
\caption{Lattices $\lat[1,\mi]$ and $\lat[3,1+2\mi]$}\label{fig:ML}
\end{figure}
In the general situation, we have
\begin{equation*}
(\mMu:\mLambda)^2=
  \begin{vmatrix}
    e&f\\g&h
  \end{vmatrix}^2=
\frac
{\displaystyle\begin{vmatrix}
    e&f\\g&h
  \end{vmatrix}^2
  \begin{vmatrix}
    \alpha&\alpha'\\\beta&\beta'
  \end{vmatrix}^2}
{\begin{vmatrix}
    \alpha&\alpha'\\\beta&\beta'
  \end{vmatrix}^2}=\frac{\disc{\mLambda}}{\disc{\mMu}}.
\end{equation*}
We can use this to define the norm in general:
\begin{equation*}
  \norm{\mLambda}=\sqrt[\frac11]{\frac{\disc{\mLambda}}{\disc{\ord}}}.
\end{equation*}
This is always positive, unlike the norm of some numbers when $d>0$.
But suppose $\alpha\in K$, and let $\ord[]$ be an order of $K$.  Then
$\alpha\ord[]$ is a lattice belonging to $\ord[]$; and since
$\ord[]=\lat[1,c\omega]$ for some positive rational integer $c$, we
have
\begin{equation*}
  \norm{\alpha\ord[]}=\sqrt[\frac11]
  {\frac
    {\begin{vmatrix}
      \alpha&\alpha'\\\alpha c\omega&\alpha'c\omega'
     \end{vmatrix}^2}
    {\begin{vmatrix}
      1&1\\c\omega&c\omega'
     \end{vmatrix}^2}}
=\oldsqrt{(\alpha\alpha')^2}=\size{\norm{\alpha}}.
\end{equation*}

\section{May 2, 2008 (Friday)}

The product\topic{Arithmetic of lattices} of lattices $\mLambda$ and
$\mMu$ of $K$
is the smallest subgroup of $K$ that includes the set
$\{xy:x\in\mLambda\land y\in\mMu\}$.  If $\mLambda=\lat$ and
$\mMu=\lat[\gamma,\delta]$, then
\begin{equation*}
  \mLambda\mMu=\lat[\alpha\gamma,\alpha\delta,\beta\gamma,\beta\delta].
\end{equation*}
Then $\mLambda\mMu$ is a lattice by Lemma~\ref{lem:lat-cond}, since
$n\mLambda,n\mMu\included\roi$ for some $m$ and $n$, and then
$nm\mLambda\mMu\included\roi$.  (Also $\mLambda\mMu$ spans $K$ since
$\mLambda\mMu$ contains $\alpha\gamma$ and $\beta\gamma$, which span.)

\begin{lemma}\label{lem:mult}
  Multiplication of lattices is commutative and associative, and
  \begin{equation*}
    \ord\cdot\mLambda=\mLambda.
  \end{equation*}
\end{lemma}

\begin{proof}
  The first part follows from the same properties of multiplication of
  numbers.  For the second part, $\mLambda\included\ord\cdot\mLambda$ since
  $1\in\ord$, and $\ord\cdot\mLambda\included\mLambda$ by definition of
  $\ord$. 
\end{proof}

\begin{lemma}\label{lem:LL'}
For all lattices $\mLambda$ belonging to an order $\ord[]$,
\begin{equation*}
  \mLambda\mLambda'=\norm{\mLambda}\cdot\ord[].
\end{equation*}
\end{lemma}

\begin{proof}
  Suppose first $\mLambda=\lat[1,\tau]$, where
  \begin{equation*}
    A\tau^2+B\tau+C=0,\qquad \gcd(A,B,C)=1,\qquad A>0.
  \end{equation*}
Then
\begin{equation*}
  \frac BA=-(\tau+\tau'),\qquad\frac CA=\tau\tau',\quad \ord=\lat[1,A\tau].
\end{equation*}
Hence
\begin{equation*}
  \lat[1,\tau]\lat[1,\tau']
=\lat[1,\tau',\tau,\tau\tau']
=\Bigl\langle\frac AA,\tau,\frac BA,\frac CA\Bigr\rangle
=\Bigl\langle\frac1A,\tau\Bigr\rangle
=\frac1A\lat[1,A\tau]
=\frac1A\cdot\ord.
\end{equation*}
But
\begin{equation*}
  \norm{\lat[1,\tau]}=\sqrt[\frac11]\frac
{
  \begin{vmatrix}
    1&1\\\tau&\tau'
  \end{vmatrix}^2}
{
  \begin{vmatrix}
    1&1\\A\tau&A\tau'
  \end{vmatrix}^2}
=\frac1A.
\end{equation*}
We can write an arbitrary lattice as $\lat[\alpha,\alpha\tau]$.  
Then
\begin{equation*}
\lat[\alpha,\alpha\tau]\lat[\alpha',\alpha'\tau']
=\alpha\lat[1,\tau]\alpha'\lat[1,\tau']
=\alpha\alpha'\norm{\lat[1,\tau]}\ord
=\norm{\lat[\alpha,\alpha\tau]}\ord,
\end{equation*}
where $\mLambda$ can be understood indifferently as $\lat[1,\tau]$ or
$\lat[\alpha,\alpha\tau]$, by Lemma~\ref{lem:homothety}.
\end{proof}

\begin{theorem}\label{thm:group}
  The lattices belonging to an order $\ord[]$ compose an abelian group
  under multiplication; the identity is $\ord[]$ itself, and inversion
  given by
  \begin{equation*}
    \mLambda\inv=\frac1{\norm{\mLambda}}\mLambda'.
  \end{equation*}
\end{theorem}

\begin{proof}
  By Lemmas~\ref{lem:mult} and~\ref{lem:LL'}, it remains to show that
  the set of lattices belonging to $\ord[]$ is actually closed under
  multiplication.  We have
  \begin{align*}
    \norm{\mLambda}\norm{\mMu}\ord[]
&=\mLambda\mLambda'\mMu\mMu'\\
&=(\mLambda\mMu)(\mLambda\mMu)'\\
&=\norm{\mLambda\mMu}\ord[\mLambda\mMu].
  \end{align*}
But since $\ord[]=\lat[1,c\omega]$ and
$\ord[\mLambda,\mMu]=\lat[1,e\omega]$ for some positive rational
integers $c$ and $e$, we must have $c=e$ and
$\ord=\ord[\mLambda\mMu]$. 
\end{proof}

\begin{porism}
  If $\mLambda$ and $\mMu$ belong to the same order, then
  \begin{equation*}
    \norm{\mLambda\mMu}=\norm{\mLambda}\norm{\mMu}.
  \end{equation*}
\end{porism}

\section{May 6, 2008 (Tuesday)}

In addition to multiplying, we can add lattices:
\begin{equation*}
  \mLambda+\mMu=\{\xi+\eta\colon \xi\in\mLambda\land\eta\in\mMu\}.
\end{equation*}

\begin{lemma}\label{lem:addition}
  Let $\mLambda$ and $\mMu$ be lattices of $K$.
  \begin{enumerate}
\item
    $\mLambda+\mMu$ is a lattice, and
    \begin{equation*}
      \lat+\lat[\gamma+\delta]=\lat[\alpha,\beta,\gamma,\delta].
    \end{equation*}
\item
Addition of lattices is commutative and associative.
\item
Multiplication of lattices distributes over addition.
\item
If $\mLambda$ and $\mMu$ belong to $\ord[]$, then
$\ord[]\included\ord[\mLambda+\mMu]$. 
\item\label{item:LMK}
If $\mLambda$ and $\mMu$ belong to $\roi$, then
$\ord[\mLambda+\mMu]=\roi$. 
  \end{enumerate}
\end{lemma}

\begin{proof}
  Exercise.
\end{proof}

Although $\mLambda$ and $\mMu$ belong to the same order $\ord[]$,
possibly $\mLambda+\mMu$ does not belong to $\ord[]$.  For example,
$\lat[n,1+\omega]$ and $\lat[1,n\omega]$ both belong to
$\lat[1,n\omega]$ (exercise), but
\begin{equation*}
  \lat[n,1+\omega]+\lat[1,n\omega]
=  \lat[n,1+\omega,1,n\omega]
=\lat[1,\omega].
\end{equation*}

We aim to show that the integral lattices belonging to $\ord[]$ have
unique prime factorizations.  What does this mean?  The integral
lattices have norms that are positive rational integers, since in this
case $\norm{\mLambda}=(\ord[]:\mLambda)$.  Also,
\begin{equation*}
  \norm{\mLambda}=1\Iff\mLambda=\ord[]
\end{equation*}
(again assuming $\mLambda\included\ord[]$).  By the porism to
Theorem~\ref{thm:group}, no non-trivial factorization can go on
forever.  That is, we obtain
\begin{equation}\label{eqn:LP}
  \mLambda=P_1P_2\dotsm P_n,
\end{equation}
where each $P_i$ is an integral lattice of norm greater than $1$, with
no factors other than itself and $\ord[]$.  In a word, each $P_i$ is
\defn{irreducible}. 

For example, if $\norm{P}$ is a rational prime $p$, then $P$ is
irreducible, since $p$ is irreducible:
\begin{align*}
  P=\mLambda_0\mLambda_1
&\implies p=\norm{P}=\norm{\mLambda_0}\norm{\mLambda_1}\\
&\implies\norm{\mLambda_i}=1\text{ for some }i\\
&\implies\mLambda_i=\ord[]\land\mLambda_{1-i}=P\text{ for some }i.
\end{align*}

We want (if possible) to establish uniqueness of the factorization
in~\eqref{eqn:LP}.  For this, we use the notion of a \defn{prime}{}
lattice.  Working with the integral lattices of some order $\ord[]$,
we define \defn{divisibility}{} by
\begin{equation*}
  \mLambda\divides\mMu\Iff \mLambda A=\mMu\text{ for some }A.
\end{equation*}

\begin{theorem}\label{thm:division}
  For all integral lattices $\mLambda$ and $\mMu$ of an order
  $\ord[]$,
  \begin{equation*}
    \mLambda\divides\mMu\Iff\mMu\included\mLambda.
  \end{equation*}
\end{theorem}

\begin{proof}
  If $\mLambda A=\mMu$, where $A\included\ord[]$, then $\mMu=\mLambda
  A\included\mLambda\ord[]=\mLambda$.   Conversely, suppose
  $\mMu\included\mLambda$.  Then
  \begin{equation*}
    \mLambda\cdot\frac1{\norm{\mLambda}}\mLambda'\mMu=\ord[]\mMu=\mMu,\qquad
\frac1{\norm{\mLambda}}\mLambda'\mMu\included
\frac1{\norm{\mLambda}}\mLambda'\mLambda=\ord[],
  \end{equation*}
so $(1/\norm{\mLambda})\mLambda'\mMu$ is integral, and
$\mLambda\divides\mMu$. 
\end{proof}

Having division, we may have \tech{greatest common divisor}{s:}  An
integral lattice $\mPi$ is a \defn{greatest common divisor}{} of
$\mLambda$ and $\mMu$ if
\begin{enumerate}
  \item
$\mPi\divides\mLambda\land\mPi\divides\mMu$;
\item
if $\mSigma\divides\mLambda$ and $\mSigma\divides\mMu$, then
$\mSigma\divides\mPi$. 
\end{enumerate}
But what \emph{is} $\mPi$ here?  We have 
\begin{gather*}
\mLambda,\mMu\included\mLambda+\mMu;\\
\mLambda,\mMu\included\mSigma\implies\mLambda+\mMu\included\mSigma.
\end{gather*}
Then we can apply Theorem~\ref{thm:division}, \emph{provided}
$\mLambda+\mMu$ also belongs to $\ord[]$.  (Easily
$\mLambda+\mMu\included\ord[]$.)  So we have:

\begin{lemma}\label{lem:gcd}
  If $\mLambda$ and $\mMu$ are integral lattices of $\roi$, then
  $\mLambda+\mMu$ is their greatest common divisor.
\end{lemma}

\begin{proof}
  By the comments just made, it is enough refer to
  Lemma~\ref{lem:addition}~\eqref{item:LMK}. 
\end{proof}

An integral lattice $P$ is \defn{prime}{} if
\begin{equation*}
  P\divides\mLambda\mMu\land P\ndivides\mLambda\implies P\divides\mMu,
\end{equation*}
equivalently,
\begin{equation*}
  \mLambda\mMu\included P\land \mLambda\nincluded
  P\implies\mMu\included P.
\end{equation*}

\begin{lemma}\label{lem:irred-prime}
  Irreducible integral lattices of $\roi$ are prime.
\end{lemma}

\begin{proof}
  Suppose $\mPi$ is irreducible, $\mLambda\mMu\included \mPi$, but
  $\mLambda\nincluded \mPi$.  But $\mPi+\mLambda\divides\mPi$ by
  Lemma~\ref{lem:gcd}.  Since $\mPi$ is irreducible, $\mPi+\mLambda$
  is either $\mPi$ or $\ord[]$.  But $\mPi\ndivides\mLambda$, so
  $\mPi+\mLambda=\ord[]$.  Hence
  \begin{equation*}
    \mMu=\ord[]\mMu=(\mPi+\mLambda)\mMu=\mPi\mMu+\mLambda\mMu.
  \end{equation*}
%We cannot conclude immediately that $\mPi\divides\mMu$.
But $\mLambda\mMu=\mPi\mSigma$ for some integral $\mSigma$ since
$\mPi\divides\mLambda\mMu$.  Hence
\begin{equation*}
  \mMu=\mPi\mMu+\mPi\mSigma=\mPi(\mMu+\mSigma).
\end{equation*}
By Lemma~\ref{lem:addition}~\eqref{item:LMK}, we have $\mPi\divides\mMu$.
\end{proof}

\begin{theorem}
The integral lattices of $\roi$ admit unique prime factorizations.  
\end{theorem}

\begin{proof}
  Suppose $P_1P_2\dotsm P_m$ and $Q_1Q_2\dotsm Q_m$ are two
  irreducible factorizations of the same lattice $\mLambda$.  Then
  $P_1\divides\mLambda$, so $P_1\divides Q_i$ for some $i$ by
  Lemma~\ref{lem:irred-prime}.  We may assume $i=1$.  Then $P_1=Q_1$,
  since $P_1\neq\roi$ and $Q_1$ is irreducible.  We now have
  \begin{gather*}
    P_1P_2\dotsm P_m=P_1Q_2\dotsm Q_n,\\
%    P_1{}'P_1P_2\dotsm P_m=P_1{}'P_1Q_2\dotsm Q_n,\\
%\norm{P_1}P_2\dotsm P_m=\norm{P_1}Q_2\dotsm Q_n,\\
P_2\dotsm P_m=Q_2\dotsm Q_n
  \end{gather*}
since we are in a group.
Continuing, we get that $m=n$ and we may assume $P_i=Q_i$.
\end{proof}

\section{May 9, 2008 (Friday)}

We want to \emph{find} prime factorizations.  
\topic{Prime factorizations}
For example, let
$\ord[]=\roi$, where $K=\Q(\sqrt{{-5}})$, so that
$\ord[]=\lat[1,\omega]$, where $\omega=\sqrt{{-5}}$.
From~\eqref{eqn:3215} we have 
\begin{equation*}
  (3\ord[])(2\ord[])=((1+\omega)\ord[])((1-{\omega})\ord[]),
\end{equation*}
that is,
\begin{align*}
  \lat[3,3\omega]\lat[2,2\omega]
&=\lat[1+\omega,\omega+\omega^2]\lat[1-\omega,\omega-\omega^2]\\
&=\lat[1+\omega,\omega-5]\lat[1-\omega,\omega+5]\\
&=\lat[6,1+\omega]\lat[6,1-\omega].
\end{align*}
These cannot be prime factorizations.  What, for example, are the
prime factors of
$2\ord[]$, that is, $\lat[2,2\omega]$?  We have $\norm{2\ord[]}=\norm
2\norm{\ord[]}=4$, so we should look for factors of norm $2$.  Two
possibilities are $\lat[2,\omega]$ and $\lat[1,2\omega]$.  (See
Figure~\ref{fig:2-wrong}.) 
\begin{figure}
\mbox{}\hfill
  \begin{pspicture}(-0.5,-0.5)(2.5,5)
    \psdots(0,0)(2,0)(0,2.236)(2,2.236)(0,4.472)(2,4.472)
    \psdots[dotstyle=o](1,0)(1,2.236)(1,4.472)
\uput[dl](0,0){$0$}
\uput[d](1,0){$1$}
\uput[l](0,2.236){$\sqrt{{-5}}$}
  \end{pspicture}
\hfill
  \begin{pspicture}(-0.5,-0.5)(2.5,5)
    \psdots(0,0)(2,0)(0,4.472)(2,4.472)(1,0)(1,4.472)
    \psdots[dotstyle=o](0,2.236)(2,2.236)(1,2.236)
\uput[dl](0,0){$0$}
\uput[d](1,0){$1$}
\uput[l](0,2.236){$\sqrt{{-5}}$}
  \end{pspicture}
\hfill\mbox{}
  \caption{Two index-$2$ sublattices of
  $\lat[1,\sqrt{{-5}}]$}\label{fig:2-wrong} 
\end{figure}
But $\lat[2,\omega]=2\lat[1,\omega/2]$, and $4(\omega/2)^2+5=0$, so
$\ord[{\lat[2,\omega]}]=
\lat[1,4\omega/2]=\lat[1,2\omega]\neq\ord[]$.  So $\lat[2,\omega]$
does not belong to $\ord[]$.  Similarly, $\lat[1,2\omega]$ does not:
in fact, it belongs to itself.  A third option for a prime factor of
$\lat[2,2\omega]$ is $\lat[2,1+\omega]$ (Figure~\ref{fig:2-right}).
\begin{figure}[ht]
  \begin{pspicture}(-0.5,-0.5)(2.5,5)
    \psdots(0,0)(2,0)(0,4.472)(2,4.472)(1,2.236)
    \psdots[dotstyle=o](0,2.236)(2,2.236)(1,0)(1,4.472)
\uput[dl](0,0){$0$}
\uput[d](1,0){$1$}
\uput[l](0,2.236){$\sqrt{{-5}}$}
  \end{pspicture}
\caption{A third index-$2$ sublattice of
  $\lat[1,\sqrt{{-5}}]$}\label{fig:2-right}  
\end{figure}
This works: if $x=(1+\omega)/2$, then $(2x-1)^2=-5$, that is,
$4x^2-4x+6=0$, so $2x^2-2x+3=0$, and $\lat[2,1+\omega]$ belongs to
$\ord[]$.  Also $\lat[2,1+\omega]'=\lat[2,1+\omega]$.  By
Lemma~\ref{lem:LL'}, we have 
\begin{equation*}
  \lat[2,1+\omega]^2=2\ord[].
\end{equation*}

Now let $K$ be an arbitrary quadratic field, $\ord[]=\roi$, and $P$ be
a prime lattice of $\ord[]$.  There is a non-zero element $\alpha$ of
$P$.  Then $\alpha'\in\ord[]$, so $P$ contains $\alpha\alpha'$, a
rational integer.  Since $P$ is prime, the least positive rational
integer that it contains must be prime.  Suppose this is $p$.  then
\begin{equation*}
  P\divides p\ord[].
\end{equation*}
Conversely, suppose $p$ be a rational prime, and $P$ is a prime factor
of $p\ord[]$.  Then
\begin{equation*}
  \norm{P}\divides p^2.
\end{equation*}
If $\norm P=p^2$, is means $P$ is just $p\ord[]$.  If $\norm P=p$, then
$PP'=p\ord[]$, but possibly $P=P'$.
So there are three possibilities:
\begin{enumerate}
  \item
$p\ord[]$ is itself prime: then $p$ is \defn{inert}{} in $\ord[]$;
\item
$p\ord[]=PP'$, where $P\neq P'$; then $p$ \defn{split}{s} in $\ord[]$;
\item
$p\ord[]=P^2$; then $p$ \defnplain{ramifies}{}\index{ramify} in $\ord[]$.
\end{enumerate}

\section{May 20, 2008 (Tuesday)}

To compute which of the three possibilities actually happens, it is
convenient to let\index{$\mDelta$}
\begin{equation*}
  \mDelta=\Delta(\ord[])=
  \begin{vmatrix}
    1&1\\
\omega&\omega'
  \end{vmatrix}^2=
\begin{cases}
  d,&\text{ if }d\equiv1\pmod 4;\\
4d,&\text{ if }d\equiv 2\text{ or }3.
\end{cases}
\end{equation*}

\begin{theorem}
  \mbox{}
  \begin{enumerate}
    \item\label{item:inert}
If $p\ndivides\mDelta$, and $\mDelta\equiv x^2\pmod{4p}$ has no
solution, then $p$ is inert in $\ord[]$.
\item\label{item:splits}
If $p\ndivides\mDelta$, and $\mDelta\equiv s^2\pmod{4p}$, then $p$
splits in $\ord[]$, and 
\begin{equation*}
p\ord[]=\Bigl\langle p,\frac{s+\sqrt{\mDelta}}2\Bigr\rangle
\Bigl\langle p,\frac{s-\sqrt{\mDelta}}2\Bigr\rangle.
\end{equation*}
\item\label{item:ramifies}
If $p\divides\mDelta$, then $p$ ramifies in $\ord[]$, and
\begin{equation*}
  p\ord[]=
  \begin{cases}
    \Bigl\langle
    p,\displaystyle\frac{\mDelta+\sqrt{\mDelta}}2\Bigr\rangle^2,&\text{
    if $p$ is odd;}\\
\lat[2,\sqrt d]^2,&\text{ if }p=2\land d\equiv 2;\\
\lat[2,1+\sqrt d]^2,&\text{ if }p=2\land d\equiv 3.
  \end{cases}
\end{equation*}
  \end{enumerate}
\end{theorem}

\begin{proof}
  Suppose $p$ is not inert in $\ord[]$.  Then $p\ord[]$ has a proper
  prime factor $P$, of norm $p$, so that
  \begin{equation*}
    (\ord[]:P)=p.
  \end{equation*}
So there are just $p$ distinct congruence-classes \emph{modulo} $P$.
Moreover, they are represented by the elements of
$\{0,1,\dots,p-1\}$.  Indeed, if $0\leq i\leq j<p$, and $i\equiv
j\pmod P$, then $P\divides (j-i)\ord[]$, so $\norm
P\divides\norm{(j-i)\ord[]}$, that is,
\begin{equation*}
  p\divides(j-i)^2,
\end{equation*}
so $i=j$.  Therefore, in particular, there is a rational integer $r$
such that $0\leq r<p$ and
\begin{gather*}
  \frac{\mDelta+\sqrt{\mDelta}}2\equiv r\pmod P,\\
2r-\mDelta-\sqrt{\mDelta}\equiv0\pmod{2P},\\
2P\divides(2r-\mDelta-\sqrt{\mDelta})\ord[],\\
\norm{2P}\divides\norm{(2r-\mDelta-\sqrt{\mDelta})\ord[]},\\
4p\divides(2r-\mDelta)^2-\mDelta,\\
\mDelta\equiv(2r-\mDelta)^2\pmod{4p}.
\end{gather*}
This proves~\eqref{item:inert}.

Now suppose $\mDelta\equiv s^2\pmod{4p}$, and let
\begin{equation*}
  P=\Bigl\langle p,\frac{s+\sqrt{\mDelta}}2\Bigr\rangle.
\end{equation*}
To compute $\ord[P]$ by means of Theorem~\ref{thm:conductor}, we have
\begin{align*}
  x=\frac{s+\sqrt{\mDelta}}{2p}
&\implies 2px-s=\sqrt{\mDelta}\\
&\implies 4p^2x^2-4psx+s^2-\mDelta=0\\
&\implies px^2-sx+\frac{s^2-\mDelta}{4p}=0.
\end{align*}
If $p\ndivides\mDelta$, then $p\ndivides s$, and we can conclude
\begin{equation*}
  \ord[P]=\Bigl\langle 1,\frac{s+\sqrt{\mDelta}}2\Bigr\rangle=\ord[].
\end{equation*}
So $P$ belongs to $\ord[]$; and it has norm $p$, so $p\ord[]=PP'$ by
Lemma~\ref{lem:LL'}.  Finally, $P\neq P'$, since $P+P'$ contains $s$,
but $P$ does not.  Thus~\eqref{item:splits}.

Finally, to prove~\eqref{item:ramifies}, since each of the given
lattices is its own conjugate, it is enough to show that the lattices
belong to $\ord[]$.  For example, in case $p$ is odd, assuming
$p\divides\mDelta$, we have
\begin{align*}
  x=\frac{\mDelta+\sqrt{\mDelta}}{2p}
&\implies 2px-\mDelta=\sqrt{\mDelta}\\
&\implies 4p^2x^2-4p\mDelta x+\mDelta^2-\mDelta=0\\
&\implies px^2-\mDelta x+\frac{\mDelta^2-\mDelta}{4p}=0.
\end{align*}
We always have $\mDelta\equiv0$ or $1 \pmod4$, so
$4\divides\mDelta^2-\mDelta$; hence $4p\divides\mDelta^2-\mDelta$.
But $\mDelta^2-\mDelta=\mDelta(\mDelta-1)$, and $p\ndivides\mDelta-1$, but
also $p^2\ndivides\mDelta$, since $d$
is squarefree.  Therefore $\lat[p,(\mDelta+\sqrt{\mDelta})/2]$ does
belong to $\ord[]$.  The remaining cases are easier.
\end{proof}

For example, if $d=21$, then $\mDelta=21$, and the primes ramifying in
$\ord[]$ are just $3$ and $7$.


\printindex


%\layout


\bibliographystyle{plain}
\bibliography{../../../../TeX/references}


\end{document}

