<s>[INST] There is no largest rational number $p$ such that $p^2 < 2$ In Rudin's analysis example 1.1, he tried to show the following
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$. He show that $A$ contains no largest number and $B$ contains no smallest
More explicitly, for every $p$ in $A$ we can find a rational $q$ in $A$ such that $p < q$ and vice versa
He then shows
$$q = p - \frac{p^2 - 2}{p + 2}$$
$$q^2 - 2 = \frac{2(p^2 - 2)}{(p + 2)^2}$$
and conclude that if $p$ in $A$ then $p^2 - 2 < 0 \rightarrow q^2 < 2$ and $q > p $ and vice versa.
I understand the conclusion, and I understand the hypothesis, but I didn't understand how he got 
$$q = p - \frac{p^2 - 2}{p + 2}$$
and 
$$q^2 - 2 = \frac{2(p^2 - 2)}{(p + 2)^2}$$
Specifically, I think he is trying to show the following
If $p$ in $A$, let $q$ be a number greater than $p$ 
$$q = p + \beta$$
now show 
$$q^2 - 2 < 0 \Rightarrow q^2 - 2 = p^2 + 2\beta p  + \beta^2 - 2$$
I use the quadratic equation to find the threshold for $\beta$, but I can't derive what Rudin give, can someone explain how Rudin got his equations?
 [/INST] Observe that: $p^2 < 2 \Rightarrow p^2+2p < 2 + 2p \Rightarrow p(p+2) < 2+2p \Rightarrow p < \dfrac{2+2p}{p+2}\in \mathbb{Q}$. He then set $q = \dfrac{2+2p}{p+2}$, then $p < q$ from definition of $q$, and furthermore: $q^2 - 2 = \left(\dfrac{2+2p}{p+2}\right)^2 - 2= \dfrac{4+8p+4p^2}{p^2+4p+4} - 2= \dfrac{2}{(p+2)^2}\cdot (p^2-2) < 0\Rightarrow q^2< 2.$
</s>