# If $d\equiv 2,3\pmod 4$, then the ring of integer of $K$ is $\mathbb Z[\sqrt d]$.

Let $K=\mathbb Q(\sqrt d)$ with $[K:\mathbb Q]=2$.

Show that if $d\equiv 2,3\pmod 4$ the ring of integer $\mathcal O_K:=\bar{ \mathbb Z}\cap K$ is $\mathbb Z[\sqrt d]$.

The proof goes as: Let show that $\mathcal O_K\subset \mathbb Z[\sqrt d]$. Let $q\in \mathcal O_K$. The, $q$ is solution of a polynomial $X^2+bX+c$ with $b,c\in \mathbb Z$. Then, $$q=\frac{-b+\sqrt{b^2-4c}}{2}$$ and s.t. $b^2-4c=f^2d$ for $f\in \mathbb Z$.

Q1) Why $q=\frac{-b+\sqrt{b^2-4c}}{2}$ and not $q=\frac{-b\pm\sqrt{b^2-4c}}{2}$ ?

Q2) Why $b^2-4c=f^2d$ ?

Since $f^2\equiv 0,1\pmod 4$, we must have $b^2-4c\not\equiv 1\pmod 4$. By the way, we see that $b^2-4c\equiv 0,1\pmod 4$, and thus $b^2-4c\pmod 0\pmod 4$.

Q3) Why $f^2\equiv 0,1\pmod 4$ and why $b^2-4c\equiv0,1\pmod 4$ ?

Sorry, but I don't understand all this. For the rest, it's fine.

For $\mathbb Z[\sqrt d]\subset \mathcal O_K$, let $a+b\sqrt d\in \mathbb Z[\sqrt d]$. Then, it's a root of $$X^2-2aX+(a^2-db^2)=(X-(a+b\sqrt d))(X-(a-b\sqrt d))$$ and thus $\mathbb Z[\sqrt d]\subset \mathcal O_K$.

Q4) Here I don't understand why the fact that $$X^2-2aX+(a^2-db^2)=(X-(a+b\sqrt d))(X-(a-b\sqrt d))$$ implies that $\mathbb Z[\sqrt d]\subset \mathcal O_K$.

Q1) it doesn't matter, they're making a choice, remember $\Bbb Z[\sqrt{d}]=\Bbb Z[-\sqrt{d}]$, so the rings are equal.
Q2) The field is $\Bbb Q\left(\displaystyle{-b+\sqrt{b^2-4ac}\over 2a}\right)$ by multiplying the generator by $2a$, adding $b$ we see that this is the same as $\Bbb Q(\sqrt{b^2-4ac})$. But then if $b^2-4ac = f^2 d$ we can divide the generator by $|f|$ and we get $\Bbb Q(\sqrt{d})$. These steps are also all reversible, so the fields are equal.
Q3) All integer squares are $0$ or $1$ mod $4$, this is just modular arithmetic. The fact that the discriminant is always $0$ or $1$ mod $4$ is a theorem which involves a bit of computations and connections with quadratic forms (or you can read about it in Serre's Local Fields if you want a very high-level approach using tensor algebra).
Q4) That equation has integer coefficients and $a+b\sqrt{d}$ as a root. Since this is an arbitrary element of $\Bbb Z[\sqrt{d}]$, and we $\mathcal{O}_K$ is the ring of all algebraic integers of $K=\Bbb Q(\sqrt{d})$ it shows that all elements of the former ring are also algebraic integers, which is exactly that containment statement.