%\documentclass[a4paper,twoside,draft]{article}
\documentclass[a4paper,twoside,reqno,12pt,draft]{amsart}
\usepackage[headings]{fullpage}
\usepackage{multicol}

%\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{showlabels}
\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{}
\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{\End}[1][\Lambda]{\operatorname{End}(#1)}  % Endomorphism-ring
\newcommand{\ord}[1][\Lambda]{\mathfrak O_{#1}}
\newcommand{\funit}[1][\Lambda]{\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{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 meets Tuesdays at
13.40 for two hours
and Fridays at 13.40 (originally 12.40) for one hour, and continues.
So these notes are unfinished.
%There are thirteen students registered to the course.

I typeset these notes after class, from memory and
from handwritten notes prepared before class.  I do some polishing
and slight 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 is \cite{MR568909}.  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. 

On Friday, March 21, I spent the class solving homework problems: the
first examination was the following Monday evening.

Class on Tuesday, April 8, was only one hour, because of a special
seminar that day (on teaching conic sections). 
\vfill
\begin{multicols}2
  \tableofcontents
\end{multicols}
\vfill
\newpage

\listoffigures
\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}
a_0&=[x], & \xi_0&=x-a_0;\\
a_1&=\left[\frac1{\xi_0}\right],& \xi_1&=\frac1{\xi_0}-a_1;\\
%&\vdots&&\dots\\
\intertext{and generally}
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*}
  [a_0]&=a_0,\\
[a_0;a_1]&=a_0+\cfrac1{a_1},\\
[a_0;a_1,a_2]&=a_0+\cfrac1{a_1+\cfrac1{a_2}},\\
\intertext{and so forth, so that}
[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*}
  \frac{p_0}{q_0}&=a_0,& p_0&=a_0,& q_0&=1;\\
\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;\\
\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*}
%\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}
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 $\Lambda$ is a lattice in $K$, let%
\index{$\End$}
\begin{equation*}
  \End=\{\xi\in\C\colon \xi\Lambda\included\Lambda\}.
\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 $\Lambda$.  That is, the
function $\xi\mapsto\alpha\xi$ is an endomorphism of $\Lambda$ if and
only if $\alpha\in\End$.
For example, if $\Lambda=\lat[1,\mi]$ in $\Q(\mi)$, then
$\End=\lat[1,\mi]$.  

But suppose $\Lambda=\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,
$\Lambda$ 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 $\Lambda$ be such
a lattice.  Then we can form the quotient group $\C/\Lambda$.
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_{\Lambda}$: the \defn{Weierstra\ss{} function}, given by
\begin{equation*}
  \wp(z)=\frac1{z^2}+
  \sum_{\zeta\in\Lambda\setminus\{0\}}\Bigl(\frac1{(z-\zeta)^2}
  -\frac1{\zeta^2}\Bigr).
\end{equation*}
This is \defn{doubly periodic}, with period $\Lambda$: that is,
\begin{equation*}
  \zeta\in\Lambda\Iff\wp(z+\zeta)=\wp(z)\text{ for all }z.
\end{equation*}
Hence $\wp$ is well-defined as a function on the torus $\C/\Lambda$.
There are $g_2$ and $g_3$ (depending on $\Lambda$) 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/\Lambda$ to
the elliptic curve.

An analytic endomorphism of $\C/\Lambda$ is a function $z\mapsto\alpha
z$, where $\alpha\in\C$, such that $\alpha\Lambda\included\Lambda$.
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{}\topic{Quadratic lattices}

We 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 $\Lambda$.  In particular then, $\alpha\neq0$ and
$\beta/\alpha\not\in\Q$. 
Every element $\alpha x+\beta y$ of $\Lambda$ 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{}\topic{Pell equation examples}

\begin{problem}
  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+5,&\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*}
  \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 $\Lambda$ 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 $\Lambda$, and we
write%
\index{$\disc{\Lambda}$, $\disc{\alpha,\beta}$}
\begin{equation*}
  \disc{\Lambda}=\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}
  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 the last lemma, 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 $\Lambda$ is a lattice of $K$, then the ring $\End$ is also called
the \defn{order}{} of $\Lambda$ 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 $\Lambda$ 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 $\Lambda$ 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\Lambda\included\Lambda$, that is, $n\gamma\in\ord$.  But
$\gamma=(1/n)n\gamma$. 
\end{proof}

\begin{theorem}
  $\ord=\lat[1,c\omega]$ for some positive 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\Lambda]=\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\Lambda\included\Lambda\Iff
  \xi\gamma\Lambda\included\gamma\Lambda$. 
\end{proof}

In looking for $\ord$, we may therefore assume that
$\Lambda=\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\oldsqrt{4a-1})/2a]$}\label{fig:lat-end-2}
\end{figure}

\begin{theorem}\label{thm:conductor}
  Suppose $\Lambda=\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}
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
$\Lambda=\lat[1,\omega]$, so that $\ord=\Lambda=\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 $\Lambda$, 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{x+\omega y}=3$ 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}
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
$\Lambda=\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 $\Lambda$.  We know one solution, namely $1+2\omega$.
Since $(2\omega)^2-2(2\omega)+4=0$, we have
$\ord=\lat[1,2\omega]=\Lambda$.  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}
  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+\gr y)(2x+y\gr')\\
&=\norm{2x+\gr y}
  \end{align*}
in $\Q(\sqrt 5)$.  Let $\Lambda=\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 the
previous theorem, we have
\begin{equation*}
  \begin{array}{c||c|c|c|c|c|c|c}
n    & 0 &1&2&3&4&5&6\\\hline
\gr^n&1  &\gr&1+\gr&1+2\gr&2+3\gr&3+5\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 $\Lambda$, 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}
(2x+y\gr)(2x+y\gr')=4,  
\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[dl](-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}
  \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
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
$\Lambda=\lat[2,\gr]$. 

\section{April 15, 2008 (Tuesday)}

If we convert a quadratic Diophantine equation to
the form $\norm{x\alpha+y\beta}=m$, where $\alpha,\beta\in K$, then we
can solve as in the examples above, 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\equiv4$ 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$, where $a,b>0$, 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}
  Assuming $\sqrt d=[a_0;a_1,a_2,\dots]$, let $p_n/q_n$ be the $n$th
  convergent, that is, $p_n/q_n=[a_0;a_1,\dots,a_n]$.  Suppose
  $a,b\in\Z$ and $1\leq b<p_{n+1}$.  Then
  \begin{equation*}
    \size{p_n-q_n\sqrt d}\leq{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}
  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 the lemma, 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}
%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
If $d\equiv2$ or $3\pmod 4$, then $a/b$ is a convergent of $\sqrt d$.
\item
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*}
    a^2-db^2=\pm1.
  \end{equation*}
  By the last theorem, 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$),
\begin{equation*}
  1<\frac{a+b\sqrt d}{2b}=\frac12\Bigl(\frac ab+\sqrt d\Bigr).
\end{equation*}
But we have
\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*}
  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}



\printindex

%\layout


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


\end{document}

