What is the reasoning behind $y=\frac{x(x^2+3D)}{ 3x^{2}+D }$ in Dedekind's "Essays On The Theory Of Numbers"? In the section IV "Creation Of Irrational Numbers"of Richard Dedekind's  "Essays On The Theory Of Numbers" the author shows that domain of rational numbers is incomplete, but can be made so. To show that, he does the following:

Let D be a positive integer but not the square of an integer, then there exists a positive
  integer λ such that
  $$\lambda ^{2}< D<(\lambda+1) ^{2}$$
  [author assigns $D$ to be in the same set ($A_{1}$) as $\lambda ^{2}$; else is in $A_{2}$]...this  separation forms a cut (A1, A2)
  ...But this cut is produced by no rational number. To demonstrate this it
  must be shown first of all that there exists no rational number
  whose square $= D$
  [proof by contradiction]
  If there exist a rational number
  whose square = D, then there exist two positive integers t, u, that satisfy the
  equation $$t^2-Du^2=0$$ 
  then, by substitution,
  $$\lambda u< t<(\lambda+1)u$$
  the number $u^{'}=t-\lambda u$ is a positive integer certainly less than $u$.  $$t^{'}=Du-\lambda t$$
$t^{'}$ is likewise a positive integer, and we have $${t^{'}}^{2}-{Du^{'}}^{2}= (\lambda^{2}-D )(t^{2}-Du^{2})=0$$ which is contrary to the assumption respecting $u$ [$u$ is not “the least positive integer possessing the property that its square, by
  multiplication by $D$, may be converted into the square of an integer.”].

Now, the part I don't follow: 

Hence the square of every rational number x is either < D or > D. From
  this it easily follows that there is neither in the class A1 a greatest, nor in the
  class A2 a least number. For if we put $$y=\frac{x(x^2+3D)}{ 3x^{2}+D }$$ 
  we have $$y-x=\frac{2x(D-x^2)}{ 3x^{2}+D }$$

Can anyone explain how the last two equations came to be?
 A: It's one thing to prove $$D-y^{2}=\frac{\left(D-x^{2}\right)^{3}}{\left(3x^{2}+D\right)^{2}}$$and thus argue underestimates beget underestimates. It's another to explain where this formula for $y$ came from in the first place. The existing answer addresses that too, but I thought I'd show an alternative motivation for the formula. Since$$D-y^{2}\in O\left(\left(D-x^{2}\right)^{3}\right),$$a natural guess is Halley's method, viz.$$y=x-\frac{2f(x)f^\prime(x)}{2[f^\prime(x)]^2-f(x)f^{\prime\prime}(x)},\,f(x):=x^2-D.$$This gives$$y=\frac{x(x^2+3D)}{3x^2+D},$$as expected.
A: You want to cook up a rational $y$ which beats your $x$ to $\sqrt{D}$ and yet remains on the same side as $x$.  The given $y$ achieves this.
How could you come up with this $y$ if you have to start from scratch?  Note that in the proof he wanted $y^2-D=\frac{(x^2-D)^3}{C(x,D)^2}$ is a good start (so $y$ lies in the same side as $x$), so $C(x,D)>\lvert x^2-D\rvert$, which would be guaranteed if $C(x,D)>x^2+D$, and we have
$$
(y+x)(y-x)=y^2-x^2=\frac{(x^2-D)^3-(x^2-D)C(x,D)^2}{C(x,D)^2}=(x^2-D)\frac{[x^2-D+C(x,D)][x^2-D-C(x,D)]}{C(x,D)^2}.
$$
It is probably a good idea if $y\pm x$ contains a factor $x$ as it looks a little more homogeneous.  So we try $C=(k+1)x^2+D$ where $k>0$, giving
$$
(y+x)(y-x)=(D-x^2)\frac{(k+2)x^2(kx^2+2D)}{[(k+1)x^2+D]^2}
$$
Now we try to split the factors, $D-x^2$ obviously goes into $y-x$, the denominator is clearly one each, the two $x$ in our manufactured $x^2$ split one each, and the $kx^2+2D$ therefore goes into $y+x$.  Then the constant $k+2$ needs to be split up in some way, so we introduce another parameter $m\in\mathbb{Q}$
\begin{align*}
y+x &=\frac{\frac{(k+2)}mx(kx^2+2D)}{(k+1)x^2+D}\\
y-x &=\frac{mx(D-x^2)}{(k+1)x^2+D}.
\end{align*}
We want this to be consistent, so subtracting
$$
\frac{\frac{(k+2)}mx(kx^2+2D)}{(k+1)x^2+D}-\frac{mx(D-x^2)}{(k+1)x^2+D}=2x
$$
or equivalently,
$$
\frac{(k+2)}m(kx^2+2D)-{m(D-x^2)}=2[(k+1)x^2+D].
$$
Therefore, we want $k,m$ such that
$$\left\{
\begin{aligned}
\frac{(k+2)}m(k)+m&=2(k+1)\\
\frac{(k+2)}2m-m&=2
\end{aligned}\right.
$$
which has positive rational solution $k=2$ and $m=2$, giving us
$$
y=\frac{\frac{2x(2x^2+2D)}{3x^2+D}+\frac{2x(D-x^2)}{3x^2+D}}{2}
=\frac{x(x^2+3D)}{3x^2+D}.
$$
