Looking for an example of a bijective continuous function $f:\mathbb{Q} \to \mathbb{Q}$ such that $f(-1)=0$, $f(0)=1$ and $f(1)=-1$? Clearly such a function does not exist from $\mathbb{R}$ to itself, but apparently it does in $\mathbb{Q}$ and I don't see how it could... Can you give me an example and explain to me how you thought of this one?

Thank you very much!

I first simply thaugh of putting the values of $f$ at the three special values of $x$ and making it $f(x)=x$ everywhere else, or constant, but it doesn't work...
Define $f:\Bbb{Q} \to \Bbb{Q}$ by 

$$
f(x)=
\begin{cases}
x+1 &amp; \sqrt{2}-3 &lt; x &lt; \sqrt{2}-1 \\
x-2 &amp; \sqrt{2}-1 &lt; x &lt; \sqrt{2}\\
x &amp; \text{otherwise}
\end{cases}
$$

Then it's easily checked that $f$ assumes the desired values. Also, $f$ has an obvious extension to $\Bbb{R}$ whose only points of discontinuity are irrational; thus it is continuous on $\Bbb{Q}$.

To see that it's bijective, note that the function
$$
g(x)=
\begin{cases}
x+2 &amp; \sqrt{2}-3 &lt; x &lt; \sqrt{2}-2\\
x-1 &amp; \sqrt{2}-2 &lt; x &lt; \sqrt{2} \\
x &amp; \text{otherwise}
\end{cases}
$$
is its inverse.

Intuitively, $f$ is a function that swaps the order of some intervals in $\Bbb{Q}$. This sounds like a discontinuous operation, but by making the interval endpoints irrational, we can ensure that $\Bbb{Q}$ doesn't notice.
Set $f(x)=1-2x$ for $x\ge 0$ and $f(x) = 1+x+\sqrt{2} (x^2+x)$ for $x&lt;0$.