Find a basis for QQ(sqrt(D)) whose elements are conjugate

Let $D \in \mathbb{Z}$ be squarefree. Find a basis $\alpha, \overline{\alpha}$ for $\mathbb{Q}(\sqrt{D})$ where $\overline{\alpha}$ is the conjugate of $\alpha$.

Let $\alpha = a+b\sqrt{D}$. Evidently, $\alpha$ is a root of $p(x) = x^2 - 2ax + (a^2 - Db^2)$; the other root is $a - b\sqrt{D}$. If $b \neq 0$, then this polynomial has no rational roots, and so is irreducible over $\mathbb{Q}$. In this case, $p(x)$ is the minimal polynomial of $\alpha$, and so $\overline{\alpha} = a - b\sqrt{D}$.

Note that if $b = 0$, then $\{\alpha,\overline{\alpha}\}$ cannot be a basis for $\mathbb{Q}(\sqrt{D})$ as it contains only one element. Thus we may assume that $b \neq 0$.

We claim that $\{\alpha, \overline{\alpha}\}$ is a basis for $\mathbb{Q}(\sqrt{D})$ so long as $a \neq 0$. To that end, suppose first that $\{\alpha,\overline{\alpha}\}$ is a basis; if $a = 0$, then we have $\alpha = b\sqrt{d}$ and $\overline{\alpha} = -b\sqrt{D}$. Now $1 = xb\sqrt{D} - yb\sqrt{D}$, with $x,y \in \mathbb{Q}$. So $\sqrt{D} = 1/b(x-y)$, a contradiction since $\sqrt{D}$ is not rational. Thus $a \neq 0$.

Conversely, suppose $a \neq 0$. To show that $\{\alpha,\overline{\alpha}\}$ is a basis, it suffices to show that it generates $\mathbb{Q}(\sqrt{D})$, as we know that this field has degree 2 over $\mathbb{Q}$. To achieve this, we will show that $1$ and $i$ are linear combinations of $\alpha$ and $\overline{\alpha}$. Indeed, evidently we have $1 = \frac{1}{2a}\alpha + \frac{1}{2a}\overline{\alpha}$ and $i = \frac{1}{2b}\alpha - \frac{1}{2b} \overline{\alpha}$, as desired.

In particular, $\{1+\sqrt{D}, 1-\sqrt{D}\}$ is a basis for $\mathbb{Q}(\sqrt{D})$ over $\mathbb{Q}$.