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...
 A: Define $f:\Bbb{Q} \to \Bbb{Q}$ by 
$$
f(x)=
\begin{cases}
x+1 & \sqrt{2}-3 < x < \sqrt{2}-1 \\
x-2 & \sqrt{2}-1 < x < \sqrt{2}\\
x & \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 & \sqrt{2}-3 < x < \sqrt{2}-2\\
x-1 & \sqrt{2}-2 < x < \sqrt{2} \\
x & \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.
A: Here are two key facts:


*

*If $X$ is countable, linearly ordered, has no first and last element,  and is dense in itself, then $X$ is order isomorphic to $\mathbb{Q}$.

*If $X$ is order isomorphic to $\mathbb{Q}$ and the topology is generated by open sets of the form $(x_1, x_2) = \{x_i: x_1 < x_i < x_2\}$, then an order isomorphism is automatically a homeomorphism.
Now, partition $\mathbb{Q}$ into several parts in the following fashion.  First, we assume all fractions are listed in lowest terms.  Let $\mathbb{Q} = A_2 \cup A_3\cup A_0$ where $A_2$ consists of all fractions whose denominator is a positive power of $2$, $A_3$ is all fractions whose denominator is a positive power of $3$, and $A_0$ is everything else.
It is clear that each $A_i$ satsifies the hypotheses of $1$, so they are all order isomorphic to $\mathbb{Q}$.  Also, if we reverse the order of any $A_i$, it's still order isomorphic to $\mathbb{Q}$.  Further, the union of any two of the $A_i$ is also order isomorphic to $\mathbb{Q}$.  Let's keep going:  Any cofinite subset of $\mathbb{Q}$, or any open set of $\mathbb{Q}$ of the form $\mathbb{Q}\cap (a,b)$ is order isomorphic (and therefore homeomorphic) to $\mathbb{Q}$.
Here's the idea of the construction:  Draw a zig zaggy piecewise- linear looking thing which is asymptotically $-x$, and goes through the $3$ desired points.  Of course, this picture fails to be injective, even when restricted to $\mathbb{Q}$.  To fix it, we modify the function appropriately so that on each zig or zag, it's only surjective onto a piece of either $A_0$, $A_2$, or $A_3$, but in such a way that it's still surjective over all.
Now, the details.  First, if $x < -2$ or $x > 3$, we declare $g(x) = -x$.  If $-2< x < -1$, we pick an anti-isomorphism $\phi_0$ between $\mathbb{Q}\cap (-2,-1)$ and $A_0\cap(0,1)$ and declare $g(x) = \phi_0(x)$.  (Anti-isomorphism means $\phi_0$ reverses order.)
If $-1< x< 0$, pick an isomorphism $\phi_1$ between $\mathbb{Q}\cap (-1,0)$ and $A_2\cap(0,1)$.  Define $g(x) = \phi_1(x)$.
If $0<x<1$, pick an anti-isomorphism $\phi_2$ between $\mathbb{Q}\cap(0,1)$ and $A_3\cap (-1,1)$.  Define $g(x) = \phi_2(x)$.
If $1< x < 2$, use an isomorphism between $\mathbb{Q}\cap (1,2)$ and $A_2\cap(-1,0)$.
If $2<x<3$, use an anti-isomorphism between $\mathbb{Q}\cap(2,3)$ and $A_0\cap(-1,0)$.
Finally, define $g(-1) = 0$, $g(0) = 1$, and $g(1) = -1$.
This $g$ almost works.  It satisfies $g(-1) = 0$, etc, by definition, and it's also a homeomorphism from its domain to $\mathbb{Q}$.  The only issue is that the domain isn't all of $\mathbb{Q}$ because $g$ hassn't been defined at $-2$, $2$, or at $3$.
So, pick an isomorphism $\psi:\mathbb{Q}\rightarrow \mathbb{Q}\setminus\{-2,2,3\}$ with $\psi(-1) = -1$, $\psi(0) = 0$, and $\psi(1) = 1$.  This can be done since the sets $\mathbb{Q}\cap(-\infty,-1)$ and $\mathbb{Q}\cap(-\infty,-1)\setminus\{-2\}$ are both order isomorphic to $\mathbb{Q}$.
Now, set $f = g\circ \psi$.  This is a composition of homeomorphisms, so is a homeomorphism.  Further, $f(-1) = g(\psi(-1)) = g(-1) = 0$, and similarly for the other two points.
A: Let's see what we can find in the interval $[-1,1]$. Everywhere else we can take the identity map.
Consider the complex plane.
Now, you can take all the rationals in $[-1,0]$ let's say $\{q_1,q_2,...\}$ and map them to the rationals in $[0,1]$ let's say $\{q^*_1,q^*_2,...\}$ on the $y$ -axis, constructing isosceles orthogonal triangle. What i mean is: $q_n\to q_n\cdot (-i)$. Do the same with the rationals of $[0,1]$ and map them to the rationals of $[-1,0]$ of the $y$ -axis.
Of course this is bijection. Check the continuity. What we have done is to contruct a function from the rational of the $z$ -axis to the rationals of the $y$ -axis. Topologically is the same to contruct a function from $x$-axis to $x$-axis.
A: Set $f(x)=1-2x$ for $x\ge 0$ and $f(x) = 1+x+\sqrt{2} (x^2+x)$ for $x<0$.
A: I would consider the third degree polynomial :
P(x) = (X+1)*( $X^2 +b*X +c)$ let's see if we can find b and c rationals that verify your three conditions.
f(-1) = 0 (surprise ) 
f(0) = 1 = c
f(1) = -1 = 2*(1+ b + 1) => b= $\frac{-5}{2} $ 
What do you think?
