\documentclass[11pt]{article}

\usepackage{amsmath,amssymb,amsthm}

\usepackage{xcolor}

%\usepackage{systeme}

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


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

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

%\usepackage{graphicx}

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

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

%\allowdisplaybreaks

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

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

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

\parskip = 0.05in
\parindent = 0.0in

%\pagestyle{empty}

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

\centerline{Quadratic fields}
\bigskip

\begin{lem} (Gauss's lemma.) 
  Let $f\in \Z[x]$, and suppose that $f=gh$ for $g,h\in \Q[x]$.  Then there
  exists a nonzero $\lambda\in \Q$ such that $\lambda g$ and
  $\frac{1}{\lambda}h$ are in $\Z[x]$.  (Thus, a polynomial in a single variable
  with integer coefficients factors over~$\Q$ if and only if it factors over
  $\Z$.)
\end{lem}
\begin{proof}
 See our text, Lemma 1.7.
\end{proof}

Last time, we defined the \emph{algebraic integers} to be the set of complex
numbers that are integral over~$\Z$:
\[
  \mathfrak{O}:=\{\alpha\in \C: f(\alpha)=0 \text{ for some monic polynomial
  $f\in \Z[x]$}\}.
\]

\begin{cor}~\label{cor:02fri-int}
  Let~$\alpha$ be an algebraic number, i.e., a complex number that is algegraic
  over~$\Q$. Then $\alpha$ is an algebraic integer if and only if its minimal
  polynomial over $\Q$ has integer coefficients.
\end{cor}
\begin{proof}
  If the minimal polynomial of $\alpha$ has integer coefficients, then it
  follows immediately that $\alpha$ is an algebraic integer. So we now consider
  the converse.

  Recall that if $L/K$ is a field extension, then $\alpha\in L$, is
  \emph{algebraic} over $K$ if there exists a polynomial $f\in K[x]$ such
  that~$f(\alpha)=0$.  If $\alpha$ is algebraic, then
  $[K(\alpha)\mathbin{:}K]<\infty$ and, in fact, $K(\alpha)=K[\alpha]$.

  Let $\alpha\in \mathfrak{O}\subset \C$ be an algebraic integer, and let $f\in\Z[x]$ be a monic
  polynomial such that $f(\alpha)=0$.  It follows that $\alpha$ is algebraic over
  $\Q$.  Thus, it makes sense to talk about its minimal polynomial~$p\in \Q[x]$.
  We need to show the coefficients of~$p$ are integers.
  Since $f(\alpha)=0$, it must be that $f=qp$ for some $q\in\Q[x]$.  (Reminder: apply the
  division algorithm to write $f=qp+r$ where $q,r\in\Q[x]$ and $\deg(r)<\deg(p)$.
  Evaluating at $\alpha$ yields $r(\alpha)=0$.  The minimality condition in the
  definition of $p$ then forces $\deg(r)=0$, i.e., $r$ is a constant polynomial.
  Then $r(\alpha)=0$ says that $r=0$.  Thus, $f=qp$.)  

  By Gauss's lemma, there exists a nonzero $\lambda\in \Q$ such that
  $\lambda q$ and $\frac{1}{\lambda}p\in \Z[x]$ have integer coefficients. 
  Next, compare leading coefficients.
  Since the leading coefficients of~$f$ and $p$ are both~$1$ and $f=qp$, it
  follows that the leading coefficient of~$q$ is~$1$ also.
  Since $q$ is monic and $\lambda q\in \Z[x]$, it follows that $\lambda\in \Z$.
  Since $p$ is monic, and $\frac{1}{\lambda}p\in\Z[x]$, it follows that
  $\frac{1}{\lambda}\in \Z$.  Therefore, $\lambda=\pm 1$,  Then, since
  $\frac{1}{\lambda}p\in\Z[x]$, it follows that $p\in\Z[x]$, too, as required.
\end{proof}

In the previous lecture, we gave an ad hoc argument that $\mathfrak{O}\cap
\Q=\Z$.  We now obtain that result as a corollary of the result we just proved.
\begin{cor}
  $\mathfrak{O}\cap\Q=\Z$.
\end{cor}
\begin{proof}
  Certainly, $\Z\subseteq\mathfrak{O}\cap\Q$.  For the reverse inclusion, suppose
  that $a\in \mathfrak{O}\cap\Q$.  The minimal polynomial for $a$ over~$\Q$ is
  $x-a$.  By Corollary~\ref{cor:02fri-int}, it follows that $x-a\in \Z[x]$.  In
  particular, this means that $a\in \Z$.
\end{proof}
\bigskip

\textbf{Ring of integers in a number field.} Let~$K$ be a number field.  In
other words, $K$ is a finite field extension of $\Q$ inside of~$\C$.  Define the \emph{ring of
integers in $K$} to be the set of all algebraic integers in~$K$:
\[
  \mathfrak{O}_{K}:=\mathfrak{O}\cap K.
\]
We picture the situation like this:
\begin{center}
  \begin{tikzcd}
    K\arrow[r,dash] \arrow[d,dash]& \mathfrak{O}_K\arrow[d,dash]\\
    \Q\arrow[r,dash]& \Z.
  \end{tikzcd}
\end{center}

\begin{lem}
  With notation as above.  If $\alpha\in K$, then there exists an integer~$c$ such
  that $c\alpha\in \mathfrak{O}_{K}$.
\end{lem}
\begin{proof}
 Homework.
\end{proof}

\begin{thm} (Primitive element theorem (generalized).)  Let $K$ be a
  number field.  Then there exists $\theta\in \mathfrak{O}_{K}$ such that
  $K=\Q(\theta)=\Q[\theta]$.
\end{thm}
\begin{proof}
 Our text proves there exists $\alpha\in K$ such that $K=\Q(\alpha)$
 (cf.~Theorem~2.2).
 By the lemma, there exists $c\in \Z$ such that $c\alpha\in
 \mathfrak{O}_{K}$.  Let $\theta:=c\alpha$.  Then it is clear that
 $K=\Q(\alpha)=\Q(\theta)$.  However, since $\theta$ is algebraic over $\Q$, it
 follows from previous work that $\Q(\theta)=\Q[\theta]$.
\end{proof}
\bigskip

\textbf{Quadratic fields.}  Suppose that $K$ is a extension of $\Q$ of
degree~$2$, i.e., $[K\mathbin{:}\Q]=2$.   By the primitive element theorem,
there exists $\theta\in \mathfrak{O}_{K}$ such that $K=\Q(\theta)=\Q[\theta]$.
Since $[K\mathbin{:}\Q]=2$, it follows that the minimal polynomial for $\theta$
has the form $p=x^2+mx+n$ for some $m,n\in\Z$.  Therefore, 
\[
  \theta = \frac{-m\pm\sqrt{m^2-4n}}{2}.
\]
Write
\[
  m^2-4n=r^2d
\]
where $r,d\in\Z$ and~$d$ is square-free.  Since~$\theta\not\in\Q$, we have $d\neq0,1$. Then
\[
  \theta=\frac{-m\pm r\sqrt{d}}{2}
\]
and
\[
  K=\Q(\theta)=\Q(\sqrt{d})=\Q[\sqrt{d}] = \Span_{\Q}\{1,\sqrt{d}\}.
\]

Our goal is to find $\mathfrak{O}_{K}$.  Let $\alpha\in \Q[\sqrt{d}]$.  Then
$\alpha=s+t\sqrt{d}$ for some~$s,t\in\Q$, from which we can see
\[
  \alpha=\frac{a+b\sqrt{d}}{c}
\]
for some $a,b,c\in \Z$ sharing no common prime factors.  If $b=0$,
then $\alpha=\frac{a}{c}\in\Q$.  So if $\alpha$ is also in $\mathfrak{O}_{K}$, we
have $\alpha\in \Q\cap \mathfrak{O}_{K}=\Z$, and~$c=1$. Now suppose that
$b\neq0$.  The minimal polynomial for $\alpha$ over~$\Q$ is
\[
  p(x) = \left(x-\frac{a+b\sqrt{d}}{c}\right)\left(x-\frac{a-b\sqrt{d}}{c}\right)
  =x^2-\frac{2a}{c}+\frac{a^2-b^2d}{c^2}\in\Q[x].
\]
Then $\alpha\in \mathfrak{O}_{K}$ if and only if
\begin{equation}~\label{eqn:02fri-div}
  \frac{2a}{c}\in\Z\quad\text{and}\quad \frac{a^2-b^2d}{c^2}\in\Z.
\end{equation}
Suppose $\alpha\in\mathfrak{O}_{K}$.  If $q\neq 2$ is a prime integer and $q|c$,
then $q|(2a)$ implies that $q|a$ and $q^2|a^2$.  Since~$q|c$ and
$c^2|(a^2-b2d)$, it follows that $q^2|(a^2-b^2d)$, and hence $q^2|(b^2d)$.
Since~$d$ is square-free, $q|b$.  We have shown that $q$ is a common factor
of~$a,b$ and~$c$,  However, $a,b$ and $c$ share no prime factors.  So at this
point, we can conclude that $c$ must be a power of~$2$.  If $4|c$, then $c|(2a)$
would imply that $2|a$, and repeating the above argument, we would get that
$a,b$ and $c$ all share a factor of~$2$, which is not the case.  It follows that
$c=1$ or~$c=2$.  

If $c=1$, then
\[
  \alpha=a+b\sqrt{d}\in\Z[\sqrt{d}].
\]
Now consider the case where~$c=2$. In that case, we need that $4|(a^2-b^2d)$.
From this, if $a$ or $b$ is even, then we may conclude that both~$a$ and~$b$
are even (since~$d$ is square-free).  Since~$a,b$ and~$c$ share no factors, it
must be that both~$a$ and $b$ are odd.  Hence,~$a^2=b^2=1\bmod 4$.  We have
\[
  a^2-b^2d=1-d=0\bmod 4.
\]
So if $c=2$, then $d=1\bmod 4$.

Therefore, if $d\neq 1\bmod 4$, we must have $c=1$, in which
case~\eqref{eqn:02fri-div} says that~$\alpha\in\mathfrak{O}_{K}$.
So if $d\neq1\bmod 4$, then $\mathfrak{O}_{K}=\Z[\sqrt{d}]$.
If~$d=1\bmod 4$, then~\eqref{eqn:02fri-div} holds if and only if~$c=1$ or if $c=2$ and
both~$a$ and~$b$ are odd.  We then claim that
$\mathfrak{O}_{K}=\Z[\frac{1+\sqrt{d}}{2}]$.  We know
that~$\frac{1+\sqrt{d}}{2}\in\mathfrak{O}_{K}$ and that~$\mathfrak{O}_{K}$ is a
ring.  Hence, $\Z[\frac{1+\sqrt{d}}{2}]\subseteq\mathfrak{O}_{K}$.  For the
reverse inclusion, suppose that~$\alpha\in\Z[\sqrt{d}]$.  We have seen that
either $\alpha=a+b\sqrt{d}$ for some $a,b\in\Z$, in which case
\[
  \alpha=a+b\sqrt{d}
  = (a-b)+2b\left(\frac{1+\sqrt{d}}{2}\right)\in
  \Z[\textstyle\frac{1+\sqrt{d}}{2}],
\]
or $\alpha=\frac{a+b\sqrt{d}}{2}$ where $a$ and $b$ are both odd, in which case,
\[
  \alpha=\frac{a+b\sqrt{d}}{2}=
  \left(\frac{a-b}{2}\right)+b\left(\frac{1+\sqrt{d}}{2}\right)\in\Z[\textstyle
  \frac{1+\sqrt{d}}{2}].
\]
We sum up our discussion with the theorem below. 

\begin{thm}
  Let $K$ be a field extension of~$\Q$ with~$[K\mathbin{:}\Q]=2$.  Then
  $K=\Q(\sqrt{d})$ where $d\neq0,1$ is a square-free integer.  Its ring of
  integers is
  \[
    \mathfrak{O}_{K}=
    \begin{cases}
      \Z[\sqrt{d}]&\text{if~$d\neq1\bmod 4$}\\[5pt]
      \Z[\frac{1+\sqrt{d}}{2}]&\text{if~$d=1\bmod 4$}.
    \end{cases}
  \]
  We have $\Z[\sqrt{d}]=\Span_{\Z}\{1,\sqrt{d}\}$, and
  $\Z[\frac{1+\sqrt{d}}{2}]=\Span_{\Z}\{1,\frac{1+\sqrt{d}}{2}\}$.
\end{thm}
\end{document}
