How to approximate real numbers using members of $\mathbb Z (\sqrt d)$? Real numbers can be approximated to successively better precision using the convergents of a continued fraction.
Is there a similar way to find quadratic integers of fixed (positive) discriminant that approximate reals?  I'm aware that it can provably be done, I'm interested in actually finding members of $\mathbb Z (\sqrt d)$ that work.
I've found any number of results proving that reals can be approximated by algebraic numbers of various degrees, but none yet with fixed discriminant, nor any algorithm for actually finding the numbers in question.  I suspect that the answer will involve generalized continued fractions somehow, but I don't yet understand them well enough to make this work.
 A: There are probably lots of ways to do this, but here is one.
First pick some integers $a$ and $b$ such that $0 \lt a + b\sqrt{d} \lt 1$ (for example choose $a = -\left\lfloor\sqrt{d}\right\rfloor$ and $b = 1$, which works if $d$ is not a perfect square).
Now given a real number $\alpha$, define the sequence $\{c_n\}_{n=1}^{\infty}$ by $c_1 = \lfloor\alpha\rfloor$ and $c_{i+1} = c_i + \left\lfloor\frac{\alpha - c_i}{(a + b\sqrt{d})^i}\right\rfloor(a+b\sqrt{d})^i$
All the $c_i$ are in $\mathbb{Z}[\sqrt{d}]$ and $\lim\limits_{n\to\infty} c_n = \alpha$.

To show this, first notice that the sequence is monotonically increasing, and that it is bounded above by $\alpha$ (induction and bounds on $\lfloor x \rfloor$), and so it is convergent. Let the limit be $c$.
Then taking limits on the recurrence above we get $$\lim\limits_{n\to\infty}\left\lfloor\frac{\alpha - c_n}{(a + b\sqrt{d})^n}\right\rfloor(a+b\sqrt{d})^n = 0$$
But we also have $$\alpha - c_n - (a + b\sqrt{d})^n \lt \left\lfloor\frac{\alpha - c_n}{(a + b\sqrt{d})^n}\right\rfloor(a+b\sqrt{d})^n \leq \alpha - c_n$$
So rearranging we get
$$\left\lfloor\frac{\alpha - c_n}{(a + b\sqrt{d})^n}\right\rfloor(a+b\sqrt{d})^n \leq \alpha - c_n \lt \left\lfloor\frac{\alpha - c_n}{(a + b\sqrt{d})^n}\right\rfloor(a+b\sqrt{d})^n + (a + b\sqrt{d})^n$$
Taking limits and using $0 \lt a + b\sqrt{d} \lt 1$, we get a squeezing result that $\alpha - c = 0$.

I am sure there are nicer ways to prove this... Anyway the intuition is simple, you basically just start moving from $0$ in steps of $1$, until you get as close to $\alpha$ as possible from below. Then you start moving in steps of $(a + b\sqrt{d})$ until you get as close to $\alpha$ as possible from below, then you start moving in steps of $(a + b\sqrt{d})^2$, and so on. It's pretty much like doing a base-x expansion of $\alpha$, where $x$ is this $a + b\sqrt{d}$.
