Let $A = \{p \in \mathbb{Q}^+ : p^2 \lt 2\} $ and $B = \{p \in \mathbb{Q}^+ : p^2 \gt 2\} $. We want to prove that $A$ has no maximum and $B $ has no minimum. I spent a good hour on this without being able to do it. This is how it was done in the book:
Associate with every rational $p \gt 0$ the number
(3) $$q=p- \frac{p^2-2}{p+2}$$
Then
(4) $$q^2-2 = \frac{2 (p^2-2)}{(p+2)^2} $$
If $p $ is in $A $ then $p^2-2 \lt 0$, (3) shows that $q \gt p $, and (4) shows that $q^2 \lt 2$. Thus q is in $A $. (and analogous for $B $).
Ok I can see it works. But how did he find that $q $? Why divide $p^2-2$ by $p+2$ and then subtract it to $p $? What process does one go to find the expressions that work?