Rudin has a proof in which he is proving that $A=\{ p \in \mathbb{Q}\;|\; p^2<2\}$ has no maximum element (or in other words, an element which is greater than every other element).
For this he creates a rational $q=p-\dfrac{p^2-2}{p+2}$ and uses this rational $q$ to show that it is greater than $p$ and still in $A$. Since $p$ was arbitrary element of $A$, this finishes the proof.
I follow the proof but I don't understand where the formula for $q$ magically came from. Any help?