# Measure of a function that maps rationals to $0$ and irrationals to $2^n$

Let $f$ be a function such that $f(x)=0$ for all $x \in \mathbb{Q}$, and $2^n$ for all $x \in \mathbb{R} \setminus \mathbb{Q}$ where $n$ is the number of zeros immediately after the decimal.

Show that this is measurable.

My first idea here was that since the irrationals are a $G_\delta$ set, they are measurable. There are countably many rationals in $[0,1]$, so that set is also measurable. I suppose this shows that $f$ is measurable.

-
A function that is measurable almost everywhere is... – The Chaz 2.0 Sep 29 '11 at 3:26
What you've said is not enough to establish measurability of $f$. You need to check that $f^{-1}(2^n)$ is measurable for each $n$. (Also, in the future it would be a good idea to make explicit your notion of measurability.) – user83827 Sep 29 '11 at 3:28
For Lebesgue measurability it suffices to show that $f^{-1}(m,\infty)$ is a Lebesgue measurable set for every $m$. You can easily show that, up to a set of measure $0$, it is a countable union of semi-open intervals and hence measurable. – Arturo Magidin Sep 29 '11 at 5:23
It looks to me as if the measure of any interval $[0,x]$ for any positive $x$ will be infinite. – Henry Sep 29 '11 at 7:15

For each positive integer $n$, let $x_n$ be the digit in the $n^\text{th}$ position after the decimal point in the decimal expansion of $x\in\mathbb R$. Then $x_n$ is a measurable function of $x$, because $x_n=\lfloor 10(10^{n-1}x-\lfloor 10^{n-1}x\rfloor)\rfloor$ is a combination of Borel measurable functions. Therefore each set $\{x\in\mathbb R:x_n=0\}$ and its complement $\{x\in\mathbb R:x_n\neq0\}$ is measurable. Note that for each nonnegative integer $n$, $f^{-1}\{2^n\}=(\mathbb R\setminus\mathbb Q)\cap \bigcap_{k=1}^{n}\{x\in\mathbb R:x_k=0\}\cap\{x\in\mathbb R:x_{n+1}\neq 0\}$ (with the convention that $\bigcap_{k=1}^0\text{stuff}=\mathbb R$). Therefore this set is measurable. For any $m\in\mathbb R$, $f^{-1}(m,\infty)$ is a countable union of such sets, or $\mathbb R$.

As Arturo notes in a comment, you can also describe $f^{-1}\{2^n\}$ as a countable union of open intervals with rationals removed, and this is another way to see that it is measurable. There was a somewhat similar question in which I gave a somewhat similar answer while Arturo again gave a more geometric approach.

-

First, notice that $f$ is well-defined because the numbers that have two different decimal expansions are all rationals.

Let $f_n(x) = 2^k$, where $k$ is the number of zeros from the first to the $n$-th position after the decimal. In order to avoid the ambiguity mentioned above, let's agree that no decimal expansion ends in an infinite sequence of $9$. That is, no expansion ends in $99999\dotsc$.

Then, $f_n$ is measurable. (Why? Hint: write it as a step function.)

Now, observe that $$I_{\mathbb{R} \setminus \mathbb{Q}} f_n \uparrow f,$$ where $I_{\mathbb{R} \setminus \mathbb{Q}}$ is $0$ at the rationals and $1$ at the irrationals. Therefore, $f$ is measurable.

Edit: fixed the definition of $f_n$.

-
I don't understand. For example, isn't it true that $f_7(2.030030003000030000030000030000003…)=5$, while $f(2.03…)=2$? – Jonas Meyer Dec 17 '11 at 7:06
@JonasMeyer: In my understanding, $f(2.03\ldots) = \infty$. But I see am missing the $2^n$ part... I will fix it. – André Caldas Dec 19 '11 at 15:51
Then we have a different reading of the problem. By "immediately", I thought it was implied that in $2.030030003\ldots$, for example, only that first $0$ counts. $2.32344003\cdots$ has zero $0$s immediately after the decimal point, $2.00000444440000404404000\ldots$ has four, etc. So every irrational number is sent to $2^n$ for some nonnegative $n$. $f(\pi)=2^0=1$, but $f(\pi-0.1)=2^1=2$. But now I understand your answer; we were just answering different questions. – Jonas Meyer Dec 19 '11 at 16:53
@JonasMeyer: You are right. I didn't pay attention to the "immediately". – André Caldas Dec 22 '11 at 1:07