I've just begun self-studying Rubin's Principals of Mathematical Analysis.
I'm having difficulty understanding a specific line in example 1.1 (proving $\sqrt{2}$ is irrational). Specifically, I'm trying to understand how they arrive at the following:
$ q = p - \frac{p^2 -2}{p+2}$
Here is the proof up to that point:
Let A be the set of all positive rationals p such that $p^2 < 2$ and let B consist of all positive rationals p such that $p^2 > 2$. We shall show that A contains no largest number and B contains no smallest number.
More explicitly, for every p in A we can find a rational q in A such that $p < q$, and for every p in B we can find a rational q in B such that $q < p$.
Any help would be much appreciated.