\documentclass[numbers=enddot,12pt,final,onecolumn,notitlepage]{scrartcl}%
\usepackage[headsepline,footsepline,manualmark]{scrlayer-scrpage}
\usepackage[all,cmtip]{xy}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{framed}
\usepackage{comment}
\usepackage{color}
\usepackage[breaklinks=True]{hyperref}
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\usepackage{needspace}
\usepackage{tabls}
\usepackage{tikz}
\usepackage{bbding}
%TCIDATA{OutputFilter=latex2.dll}
%TCIDATA{Version=5.50.0.2960}
%TCIDATA{LastRevised=Saturday, February 11, 2023 11:37:28}
%TCIDATA{SuppressPackageManagement}
%TCIDATA{<META NAME="GraphicsSave" CONTENT="32">}
%TCIDATA{<META NAME="SaveForMode" CONTENT="1">}
%TCIDATA{BibliographyScheme=Manual}
%TCIDATA{Language=American English}
%BeginMSIPreambleData
\providecommand{\U}[1]{\protect\rule{.1in}{.1in}}
%EndMSIPreambleData
\usetikzlibrary{arrows.meta}
\usetikzlibrary{chains}
\usetikzlibrary{shapes}
\usetikzlibrary{decorations.pathmorphing}
\newcounter{exer}
\newcounter{exera}
\theoremstyle{definition}
\newtheorem{theo}{Theorem}[subsection]
\newenvironment{theorem}[1][]
{\begin{theo}[#1]\begin{leftbar}}
{\end{leftbar}\end{theo}}
\newtheorem{lem}[theo]{Lemma}
\newenvironment{lemma}[1][]
{\begin{lem}[#1]\begin{leftbar}}
{\end{leftbar}\end{lem}}
\newtheorem{prop}[theo]{Proposition}
\newenvironment{proposition}[1][]
{\begin{prop}[#1]\begin{leftbar}}
{\end{leftbar}\end{prop}}
\newtheorem{defi}[theo]{Definition}
\newenvironment{definition}[1][]
{\begin{defi}[#1]\begin{leftbar}}
{\end{leftbar}\end{defi}}
\newtheorem{remk}[theo]{Remark}
\newenvironment{remark}[1][]
{\begin{remk}[#1]\begin{leftbar}}
{\end{leftbar}\end{remk}}
\newtheorem{coro}[theo]{Corollary}
\newenvironment{corollary}[1][]
{\begin{coro}[#1]\begin{leftbar}}
{\end{leftbar}\end{coro}}
\newtheorem{conv}[theo]{Convention}
\newenvironment{convention}[1][]
{\begin{conv}[#1]\begin{leftbar}}
{\end{leftbar}\end{conv}}
\newtheorem{quest}[theo]{Question}
\newenvironment{question}[1][]
{\begin{quest}[#1]\begin{leftbar}}
{\end{leftbar}\end{quest}}
\newtheorem{warn}[theo]{Warning}
\newenvironment{warning}[1][]
{\begin{warn}[#1]\begin{leftbar}}
{\end{leftbar}\end{warn}}
\newtheorem{conj}[theo]{Conjecture}
\newenvironment{conjecture}[1][]
{\begin{conj}[#1]\begin{leftbar}}
{\end{leftbar}\end{conj}}
\newtheorem{exam}[theo]{Example}
\newenvironment{example}[1][]
{\begin{exam}[#1]\begin{leftbar}}
{\end{leftbar}\end{exam}}
\newtheorem{exmp}[exer]{Exercise}
\newenvironment{exercise}[1][]
{\begin{exmp}[#1]\begin{leftbar}}
{\end{leftbar}\end{exmp}}
\newenvironment{statement}{\begin{quote}}{\end{quote}}
\newenvironment{fineprint}{\begin{small}}{\end{small}}
\iffalse
\newenvironment{proof}[1][Proof]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\newenvironment{convention}[1][Convention]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\newenvironment{question}[1][Question]{\noindent\textbf{#1.} }{\ \rule{0.5em}{0.5em}}
\fi
\let\sumnonlimits\sum
\let\prodnonlimits\prod
\let\cupnonlimits\bigcup
\let\capnonlimits\bigcap
\renewcommand{\sum}{\sumnonlimits\limits}
\renewcommand{\prod}{\prodnonlimits\limits}
\renewcommand{\bigcup}{\cupnonlimits\limits}
\renewcommand{\bigcap}{\capnonlimits\limits}
\newcommand\arxiv[1]{\href{http://www.arxiv.org/abs/#1}{\texttt{arXiv:#1}}}
\setlength\tablinesep{3pt}
\setlength\arraylinesep{3pt}
\setlength\extrarulesep{3pt}
\setlength\textheight{22.5cm}
\setlength\textwidth{14.8cm}
\newenvironment{verlong}{}{}
\newenvironment{vershort}{}{}
\newenvironment{noncompile}{}{}
\excludecomment{verlong}
\includecomment{vershort}
\excludecomment{noncompile}
\newcommand{\defn}[1]{{\color{darkred}\emph{#1}}}
\newcommand{\CC}{\mathbb{C}}
\newcommand{\RR}{\mathbb{R}}
\newcommand{\QQ}{\mathbb{Q}}
\newcommand{\NN}{\mathbb{N}}
\newcommand{\ZZ}{\mathbb{Z}}
\newcommand{\KK}{\mathbb{K}}
\newcommand{\set}[1]{\left\{ #1 \right\}}
\newcommand{\abs}[1]{\left| #1 \right|}
\newcommand{\tup}[1]{\left( #1 \right)}
\newcommand{\ive}[1]{\left[ #1 \right]}
\newcommand{\floor}[1]{\left\lfloor #1 \right\rfloor}
\newcommand{\arinj}{\ar@{_{(}->}}
\newcommand{\arinjrev}{\ar@{^{(}->}}
\newcommand{\arsurj}{\ar@{->>}}
\newcommand{\arelem}{\ar@{|->}}
\newcommand{\arback}{\ar@{<-}}
\newcommand{\are}{\ar@{-}}
\newcommand{\arebi}[1][]{\ar@{<-}@/_/[#1] \ar@/^/[#1]}
\newcommand{\of}{\text{ of }}
\definecolor{darkgreen}{rgb}{0,.5,0}
\newtheoremstyle{plainsl}
{8pt plus 2pt minus 4pt}
{8pt plus 2pt minus 4pt}
{\slshape}
{0pt}
{\bfseries}
{.}
{5pt plus 1pt minus 1pt}
{}
\theoremstyle{plainsl}
\ihead{Lecture 14, version \today}
\ohead{page \thepage}
\cfoot{}
\begin{document}
\section*{Math 332 Winter 2023, Lecture 14: Rings}

\textbf{website:}
\texttt{\href{https://www.cip.ifi.lmu.de/~grinberg/t/23wa}{\texttt{https://www.cip.ifi.lmu.de/\symbol{126}%
grinberg/t/23wa}}}

\section{Rings and ideals (cont'd)}

\setcounter{subsection}{11}

\subsection{The Chinese Remainder Theorem (cont'd)}

\setcounter{subsubsection}{3}

\setcounter{theo}{3}

\subsubsection{The story so far}

Let us recapitulate the results of Lecture 13.

We began by observing that
\[
\mathbb{Z}/\left(  nm\right)  \cong\mathbb{Z}/n\times\mathbb{Z}/m
\]
(by our convention, the right hand side means $\left(  \mathbb{Z}/n\right)
\times\left(  \mathbb{Z}/m\right)  $) whenever $n$ and $m$ are two coprime integers.

We generalized this by replacing $\mathbb{Z}$ by an arbitrary commutative ring
and replacing $n$ and $m$ by two comaximal ideals.

Two ideals $I$ and $J$ of a ring $R$ are said to be \textbf{comaximal} if
$I+J=R$. If $I=n\mathbb{Z}$ and $J=m\mathbb{Z}$ for two integers $n$ and $m$,
then this condition is equivalent to $n$ and $m$ being coprime. (See
Proposition 1.11.3 in Lecture 12 for a dictionary between ideal arithmetic for
principal ideals of $\mathbb{Z}$ and elementary number theory for integers.)

We proved the Chinese Remainder Theorem for two ideals: If $I$ and $J$ are two
comaximal ideals of a commutative ring $R$, then $I\cap J=IJ$ and there is a
ring isomorphism%
\begin{align*}
R/\left(  IJ\right)   &  \rightarrow R/I\times R/J,\\
\overline{r}  &  \mapsto\left(  \overline{r},\overline{r}\right)  .
\end{align*}


Today, we will extend this result to $k$ mutually comaximal ideals rather than
just two.

\subsubsection{Interlude: Multiplying comaximal ideals}

First, we need some auxiliary results.

Recall the classical fact from elementary number theory saying that if $i,j,k$
are three integers such that each of $i$ and $j$ is coprime to $k$ (that is,
such that $\gcd\left(  i,k\right)  =1$ and $\gcd\left(  j,k\right)  =1$), then
$ij$ is also coprime to $k$ (that is, $\gcd\left(  ij,k\right)  =1$).

More generally, for any three integers $i,j,k$, we have%
\[
\gcd\left(  ij,k\right)  \mid\gcd\left(  i,k\right)  \gcd\left(  j,k\right)
.
\]


These facts can be generalized to arbitrary ideals of any ring:

\begin{proposition}
\label{prop.comax.prod2}Let $I$, $J$ and $K$ be three ideals of a ring $R$. Then:

\textbf{(a)} We have $\left(  I+K\right)  \left(  J+K\right)  \subseteq IJ+K$.

\textbf{(b)} If $I+K=R$ and $J+K=R$, then $IJ+K=R$.
\end{proposition}

\begin{proof}
The sets $I+K$, $J+K$ and $IJ+K$ are ideals of $R$ (by Proposition 1.11.2
\textbf{(a)} in Lecture 12), and thus are closed under finite sums. \medskip

\textbf{(a)} The ideal $\left(  I+K\right)  \left(  J+K\right)  $ is defined
as the set of all finite sums of $\left(  I+K,\ J+K\right)  $-products. Thus,
in order to prove that it is a subset of $IJ+K$, it suffices to show that any
$\left(  I+K,\ J+K\right)  $-product belongs to $IJ+K$ (because $IJ+K$ is
closed under finite sums, and thus any sum of elements of $IJ+K$ will again
lie in $IJ+K$).

An $\left(  I+K,\ J+K\right)  $-product is an element of the form $xy$, where
$x\in I+K$ and $y\in J+K$. So we must show that%
\[
xy\in IJ+K\ \ \ \ \ \ \ \ \ \ \text{for any }x\in I+K\text{ and }y\in J+K.
\]


To prove this, we let $x\in I+K$ and $y\in J+K$. Thus, $x=i+a$ for some $i\in
I$ and some $a\in K$. Likewise, $y=j+b$ for some $j\in J$ and $b\in K$.
Consider these $i,a,j,b$. Multiplying the equalities $x=i+a$ and $y=j+b$, we
obtain%
\begin{align*}
xy  &  =\left(  i+a\right)  \left(  j+b\right)  =\underbrace{ij}%
_{\substack{\in IJ\\\text{(since }i\in I\\\text{and }j\in J\text{)}%
}}+\underbrace{ib}_{\substack{\in K\\\text{(since }b\in K\\\text{and since
}K\\\text{is an ideal)}}}+\underbrace{aj}_{\substack{\in K\\\text{(since }a\in
K\\\text{and since }K\\\text{is an ideal)}}}+\underbrace{ab}_{\substack{\in
K\\\text{(since }b\in K\\\text{and since }K\\\text{is an ideal)}}}\\
&  \in IJ+\underbrace{K+K+K}_{\substack{\subseteq K\\\text{(since }K\text{ is
closed under finite sums)}}}\subseteq IJ+K,
\end{align*}
as desired. This completes the proof of part \textbf{(a)} as explained above.
\medskip

\textbf{(b)} Assume that $I+K=R$ and $J+K=R$. Then, $\left(  I+K\right)
\left(  J+K\right)  =RR$. However, $RR=R$ (since each $r\in R$ satisfies
$r=\underbrace{1}_{\in R}\cdot\underbrace{r}_{\in R}\in RR$). Thus, $\left(
I+K\right)  \left(  J+K\right)  =RR=R$.

However, Proposition \ref{prop.comax.prod2} \textbf{(a)} yields that $\left(
I+K\right)  \left(  J+K\right)  \subseteq IJ+K$. In view of $\left(
I+K\right)  \left(  J+K\right)  =R$, this can be rewritten as $R\subseteq
IJ+K$. Since $IJ+K$ is a subset of $R$, we thus conclude that $IJ+K=R$. Thus,
Proposition \ref{prop.comax.prod2} \textbf{(b)} is proved.
\end{proof}

We can extend Proposition \ref{prop.comax.prod2} \textbf{(b)} to products of
$k$ ideals:

\begin{proposition}
\label{prop.comax.prodn}Let $I_{1},I_{2},\ldots,I_{k}$ be $k$ ideals of a ring
$R$. Let $K$ be a further ideal of $R$. Assume that%
\[
I_{i}+K=R\ \ \ \ \ \ \ \ \ \ \text{for each }i\in\left\{  1,2,\ldots
,k\right\}  .
\]
Then, $I_{1}I_{2}\cdots I_{k}+K=R$.
\end{proposition}

\begin{proof}
Induct on $k$. The base case ($k=0$) is an exercise in triviality (an empty
product of ideals of $R$ is $R$ by definition, and we have $R+K=R$). The
induction step uses Proposition \ref{prop.comax.prod2} \textbf{(b)} in a
straightforward way ($I_{1}I_{2}\cdots I_{k}=\left(  I_{1}I_{2}\cdots
I_{k-1}\right)  I_{k}$). See \S 2.12.4 in the text for more details.
\end{proof}

\subsubsection{The Chinese Remainder Theorem for $k$ ideals}

Let us now define the proper condition for the Chinese Remainder Theorem for
$k$ ideals:

\begin{definition}
Let $I_{1},I_{2},\ldots,I_{k}$ be $k$ ideals of a ring $R$. We say that these
$k$ ideals $I_{1},I_{2},\ldots,I_{k}$ are \textbf{mutually comaximal} if
$I_{i}+I_{j}=R$ holds for all $i<j$.
\end{definition}

In other words, $k$ ideals $I_{1},I_{2},\ldots,I_{k}$ are mutually comaximal
if $I_{i}$ and $I_{j}$ are comaximal for every $i<j$. When $k>2$, this
requirement is \textbf{much stronger} than requiring $I_{1}+I_{2}+\cdots
+I_{k}=R$.

For instance, if $n_{1},n_{2},\ldots,n_{k}$ are $k$ arbitrary integers, then
the $k$ principal ideals $n_{1}\mathbb{Z},\ n_{2}\mathbb{Z},\ \ldots
,\ n_{k}\mathbb{Z}$ are mutually comaximal if and only if $\gcd\left(
n_{i},n_{j}\right)  =1$ for all $i<j$. This is a \textbf{much stronger}
condition than $\gcd\left(  n_{1},n_{2},\ldots,n_{k}\right)  =1$. (For a
concrete example, $6,10,15$ are not mutually coprime -- even worse, no two of
them are coprime! -- but they satisfy $\gcd\left(  6,10,15\right)  =1$.)

This being said, we can state a generalization of the Chinese Remainder
Theorem to $k$ ideals:

\begin{theorem}
[The Chinese Remainder Theorem for $k$ ideals]\label{thm.CRT-k-ids}Let
$I_{1},I_{2},\ldots,I_{k}$ be $k$ mutually comaximal ideals of a commutative
ring $R$. Then:

\textbf{(a)} We have%
\[
I_{1}\cap I_{2}\cap\cdots\cap I_{k}=I_{1}I_{2}\cdots I_{k}.
\]


\textbf{(b)} We have%
\[
R/\left(  I_{1}I_{2}\cdots I_{k}\right)  \cong R/I_{1}\times R/I_{2}%
\times\cdots\times R/I_{k}.
\]


\textbf{(c)} More concretely, there is a ring isomorphism%
\begin{align*}
R/\left(  I_{1}I_{2}\cdots I_{k}\right)   &  \rightarrow R/I_{1}\times
R/I_{2}\times\cdots\times R/I_{k},\\
\overline{r}  &  \mapsto\left(  \overline{r},\overline{r},\ldots,\overline
{r}\right)  .
\end{align*}

\end{theorem}

\begin{proof}
Induct on $k$. The induction step uses

\begin{itemize}
\item Proposition \ref{prop.comax.prodn} to argue that $I_{1}I_{2}\cdots
I_{k-1}$ is comaximal to $I_{k}$;

\item the Chinese Remainder Theorem for two ideals (Theorem 1.12.3 in Lecture 13);

\item the pretty simple fact that if three rings $A,B,C$ satisfy $A\cong B$,
then $A\times C\cong B\times C$ (and, to be more concrete: if $f:A\rightarrow
B$ is a ring isomorphism, then there is a ring isomorphism $A\times
C\rightarrow B\times C$ that sends each pair $\left(  a,c\right)  $ to
$\left(  f\left(  a\right)  ,c\right)  $).
\end{itemize}

See \S 2.12.5 in the text for more details (although stated in a slightly more
general context).
\end{proof}

\subsubsection{Applying to integers again}

Applying Theorem \ref{thm.CRT-k-ids} to principal ideals of $R=\mathbb{Z}$, we
obtain the following:

\begin{theorem}
[The Chinese Remainder Theorem for $k$ integers]\label{thm.CRT-k-ints}Let
$n_{1},n_{2},\ldots,n_{k}$ be $k$ mutually coprime integers (i.e., any $k$
integers satisfying $\gcd\left(  n_{i},n_{j}\right)  =1$ for all $i<j$). Then,%
\[
\mathbb{Z}/\left(  n_{1}n_{2}\cdots n_{k}\right)  \cong\mathbb{Z}/n_{1}%
\times\mathbb{Z}/n_{2}\times\cdots\times\mathbb{Z}/n_{k}.
\]
More concretely, there is a ring isomorphism%
\begin{align*}
\mathbb{Z}/\left(  n_{1}n_{2}\cdots n_{k}\right)   &  \rightarrow
\mathbb{Z}/n_{1}\times\mathbb{Z}/n_{2}\times\cdots\times\mathbb{Z}/n_{k},\\
\overline{r}  &  \mapsto\left(  \overline{r},\overline{r},\ldots,\overline
{r}\right)  .
\end{align*}

\end{theorem}

\begin{proof}
Since the integers $n_{1},n_{2},\ldots,n_{k}$ are mutually coprime, the
corresponding principal ideals $n_{1}\mathbb{Z},\ n_{2}\mathbb{Z}%
,\ \ldots,\ n_{k}\mathbb{Z}$ are mutually comaximal (by Proposition 1.11.3
\textbf{(c)} in Lecture 12). Hence, we can apply Theorem \ref{thm.CRT-k-ids}
to $R=\mathbb{Z}$ and $I_{i}=n_{i}\mathbb{Z}$. Specifically, parts
\textbf{(b)} and \textbf{(c)} of this theorem yield the claims of Theorem
\ref{thm.CRT-k-ints}. (Part \textbf{(a)} of Theorem \ref{thm.CRT-k-ids} yields
that $\operatorname{lcm}\left(  n_{1},n_{2},\ldots,n_{k}\right)  =\left\vert
n_{1}n_{2}\cdots n_{k}\right\vert $, which is also nice.)
\end{proof}

\begin{corollary}
\label{cor.CRT-primepows}Let $n$ be a positive integer with prime
factorization $n=p_{1}^{a_{1}}p_{2}^{a_{2}}\cdots p_{k}^{a_{k}}$, where
$p_{1},p_{2},\ldots,p_{k}$ are distinct primes, and where $a_{1},a_{2}%
,\ldots,a_{k}$ are nonnegative integers. Then,%
\[
\mathbb{Z}/n\cong\mathbb{Z}/p_{1}^{a_{1}}\times\mathbb{Z}/p_{2}^{a_{2}}%
\times\cdots\times\mathbb{Z}/p_{k}^{a_{k}}.
\]
More concretely, there is a ring isomorphism%
\begin{align*}
\mathbb{Z}/n  &  \rightarrow\mathbb{Z}/p_{1}^{a_{1}}\times\mathbb{Z}%
/p_{2}^{a_{2}}\times\cdots\times\mathbb{Z}/p_{k}^{a_{k}},\\
\overline{r}  &  \mapsto\left(  \overline{r},\overline{r},\ldots,\overline
{r}\right)  .
\end{align*}

\end{corollary}

For instance, the prime factorization of $72$ is $72=2^{3}\cdot3^{2}$, so that
Corollary \ref{cor.CRT-primepows} yields
\[
\mathbb{Z}/72\cong\mathbb{Z}/2^{3}\times\mathbb{Z}/3^{2}%
\ \ \ \ \ \ \ \ \ \ \left(  \text{as rings}\right)  .
\]
This cannot be broken up any further: Neither of the rings $\mathbb{Z}/2^{3}$
and $\mathbb{Z}/3^{2}$ is isomorphic to a direct product. (In particular,
$\mathbb{Z}/3^{2}$ is not $\left(  \mathbb{Z}/3\right)  \times\left(
\mathbb{Z}/3\right)  $, since $3$ and $3$ are not coprime.)

\begin{proof}
[Proof of Corollary \ref{cor.CRT-primepows}.]Apply Theorem
\ref{thm.CRT-k-ints} to $n_{j}=p_{j}^{a_{j}}$ (since powers of distinct primes
are coprime).
\end{proof}

\bigskip

Corollary \ref{cor.CRT-primepows} allows us to break rings of the form
$\mathbb{Z}/n$ down into simpler rings (as long as $n$ is not itself a prime
power). This has several applications:

\begin{itemize}
\item Counting squares (or, more generally, solutions to polynomial equations)
in $\mathbb{Z}/n$.

Exercise 7 on homework set \#0 asked, for a given integer $n>0$, how many of
the numbers $0,1,\ldots,n-1$ appear as remainders of a perfect square divided
by $n$. This is equivalent to asking for the number of squares in the ring
$\mathbb{Z}/n$. Here, a \textbf{square} in a ring $R$ means an element of the
form $r^{2}$ with $r\in R$. For instance, if $n=5$, then there are $3$ squares
in $\mathbb{Z}/n$, namely $\overline{0}$, $\overline{1}$ and $\overline{4}$.
Can we answer this question for general $n$, without having to count the
squares in $\mathbb{Z}/n$ one by one?

It is easy to see that a square in a direct product $A\times B$ of two rings
is the same thing as a pair $\left(  a,b\right)  $ consisting of a square
$a\in A$ and a square $b\in B$. Thus,%
\[
\left(  \text{\# of squares in }A\times B\right)  =\left(  \text{\# of squares
in }A\right)  \cdot\left(  \text{\# of squares in }B\right)  .
\]


Also, isomorphic rings have the same \# of squares. Thus, if $n$ has the prime
factorization $n=p_{1}^{a_{1}}p_{2}^{a_{2}}\cdots p_{k}^{a_{k}}$, then the
isomorphism
\[
\mathbb{Z}/n\cong\mathbb{Z}/p_{1}^{a_{1}}\times\mathbb{Z}/p_{2}^{a_{2}}%
\times\cdots\times\mathbb{Z}/p_{k}^{a_{k}}%
\]
in Corollary \ref{cor.CRT-primepows} entails%
\begin{align}
&  \left(  \text{\# of squares in }\mathbb{Z}/n\right) \nonumber\\
&  =\left(  \text{\# of squares in }\mathbb{Z}/p_{1}^{a_{1}}\times
\mathbb{Z}/p_{2}^{a_{2}}\times\cdots\times\mathbb{Z}/p_{k}^{a_{k}}\right)
\nonumber\\
&  =\prod_{i=1}^{k}\left(  \text{\# of squares in }\mathbb{Z}/p_{i}^{a_{i}%
}\right)  . \label{eq.count-squares.crt}%
\end{align}
Hence, it remains to compute the \# of squares in $\mathbb{Z}/p^{a}$ for any
prime $p$ and any positive integer $a$.

A good first step is counting the squares in $\mathbb{Z}/p$ for any prime $p$.
Their number turns out to be
\[%
\begin{cases}
2, & \text{if }p=2;\\
\dfrac{p+1}{2}, & \text{if }p\neq2.
\end{cases}
\]
This is not hard to show by observing that each square $x$ in $\mathbb{Z}/p$
other than $\overline{0}$ is taken twice (i.e., there are exactly two elements
$y\in\mathbb{Z}/p$ satisfying $y^{2}=x$), whereas the square $\overline{0}$ is
taken only once. (Exception: if $p=2$, then the square $\overline{1}$ is also
taken only once.)\footnote{See
\href{https://www.cip.ifi.lmu.de/~grinberg/t/19s/hw6s.pdf}{the solution to
Exercise 5 on homework set \#6 of my Spring 2019 Math 4281 class} for a
detailed version of this proof.}

The next step is counting squares in $\mathbb{Z}/p^{2}$, where $p$ is again a
prime. Their number turns out to be%
\[%
\begin{cases}
2, & \text{if }p=2;\\
\dfrac{p^{2}-p}{2}+1, & \text{if }p\neq2.
\end{cases}
\]
This is again not hard to prove\footnote{See
\href{https://www.cip.ifi.lmu.de/~grinberg/t/21w/hw2s.pdf}{the solution to
Exercise 4 on homework set \#2 of my Winter 2021 Math 533 class} for a proof.}.

Now you can probably trust me that the analogous problem is solvable for
$\mathbb{Z}/p^{a}$ when $a$ is an arbitrary positive answer. Unfortunately,
this solution is painful and quite tricky, but still doable. See
\cite{Stangl96} for one way to find and prove a formula (albeit using
primitive roots, which we have not seen yet in this course, but which can be
avoided with some more careful counting). Alas, the formula is rather ugly:
For any prime $p$ and any integer $a\geq1$, it says that the number of squares
in $\mathbb{Z}/p^{a}$ is%
\[%
\begin{cases}
\dfrac{p^{a+1}+p+2}{2\left(  p+1\right)  }, & \text{if }p\neq2\text{ and if
}a\text{ is even};\\
\dfrac{p^{a+1}+2p+1}{2\left(  p+1\right)  }, & \text{if }p\neq2\text{ and if
}a\text{ is odd};\\
\dfrac{2^{a-1}+4}{3}, & \text{if }p=2\text{ and if }a\text{ is even};\\
\dfrac{2^{a-1}+5}{3}, & \text{if }p=2\text{ and if }a\text{ is odd}.
\end{cases}
\]
\footnote{Don't be surprised about the denominators in the fractions; those
are obtained by summing geometric sequences.} Plugging this into
(\ref{eq.count-squares.crt}), we obtain a formula for the \# of squares in
$\mathbb{Z}/n$.

\item What is an integer $a$ that leaves the remainder $3$ when divided by
$5$, the remainder $2$ when divided by $6$ and the remainder $9$ when divided
by $23$ ?

This is just asking for an integer $a$ that satisfies $\overline{a}%
=\overline{3}$ in $\mathbb{Z}/5$, satisfies $\overline{a}=\overline{2}$ in
$\mathbb{Z}/6$ and satisfies $\overline{a}=\overline{9}$ in $\mathbb{Z}/23$.
In other words, this is asking for an integer $a$ whose image under the ring
morphism%
\begin{align*}
\mathbb{Z}  &  \rightarrow\left(  \mathbb{Z}/5\right)  \times\left(
\mathbb{Z}/6\right)  \times\left(  \mathbb{Z}/23\right)  ,\\
r  &  \mapsto\left(  \overline{r},\overline{r},\overline{r}\right)
\end{align*}
is the triple $\left(  \overline{3},\overline{2},\overline{9}\right)  $.

Since the integers $5,6,23$ are mutually coprime, the Chinese Remainder
Theorem (Theorem \ref{thm.CRT-k-ints}) shows that there is a ring isomorphism%
\begin{align*}
\mathbb{Z}/\left(  5\cdot6\cdot23\right)   &  \rightarrow\left(
\mathbb{Z}/5\right)  \times\left(  \mathbb{Z}/6\right)  \times\left(
\mathbb{Z}/23\right)  ,\\
\overline{r}  &  \mapsto\left(  \overline{r},\overline{r},\overline{r}\right)
.
\end{align*}
By tracking our way through the proof of this theorem, we can obtain an
algorithm for constructing the inverse of this
isomorphism\footnote{Specifically, we recall that Theorem \ref{thm.CRT-k-ints}
is proved using Theorem \ref{thm.CRT-k-ids}, which in turn is proved by
induction using Proposition \ref{prop.comax.prodn} and using the Chinese
Remainder Theorem for two ideals twice. All these results have been proved
constructively, so reading their proofs will give us algorithms for all the
isomorphisms they claim.
\par
Explicitly, re-reading the proof of the Chinese Remainder Theorem for two
ideals (Lecture 13), we see that if $I$ and $J$ are two comaximal ideals of a
ring $R$, then the inverse of the isomorphism%
\begin{align*}
f^{\prime}:R/\left(  IJ\right)   &  \rightarrow R/I\times R/J,\\
\overline{r}  &  \mapsto\left(  \overline{r},\overline{r}\right)
\end{align*}
sends each pair $\left(  \overline{x},\overline{y}\right)  $ to $\overline
{yi+xj}$, where $i\in I$ and $j\in J$ are two elements chosen to satisfy
$1=i+j$. Thus, in order to compute preimages under this isomorphism, we need
to find two elements $i\in I$ and $j\in J$ satisfying $1=i+j$ (that is,
\textquotedblleft witnessing\textquotedblright\ the comaximality of $I$ and
$J$). In our case, $I$ and $J$ are principal ideals of $\mathbb{Z}$, and thus
we can find our $i$ and $j$ using the extended Euclidean algorithm (which
takes two integers $a$ and $b$ as inputs and produces integers $x$ and $y$
satisfying $xa+yb=\gcd\left(  a,b\right)  $). Specifically, this algorithm
lets us write $1$ in the form $x\cdot5+y\cdot6$ (which is needed to invert the
isomorphism $\mathbb{Z}/\left(  5\cdot6\right)  \rightarrow\left(
\mathbb{Z}/5\right)  \times\left(  \mathbb{Z}/6\right)  $) and write $1$ in
the form $x\cdot5\cdot6+y\cdot23$ (which is needed to invert the isomorphism
$\mathbb{Z}/\left(  5\cdot6\cdot23\right)  \rightarrow\left(  \mathbb{Z}%
/5\right)  \times\left(  \mathbb{Z}/6\right)  \times\left(  \mathbb{Z}%
/23\right)  $).
\par
Since this is not a course on computational algebra, I will leave it at these
laconic hints.}, and thus we can find that the preimage of the triple $\left(
\overline{3},\overline{2},\overline{9}\right)  \in\left(  \mathbb{Z}/5\right)
\times\left(  \mathbb{Z}/6\right)  \times\left(  \mathbb{Z}/23\right)  $ under
this isomorphism is $\overline{308}$. Thus, the integer $a$ we are looking for
satisfies $\overline{a}=\overline{308}$ in $\mathbb{Z}/\left(  5\cdot
6\cdot23\right)  $, and conversely, any integer $a$ satisfying $\overline
{a}=\overline{308}$ in $\mathbb{Z}/\left(  5\cdot6\cdot23\right)  $ will work.
The simplest answer is of course $a=308$, but there are infinitely many others.

Problems like this are how the Chinese Remainder Theorem got its name.

\item A more down-to-earth application of the Chinese Remainder Theorem is a
technique known as \textbf{Chinese remaindering}. It can be used to
parallelize computations with large integers, saving both on running time and
on memory usage. A real-life example of this is given in \cite[pp.
1031--1033]{Vogan07}.

Let us here give a toy example.

Assume we want to compute%
\[
a:=77^{2}\cdot80^{2}-78^{2}\cdot79^{2}.
\]
Assume that we are unable/unwilling to do arithmetic with numbers this high
(OMG 8 digits!), and also unwilling to simplify our life by finding a
factorization\footnote{This is not as unrealistic as it sounds. Not all
factorizations are as evident as $x^{2}-y^{2}=\left(  x-y\right)  \left(
x+y\right)  $, and in practice, the Chinese Remainder Theorem is often used
for factoring polynomials.}. However, for some theoretical reasons, we know
that the magnitude of $a$ is not too high: say, $-50\ 000<a<50\ 000$. (Such
estimates often fall out of theoretical considerations.)

What can we do?

Well, we can easily compute the residue class $\overline{a}$ in $\mathbb{Z}/5$
by first reducing the relevant integers $77,\ 80,\ 78,\ 79$ to their
remainders upon division by $5$ (warning: do not reduce the
exponents!\footnote{Of course, the exponents here are $2$, so the temptation
does not arise in the first place.}) and then performing the rest of the
computation (squaring, multiplying and subtracting) within $\mathbb{Z}/5$:%
\begin{align*}
\overline{a}  &  =\overline{77^{2}\cdot80^{2}-78^{2}\cdot79^{2}}\\
&  =\overline{77}^{2}\cdot\overline{80}^{2}-\overline{78}^{2}\cdot
\overline{79}^{2}\\
&  =\overline{2}^{2}\cdot\overline{0}^{2}-\overline{3}^{2}\cdot\overline
{4}^{2}\ \ \ \ \ \ \ \ \ \ \left(
\begin{array}
[c]{c}%
\text{here, we reduced the numbers}\\
\text{to their remainders}%
\end{array}
\right) \\
&  =\overline{4}\cdot\overline{0}-\overline{4}\cdot\overline{1}=\overline
{0}-\overline{4}=\overline{-4}=\overline{1}.
\end{align*}


Likewise, we can compute the residue classes $\overline{a}$ in $\mathbb{Z}/2$
and $\mathbb{Z}/3$ and $\mathbb{Z}/7$ and $\mathbb{Z}/11$ and $\mathbb{Z}/13$
and $\mathbb{Z}/17$ and so on (there are infinitely many primes, after all,
but we only need these few). Thus, we easily find the tuple%
\[
\left(  \overline{a},\overline{a},\overline{a},\overline{a},\overline
{a},\overline{a},\overline{a}\right)  \in\mathbb{Z}/2\times\mathbb{Z}%
/3\times\mathbb{Z}/5\times\mathbb{Z}/7\times\mathbb{Z}/11\times\mathbb{Z}%
/13\times\mathbb{Z}/17.
\]


However, the primes $2,3,5,7,11,13,17$ are mutually coprime, and thus the
Chinese Remainder Theorem yields a ring isomorphism%
\begin{align*}
\mathbb{Z}/\left(  2\cdot3\cdot5\cdot7\cdot11\cdot13\cdot17\right)   &
\rightarrow\mathbb{Z}/2\times\mathbb{Z}/3\times\mathbb{Z}/5\times
\mathbb{Z}/7\times\mathbb{Z}/11\times\mathbb{Z}/13\times\mathbb{Z}/17,\\
\overline{r}  &  \mapsto\left(  \overline{r},\overline{r},\overline
{r},\overline{r},\overline{r},\overline{r},\overline{r}\right)  ,
\end{align*}
whose inverse we can algorithmically construct. Applying this inverse to the
tuple $\left(  \overline{a},\overline{a},\overline{a},\overline{a}%
,\overline{a},\overline{a},\overline{a}\right)  $ (which has already been
found), we obtain the residue class $\overline{a}\in\mathbb{Z}/\left(
2\cdot3\cdot5\cdot7\cdot11\cdot13\cdot17\right)  $. In other words, we obtain
the residue class $\overline{a}\in\mathbb{Z}/\left(  510\ 510\right)  $ (since
$2\cdot3\cdot5\cdot7\cdot11\cdot13\cdot17=510\,510$).

But we also know that $-50\ 000<a<50\ 000$, so that $a$ lies in the open
interval $\left(  -50\ 000,\ 50\ 000\right)  $. Any two distinct integers in
this interval have distinct residue classes in $\mathbb{Z}/\left(
510\ 510\right)  $, and any integer in this interval can be easily
reconstructed from its residue class. Thus, we can easily reconstruct $a$ from
$\overline{a}$. In our specific example, we obtain $a=-24\,644$.

This method is particularly good for parallel computing, as the computations
of $\overline{a}$ in different quotient rings $\mathbb{Z}/n$ can be done in
parallel. It also saves on memory, since working in $\mathbb{Z}/n$ requires
less memory than working with \textquotedblleft big\textquotedblright%
\ integers. (The extended Euclidean algorithm, on which the computation of the
inverse isomorphism relies, is really fast and not very memory-consuming, so
the last step of the method is not a heavy burden.)

See \cite[\S 4.3.2]{TAoCP2} for more details on Chinese remaindering.
\end{itemize}

More applications of the Chinese Remainder Theorem can be found in
\url{https://mathoverflow.net/questions/10014/} . (As you have surely noticed,
the theorem comes in many forms, some rather elementary; our Theorem
\ref{thm.CRT-k-ids} is one of the most general.)

\begin{thebibliography}{99999999}                                                                                         %


\bibitem[Knuth98]{TAoCP2}Donald Ervin Knuth, \textit{The art of computer
programming, volume 2}, Addison--Wesley 1998.

\bibitem[Stangl96]{Stangl96}Walter D. Stangl, \textit{Counting squares in
}$\mathbb{Z}_{n}$, Mathematics Magazine \textbf{69} (1996), no. 4 (October),
pp. 285--289.

\bibitem[Vogan07]{Vogan07}%
\href{https://www.ams.org/notices/200709/tx070901122p.pdf}{David Vogan,
\textit{The Character Table for }$E_{8}$, Notices of the American Mathematical
Society 2007/09}.
\end{thebibliography}


\end{document}