Solution to Abstract Algebra by Dummit & Foote 3rd edition Chapter 7.3 Exercise 7.3.12
Solution: We begin with a lemma.
Lemma: If $D \in \mathbb{Z}$ is not a perfect square, then $\sqrt{D}$ is not rational.
Proof: Suppose to the contrary that $\sqrt{D} = a/b$. Then $D = a^2/b^2$, and $Db^2 = a^2$. Note, however, that some divisor of $D$ must have odd multiplicity in the factorization of $D$, and thus of $Db^2$, while all divisors of $a^2$ have even multiplicity. $\square$
As a consequence of this lemma, if $D$ is not a perfect square and $$a_1 + b_1\sqrt{D} = a_2 + b_2 \sqrt{D},$$ then $a_1 = a_2$ and $b_1 = b_2$. To see this, suppose $b_1 \neq b_2$. Then $\sqrt{D} = (a_1 – a_2)/(b_2 – b_1)$ is rational, a contradiction. Thus $b_1 = b_2$, and $a_1 = a_2$. Similarly, if $D$ is squarefree, then $$a_1 + b_1 \frac{1 + \sqrt{D}}{2} = a_2 + b_2\frac{1+\sqrt{D}}{2}$$ implies that $a_1 = a_2$ and $b_1 = b_2$.
(1) Note that $\begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix} \in S$. Now let $A = \begin{bmatrix} a_1 & b_1 \\ Db_1 & a_1 \end{bmatrix}$, $B = \begin{bmatrix} a_2 & b_2 \\ Db_2 & a_2 \end{bmatrix} \in S$. Evidently, $$A – B = \begin{bmatrix} a_1 – a_2 & b_1 – b_2 \\ D(b_1 – b_2) & a_1 – a_2 \end{bmatrix} \in S$$ and $$AB = \begin{bmatrix} a_1a_2 + Db_1b_2 & a_1b_2 + b_1a_2 \\ D(a_1b_2 + b_1a_2) & a_1a_2 + Db_1b_2 \end{bmatrix} \in S.$$ Thus $S$ is a subring of $M_2(\mathbb{Z}$).
Define $\varphi : \mathbb{Z}[\sqrt{D}] \rightarrow S by a+b\sqrt{D} \mapsto \begin{bmatrix} a & b \\ Db & a \end{bmatrix}$. By the lemma and the discussion following it, $\varphi$ is well defined. Evidently we have the following for all $\alpha = a_1 + b_1\sqrt{D}$ and $\beta = a_2 + b_2\sqrt{D}$.
\begin{align*}\varphi(\alpha + \beta) =&\ \varphi((a_1 + b_1 \sqrt{D}) + (a_2 + b_2\sqrt{D}))\\
=&\ \varphi((a_1 + a_2) + (b_1 + b_2)\sqrt{D})\\
=&\ \begin{bmatrix} a_1 + a_2 & b_1 + b_2 \\ D(b_1 + b_2) & a_1 + a_2 \end{bmatrix}\\
=&\ \begin{bmatrix} a_1 & b_1 \\ Db_1 & a_1 \end{bmatrix} + \begin{bmatrix} a_2 & b_2 \\ Db_2 & a_2 \end{bmatrix}\\
=&\ \varphi(a_1 + b_1\sqrt{D}) + \varphi(a_2 + b_2 \sqrt{D})\\
=&\ \varphi(\alpha) + \varphi(\beta)\end{align*} \begin{align*}\varphi(\alpha\beta) =&\ \varphi((a_1 + b_1\sqrt{D})(a_2 + b_2\sqrt{D}))\\
=&\ \varphi((a_1a_2 + Db_1b_2) + (a_1b_2 + a_2b_1)\sqrt{D})\\
=&\ \begin{bmatrix} a_1a_2 + Db_1b_2 & a_1b_2 + a_2b_1 \\ D(a_1b_2 + a_2b_1) & a_1a_2 + Db_1b_2 \end{bmatrix}\\
=&\ \begin{bmatrix} a_1 & b_1 \\ Db_1 & a_1 \end{bmatrix} \cdot \begin{bmatrix} a_2 & b_2 \\ Db_2 & a_2 \end{bmatrix}\\
=&\ \varphi(a_1 + b_1\sqrt{D}) \cdot \varphi(a_2 + b_2\sqrt{D})\\
=&\ \varphi(\alpha) \cdot \varphi(\beta)\end{align*}Thus $\varphi$ is a homomorphism of rings. Now if $\begin{bmatrix} a & b \\ Db & a \end{bmatrix} \in S$, then $\varphi(a + b\sqrt{D}) = \begin{bmatrix} a & b \\ Db & a \end{bmatrix}$, so that $\varphi$ is surjective. Suppose now that $a+b\sqrt{D}$ is in the kernel of $\varphi$. Then $$\varphi(a+b\sqrt{D}) = \begin{bmatrix} a & b \\ Db & a \end{bmatrix} = \begin{bmatrix} 0 & 0 \\ 0 & 0 \end{bmatrix},$$ so that $a = b = 0$. Thus the kernel of $\varphi$ is trivial, and $\varphi$ is injective. Thus $\varphi$ is a ring isomorphism.
(3) First we show that $S$ is a subring of $M_2(\mathbb{Z})$. To that end, let $A = \begin{bmatrix} a_1 & b_1 \\ \frac{D-1}{4}b_1 & a_1+b_1 \end{bmatrix}$ and $B = \begin{bmatrix} a_2 & b_2 \\ \frac{D-1}{4}b_2 & a_2+b_2 \end{bmatrix}$ be in $S$. Clearly $0 \in S$. Moreover, evidently $$A – B = \begin{bmatrix} a_1 – a_2 & b_1 – b_2 \\ \frac{D-1}{4}(b_1 – b_2) & (a_1 – a_2) + (b_1 – b_2) \end{bmatrix}$$ and $$AB = \begin{bmatrix} a_1a_2 + \frac{D-1}{4}b_1b_2 & a_1b_2 + b_1a_2 + b_1b_2 \\ \frac{D-1}{4}(a_1b_2 + a_2b_1 + b_1b_2) & (a_1a_2 + \frac{D-1}{4}b_1b_2) + (a_1b_2 + a_2b_1 + b_1b_2) \end{bmatrix}.$$ Thus $S$ is a subring.
Now define a mapping $\varphi : \mathcal{O} \rightarrow S$ by $a + b\omega \mapsto \begin{bmatrix} a & b \\ Db & a+b \end{bmatrix}$. Clearly $\varphi$ is well defined. We have the following for all $\alpha = a_1 + b_1\omega$ and $\beta = a_2 + b_2\omega$ in $\mathcal{O}$.\begin{align*}\varphi(\alpha + \beta) =&\ \varphi((a_1 + b_1\omega) + (a_2 + b_2\omega))\\
=&\ \varphi((a_1 + a_2) + (b_1 + b_2)\omega)\\
=&\ \begin{bmatrix} a_1 + a_2 & b_1 + b_2 \\ \frac{D-1}{4}(b_1 + b_2) & a_1 + a_2 + b_1 + b_2 \end{bmatrix}\\
=&\ \begin{bmatrix} a_1 & b+1 \\ \frac{D-1}{4}b_1 & a_1 + b_1 \end{bmatrix} + \begin{bmatrix} a_2 & b_2 \\ \frac{D-1}{4}b_2 & a_2 + b_2 \end{bmatrix}\\
=&\ \varphi(a_1 + b_1\omega) + \varphi(a_2 + b_2\omega)\\
=&\ \varphi(\alpha) + \varphi(\beta)\end{align*}\begin{align*}\varphi(\alpha\beta) =&\ \varphi((a_1+b_1\omega)(a_2+b_2\omega))\\
=&\ \varphi((a_1a_2 + b_1b_2\frac{D-1}{4}) + (a_1b_2 + a_2b_1 + b_1b_2)\omega)\\
=&\ \begin{bmatrix} a_1a_2 + b_1b_2\frac{D-1}{4} & a_1b_2 + a_2b_1 + b_1b_2 \\ \frac{D-1}{4}(a_1b_2 + a_2b_1 + b_1b_2) & (a_1a_2 + \frac{D-1}{4}b_1b_2) + (a_1b_2 + a_2b_1 + b_1b_2) \end{bmatrix}\\
=&\ \begin{bmatrix} a_1 & b_1 \\ \frac{D-1}{4}b_1 & a_1 + b_1 \end{bmatrix} \cdot \begin{bmatrix} a_2 & b_2 \\ \frac{D-1}{4}b_2 & a_2 + b_2 \end{bmatrix}\\
=&\ \varphi(a_1 + b_1\omega) \cdot \varphi(a_2 + b_2\omega)\\
=&\ \varphi(\alpha)\varphi(\beta)\end{align*}Thus $\varphi$ is a ring homomorphism. As before, it is clear that $\varphi$ is surjective and injective; thus $\varphi$ is a ring isomorphism.