TITLE: Real Analysis: Showing $f: \Bbb Q \to \Bbb Q$ is continuous
QUESTION [5 upvotes]: 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.

REPLY [3 votes]: 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.