Proving the real numbers are complete In Rudin's book, the following proof is published:

Let $A$ be the set of all positive rationals $p : p^2 &lt; 2$. Let $B$ be the set of all positive rationals $p : p^2 &gt; 2$. $A$ contains no largest number and $B$ contains no smallest.
Let q be a rational. More explicitly, $$\forall p \in A, \exists q \in A : p &lt; q$$
and $$\forall p \in B, \exists q \in B : q &lt; p$$
This needs proof.

Now he introduces a couple of equations which are not clear where they are derived from. As follows,

To do this, we associate with each rational $p &gt; 0$ the number $$q = p - {\frac{p^2-2}{p+2}} = {\frac{2p+2}{p+2}}$$
then $$q^2 - 2 = {\frac {2(p^2-2)}{(p+2)^2}}$$

He then goes on to prove how $p \in A \rightarrow q \in A$; similarly for the set B.
My question is: How did he arrive at those equations - particularly, the first one (since the second is clear)?
If $p\in\mathbb{Q}$ is smaller than $\sqrt{2}$, we want to find another rational $p&lt;q&lt;\sqrt{2}$. Now, this can easily be handled with decimal fractions, but if you want something neater that relies solely on $p$, then what we basically want to do is find a rational $r\in\mathbb{Q}\cap(0,\sqrt{2}-p)$ and define $q=p+r$.

Note that $\sqrt{2}-p\not\in\mathbb{Q}$, but $2-p^2 = (\sqrt{2}-p)(\sqrt{2}+p)\in\mathbb{Q}$. If we want it to be small enough, it suffices that $\frac{\sqrt{2}+p}{2+p} &lt; 1$, so that
$$\frac{2-p^2}{2+p} = (\sqrt{2}-p)\frac{\sqrt{2}+p}{2+p}&lt;\sqrt{2}-p.$$
if $p^2&lt;2$
let's add 2p to both sides of the inequality
then $p^2+2p&lt;2+2p$ then $p(p+2)&lt;2(p+1)$ then $p&lt;\frac{2(p+1)}{p+2}$ so let's set $q=\frac{2(p+1)}{p+2}$ then we have if $p^2&lt;2$ then $p&lt;q$. what is left to show is that $q^2&lt;2$
and that would show that $0&lt;p&lt;q$ and $q \in A$