Continuous function from Q to Q

#math #problem


Find a continuous function $f \colon \mathbb{Q} \to \mathbb{Q}$ that satisfies $f(f(q)) = -q$ for all $q \in \mathbb{Q}$.


This cute problem was posed to me by Z-module from the Libera IRC network. This problem exemplifies how continuity could end up being wonky in domains that aren’t as nice as $\mathbb{R}$; a function like $f$ does not exist if the domain is changed from $\mathbb{Q}$ to $\mathbb{R}$. If you want to solve it yourself, you should stop reading here! Here are two hints:

  • Hint 1: First try constructing a continuous function $h \colon \mathbb{Q} \setminus \{0\} \to \mathbb{Q} \setminus \{0\}$ that satisfies $h(h(q)) = -q$ for all $q \in \mathbb{Q} \setminus\{0\}$.
  • Hint 2: If you’ve constructed $h$, then the problem is extending the domain to include $0$. Think of the sequence $(\pi, \pi/2, \pi/4, \pi/8, \dots)$.

Solution

We shall first construct $h$ from the first hint, and then extend the domain to include $0$, thus constructing $f$. Let $A = (0, a) \cap \mathbb{Q}$ where $a > 0$, and let $B = \mathbb{Q}_{>0} \setminus A $. Let $-A = \{-q \mid q \in A \} $ and $-B = \{-q \mid q \in B\} $. We shall construct $h$ in such a way that

$$ \begin{align*} h[A] &= B \,, \\ h[B] &= -A \,, \\ h[-A] &= -B \quad \text{and}\\ h[-B] &= A \,. \end{align*} $$

Note that $h$ has to be bijective since $h^2$ is bijective. It is easy to find a $h$ that is piecewise continuous over $A, -A, B, -B$. The issue is the jump discontinuities that may arise at the boundary points of the intervals. However, by making $a$ an irrational number, we can have a jump in $h$ as it passes from one interval to the next.

To make this point clearer, let us take $a = \pi$, which gives $A = (0, \pi) \cap \mathbb{Q}$ and $B = (\pi , \infty) \cap \mathbb{Q}$. We now construct a function $h$ that is continuous over $A$ and $B$. Recall that the definition of continuity requires only that $\lim_{q \to c}h(q) = h(c)$ for any $c \in \mathbb{Q} \setminus \{0\}$. By picking $a = \pi$, we remove the jump discontinuity at the boundary point of $A$ and $B$ by simply removing the boundary point itself from the domain. Note that we can also have a jump at $0$ since $0$ does not belong to the domain of $h$.

Now, to extend this idea to construct $f$, we need to find a way to remove the jump at $0$. Let us consider another way to create $h$ where instead of just having one collection of sets defined by $a = \pi$, we have two such collections of sets: let $A_2 = (0, \pi/4) \cap \mathbb{Q}$, $B_2 = (\pi/4, \pi/2) \cap \mathbb{Q}$, $A_1 = (\pi/2, \pi) \cap \mathbb{Q}$, and $B_1 = (\pi, \infty) \cap \mathbb{Q}$. We map sets to their images in a similar way as for the previous case, so we have

$$ \begin{align*} h[A_2] &= B_2 \,, \\ h[B_2] &= - A_2 \,, \\ h[-A_2] &= - B_2 \quad \text{and}\\ h[-B_2] &= A_2 \,, \end{align*} $$

and similarly for $A_1$ and $B_1$ where $- C_i := \{ -q \mid q \in C_i\}$ for any $C_i \in \{A_1, A_2, B_1, B_2\}$. See the image below for a visualization.

Observe that by modifying the construction of $h$ in this way, we have brought down the length of the jump at $0$ from $2\pi$ to $\pi/2$. We may repeat this process infinitely many times, taking smaller and smaller collections of sets near zero, scaling successive interval sizes by a factor of $1/2$ so that the jump-length approaches $0$. Finally, mapping $0$ to itself will give us $f$.

To be precise, we define $f \colon \mathbb{Q} \to \mathbb{Q}$ in the following way. First we set $f(0) = 0$. For each $i \in \mathbb{Z}$, define $C_i = \left(\pi/2^{i}, \pi/2^{i-1} \right) \cap \mathbb{Q}$. Now, for each even $i$, we make $f$ induce the following set mappings:

$$ \begin{align*} f[C_i] &= C_{i-1} \,, \\ f[C_{i-1}] &= - C_i \,, \\ f[-C_i] &= - C_{i-1} \quad \text{and}\\ f[- C_{i-1}] &= C_i \,. \end{align*} $$

To explicitly construct these set mappings, we define $f$ piecewise. For each even integer $i \in \mathbb{Z}$, the function is defined as

$$ f(q) = \begin{cases} 2q & \text{if } q \in C_i \\ -q/2 & \text{if } q \in C_{i-1} \\ 2q & \text{if } q \in -C_i \\ -q/2 & \text{if } q \in -C_{i-1} \end{cases} \,. $$

This is the same as

$$ f(q) = \begin{cases} 2q & \text{if } q \in C_i \cup -C_i \text{ for some even } i \in \mathbb{Z} \\ -q/2 & \text{if } q \in C_i \cup -C_i \text{ for some odd } i \in \mathbb{Z} \\ 0 & \text{if } q = 0 \end{cases} \,. $$

Note that $f$ is continuous and that $f(f(q)) = -q$ for all $q \in \mathbb{Q}$.