Checking a fundamental unit of a real quadratic field I just want to check whether I have got the fundamental unit of a certain real quadratic field, but I can't find how.
For instance, if I am working in $\mathbb{Q}(\sqrt{2})$ then $\mathcal{O}_K=\mathbb{Z}[\sqrt{2}]$ and so the fundamental unit is of the form $a+b\sqrt{2}$. I suppose the fundamental unit is $1+\sqrt{2}$, ie. $a=1, b=1$. I know this satisfies Pell's Equation:
$$a^2-db^2=1^2-(2)(1^2)=1-2=-1$$
and so is a unit. How would I show this is fundamental?
Since the fundamental unit generates all the other units, I first considered trying to show that $(1+\sqrt{2})^n$ for $n \in \mathbb{N}$ must generate units, but this got messy. Surely there is a simpler way to check if this unit is fundamental? Is it simply that these are the smallest values of $a,b$ to create a unit?
 A: Here’s the story, though I leave it to others to furnish a proof or give a proper reference.
For $d\ge2$ and not a square, you get all solutions to the Pell equation $m^2-dn^2=\pm1$ by looking at the continued fraction expansion of $\sqrt d$. If $k=\lfloor\sqrt d\rfloor$, then your expansion looks like this:
$$
\sqrt d=k+\bigl[\frac1{\delta_1+}\>\frac1{\delta_2+}\cdots\frac1{\delta_{r-2}+}\>\frac1{\delta_{r-1}+}\>\frac1{2k+}\>\bigr]\,,
$$
where the part in brackets repeats infinitely. Then, every time you evaluate a convergent to the continued fraction just before the appearance of the $2k$, you’ll get a solution of Pell from the numerator $m$ and the denominator $n$. For instance, $\sqrt7=2+\frac1{1+}\,\frac1{1+}\,\frac1{1+}\,\frac1{4+}\,\cdots$, repeating with a period of length four. You evaluate $2+\frac1{1+}\,\frac1{1+}\,\frac1{1}=8/3$, and lo and behold, the first solution of $m^2-7n^2=\pm1$ is $m=8$, $n=3$.
For $d$ squarefree and incongruent to $1$ modulo $4$, this gives you all the units in $\Bbb Q(\sqrt{d}\,)$, but for $d\equiv1\pmod4$, it may happen that what you get is the cube of a unit. But as I recall, in that case, the primitive unit’s coordinates always will show up as the numerator and denominator of an earlier convergent.
