Real Analysis: Showing $f: \Bbb Q \to \Bbb Q$ is continuous The following is all working in $\mathbb{Q}$, not $\mathbb{R}$. I am working with the function $f: \mathbb{Q} \to \mathbb{Q}$ defined piece-wise by 
$f(x)=-1$ if $x^2<2$
$f(x)=1$ if otherwise
I hope to prove $f$ is continuous. The hint in my textbook suggests to break this down into two steps: One, show $f$ is continuous at $x$ if $x^2<2$ then, two, show $f$ is continuous at $x$ if $x^2>2$. 
To prove the former, the books suggests we show: If $x^2<2$ and $\delta=\frac{2-x^2}{6}$, show that $y^2<2$ whenever $|x-y|<\delta$. This is where I am stuck; I've hopelessly tried to prove this statement several ways to no avail. 
I don't believe showing $|x-y|<\delta$ $\implies$ $y^2<2$ is possible solely through algebra as I've tried many different manipulations/factoring(s) and cannot seem to get it. Furthermore, I've thought of taking the limit of both sides (since $y<\frac{2-x^2}{6}+x$ can easily be obtained through algebra and the RHS $\to$ $\sqrt{2}$ as $x \to \sqrt{2}$) yet I know the limit need not preserve strict inequalities and, also, I am unsure if I can work with $\sqrt{2}$ like that because, technically, the entire problem is in $\mathbb{Q}$. I feel as if I am making this problem more difficult than it is. Any hints or solutions would be greatly appreciated; the problem has been eating at me all day and I'm now very curious of the solution after my many failed attempts. 
 A: Your $f$ is locally constant, so it had better be continuous. But for a complete formal proof, just use this characterization of continuity: $f$ is continuous if and only if for every open $U$ in the target space (codomain), $f^{-1}(U)$ is open in the domain.
Well: if $U$ contains both $1$ and $-1$, then the inverse image is $\mathbb Q$, open. If it contains neither, inverse image is empty, also open. If $U$ contains $1$ but not $-1$, then the inverse image is $[\langle-\infty,\sqrt2\rangle\cup\langle\sqrt2,\infty\rangle]\cap\mathbb Q$, which, being the intersection of $\mathbb Q$ with an open of $\mathbb R$, is open in $\mathbb Q$. Similar if the inverse image contains $-1$ but not $1$, but shorter.
A: For this you take a sequence of rational numbers converging to some $x\in\mathbb{Q}$. Either $|x|<\sqrt{2}$ or $|x|>\sqrt{2}$; equality can never hold.
Then there is an interval $\{y\in\mathbb{R}: |x-y|<\delta\}$ and all such $y$ also satisfy $|y|<\sqrt{2}$ or $|y|>\sqrt{2}$. Either way the sequence is eventually constant after applying $f$, hence $f$ is continuous.
In particular if you write $|x-\sqrt{2}|=d$ then choosing $\delta =\min\{d/2,\epsilon/2\}$, you can assure the $y$ satisfy the condition claimed.
For the original claim--as per the op's request:
$$2-x^2=|\sqrt 2-x||\sqrt 2+x|$$
$$<d|\sqrt 2+x|$$
then since $|x|<\sqrt 2$ we can apply the triangle inequality and get:
$$2-x^2< d(\sqrt 2 +|x|)$$
$$\le d(\sqrt2+\sqrt 2)=2d\sqrt 2$$
then dividing by 6 we get:
$${2-x^2\over 6}< {d\sqrt 2\over 3}<d$$
So this means $|x-y|<\delta<d$ hence $|y|<\sqrt 2$ by the definition of the number $d$.
A: Here's how I would do it, given some knowledge about real numbers. Find a sequence of rationals $x_n$ with $x_n^2 < 2$ and $x_n \to \sqrt{2}$. Given an $x$ with $x^2 < 2$ and $x>0$, find an $n$ with $x_n > x$. Then set $\delta=|x_n-x|$. Do the same for $x^2>2$ (and for $x<0$).
To follow your hint (which is completely agnostic about the existence of real numbers), note that for $x>0$, $f(x)=x^2$ is increasing, and for $x<0$, $f(x)=x^2$ is decreasing. So the "worst case" in an interval $[x-\delta,x+\delta]$ is $x+\delta$ for $x>0$ and $x-\delta$ for $x<0$.
So you can split into cases. That is, show that if $x>0$ and $x^2<2$ then $\left ( x+\frac{2-x^2}{6} \right )^2 < 2$, and that if $x<0$ and $x^2<2$ then $\left ( x - \frac{2-x^2}{6} \right )^2 < 2$. 
Edit: actually, here's an intuitive but still completely rigorous proof. Let $x \in \mathbb{Q}$ and $x^2 < 2$. Suppose $x_n$ is a sequence of rationals with $x_n \to x$. Because $x_n \to x$, there is an $N$ so that for $n \geq N$, $x_n^2 < 2$. (Sketch: $x_n^2 = (x_n-x+x)^2 = (x_n-x)^2 + 2x(x_n-x) + x^2$. Choose $N$ large enough that the first two terms are less than $|2-x^2|$.) 
Then $x^2 \leq 2$ by preservation of nonstrict inequalities. But $x \in \mathbb{Q}$, so $x^2 \neq 2$, so $x^2 < 2$. Thus $f(x_n) \to f(x)$, so $f$ is continuous at $x$ Repeat for $x^2 > 2$.
A: $x + \epsilon$ is easier to work with than $x + \frac{2-x^2}{6}$.
Also, showing that $2 - (x+\epsilon)^2 \geq 0$ is easier than showing $(x+\epsilon)^2 \leq 2$.
But I do question the choice of $\epsilon$: I suspect Newton's method will give up a better choice of $\epsilon$. If we use Newton's method to approximate a root of the function $f(t) = t^2 - 2$, then given an approximation $x$ the next approximation is
$$ y = x - \frac{f(x)}{f'(x)} = x - \frac{x^2 - 2}{2x} $$
and as I recall, Newton's method for estimating a square root always gives underestimates. (If I'm remembering that wrongly, then what is correct is that it alternates overestimates and underestimates, and thus just run the algorithm twice) I've done this sort of exercise before, and $2-y^2$ just magically simplifies: specifically to $(2-x^2)^2$, if I remember correctly.
And so it's probably better to have chosen
$$ \frac{2-x^2}{2x} $$
so long as $x$ isn't too far away from $\sqrt{2}$. But now I see the motivation behind their choice of $\epsilon$. If we have
$$ 0 < x < 3$$
then we have
$$ \epsilon < \frac{2-x^2}{2x} $$
and presumably, the choice of $\epsilon$ also winds up working out for the case of $x \leq 0$ as well.
However, I find that this "simplification" really just makes the problem more complicated, and it's much better to simply split the domain into cases and use different choices of $\epsilon$ on each.
