Suppose $A$ is the set of all rational numbers $p$ such that $p^2 <2$ and $B$ is the set of all rational numbers $p$ such that $p^2 > 2$. We want to show that $A$ contains no largest element and $B$ contains no smallest element.
In Rudin's Principles of Mathematical Analysis, he associates $q = p- \frac{p^2-2}{p+2} = \frac{2p+2}{p+2}$. Did he just come up with this using trial and error?