Let $A$ be the set of all rational numbers $p$ such that $p^2<2$, and let $B$ be the set of all rational numbers $p$ such that $p^2>2$. It can be shown that $A$ has no largest element and that $B$ has no smallest element by associating to each $p>0$ the number $$q=p-\frac{p^2-2}{p+2}$$
and then proving that $p\in A \Rightarrow q\in A$ and $p\in B\Rightarrow q\in B$.
Where is this value of $q$ coming from?
We want to find a rational number $q$ such that $$ \sqrt 2<q<p. $$ One idea is try to lower $p$, like $$ q = \frac {k-1}k p <p $$ with a suitable rational $k$. If you write the condition $\sqrt 2<q$, you get $$ \sqrt 2<\frac {k-1}{k} p $$ and obtain $$ k \ge \frac{p}{p-\sqrt 2}. $$ Any positive rational number $k$ above that bound gives you a good $q$. In order to get a rational number, you try to get rid of the $\sqrt 2$ by rationalization $$ \frac{p}{p-\sqrt 2} = \frac{p(p+\sqrt 2)}{p^2-2} $$ and $2>\sqrt 2$, so $$ k = \frac{p(p+ 2)}{p^2-2} > \frac{p(p+\sqrt 2)}{p^2-2}. $$ Substituting it in $q$, you obtain $$ q = \frac {k-1}{k} p = p - \frac {p}{k} = p - \frac{p^2-2}{p+ 2}. $$
You do the same for the opposite inequality.