# Construct a one-to-one function $f: I\times I \to I$ (the unit square to $[0,1]$)

Let $I$ be the set of decimals of the form $0.d_1 d_2 d_3 \cdots$, where $d_i \in \{0, 1, 2, \cdots, 8, 9\}$. Then, $I$ is the interval $[0,1]$ (if $d_1 = d_2 = \cdots = 0$ we have the origin, if $d_1 = d_2 = \cdots = 9$ we have $0.\bar{9} = 1$). Construct a one-to-one function from $I\times I$ to $I$.

Definition of a one-to-one function $f: I \times I \to I$: $$\forall x \in I\times I, \quad \forall y \in I \times I \quad \left( x \ne y \implies f(x) \ne f(y) \right).$$

First attempt: vertical drop

Let $a = (a_1,a_2)$ be an ordered pair in $I \times I$. That is, $I\times I = \{ a = (a_1,a_2) : a_1,a_2 \in I \}$. Then let $f(a) = f(a_1,a_2) = a_1$. I.e., $f$ drops the point vertically down to the real line. But for $a = (a_1,a_2), a' = (a_1, a_3), a_2\ne a_3$, we have $a\ne a'$ but $f(a) = f(a')$, so this function does not work.

Second attempt: Euclidean distance from origin.

Let $f(a) = \sqrt{a_1^2 + a_2^2}$. Actually this fails because the largest radius in the unit square is $\sqrt{2} > 1$.

Third attempt: take the average of $a_1, a_2$.

Let $f(a) = (a_1+a_2)/2$. But if $a' = (a_2,a_1)$ then $f(a) = f(a')$.

Fourth attempt: some violently oscillating sine function.

Let $f(a) = 1/2 + 1/2 \sin(\cdot)$. I'm not sure what the argument of $\sin$ should be. The halves are there to translate and re-scale the $\sin$ function.

• I'm not sure how much topology you've done, but using a connectedness argument it is easy to see that the map your looking for cannot be continuous. – Zestylemonzi Jul 14 '16 at 7:43
• I don't think the OP wants a continuous function. – R_D Jul 14 '16 at 7:45
• The book I got this question out of Introduction to real analysis, by Schramm, is quite vague. There is no (explicit) demand for a continuous function, so a non-continuous one should do just fine. In fact, the author has defined some functions with words only and no formulae, so even a construction in words would be good. It's just bothering me that I can't think of one... – jamesh625 Jul 14 '16 at 7:51
• It's not obvious what you mean by 'Let $I$ be the set of decimals of the form $0.d_1 d_2 d_3 \cdots$, where $d_i \in \{0, 1, 2, \cdots, 8, 9\}$.' It seems to define $I$ as a set of decimal representations of numbers, so $I$ would contain e.g. $0.1\overline0$ and $0.0\overline9$ as two distinct elements. OTOH you later say '$I$ is the interval $[0,1]$' which implies it contains only one instance of $\frac 1{10} = 0.1\overline0 = 0.0\overline9$. So, is $I$ a set of decimals (strings of digits, representing the numbers) or a (sub)set of real numbers themselves? – CiaPan Jul 14 '16 at 8:28
• @CiaPan I agree the question is vague. Maybe I should say that the book does not say anything more than that first thing you quoted. I think it was introduced earlier that $0.1 = 0.0\bar{9}$, so presumably $0.1\bar{0}$ and $0.0\bar{9}$ should be treated as the same element. In addition, the author has a footnote saying "This exercise can be interpreted as saying that the cardinality of the inside of the square ($I\times I$) is the same as that of an interval on the number line ($I$)". – jamesh625 Jul 14 '16 at 8:41

One way is to 'knit' the decimal expansions of your $2$ points in $I \times I$ together. Let $a=0.a_1a_2a_3......$ and $b=0.b_1b_2b_3.....$ then define $$f(a,b) = 0.a_1b_1a_2b_2........$$
I'll leave the details to you because you have to be careful about using the reduced decimal expansion for the points in $I \times I$ (i.e for example $0.1 = 0.099999999....$). Now injectivity follows from uniqueness of the reduced decimal expansion! Hope this helps.
• I should mention that you need to string a load of zeros on the end of your numbers in $I \times I$ if they have a finite decimal expansion. i.e treat one half as 0.5000000000..... – Zestylemonzi Jul 14 '16 at 8:09
• @jamesh625 Such function can't be continuous, so you won't see an explicit formula... +1 for ths answer. The detail left by Zestylemonzi is: avoid representation with recurring 9, then take for interleaving all contiguous nines together with following non-9 digit as a unit or every single non-9 digit if not preceded by 9. Additionally, dropping recurring 9 will exclude $1=0.\overline9$ from $I$, so you'll have to add a simple transformation $[0,1]\to[0,1)$ before interleaving digits and $[0,1)\to[0,1]$ after that. – CiaPan Jul 14 '16 at 9:00
• @jamesh625 ..and after applying all the tricks I described above you'll have a function, which is not just an injection, but also a surjection, that is you have a bijection $I\times I\to I$. – CiaPan Jul 14 '16 at 9:38
• @jamesh625 Here's an example of interleaving glued nines: $(0.\color{red}{91}2\color{red}{93}4, 0.78\color{green}{996}) \mapsto 0.\color{red}{91}728\color{red}{93}\color{green}{996}4$ – CiaPan Jul 14 '16 at 9:53
• @jamesh625 By forbidding the recurring nines we avoid the problem with ambiguity $(0,0.0\overline 9)\mapsto 0.00\overline{09}$ and $(0,0.1)\mapsto 0.01$. By gluing nines we make the reverse transformation to avoid recurring nines, hence be injective: $0.23\overline{90}$ will properly map to $(0.2\overline{90},0.3\overline{90})$ instead of $(0.2\overline 9,0.3)=(0.3,0.3)$, which is an image of $0.33$. – CiaPan Jul 14 '16 at 14:36