# Proving a function is continuous on all irrational numbers

Let $\langle r_n\rangle$ be an enumeration of the set $\mathbb Q$ of rational numbers such that $r_n \neq r_m\,$ if $\,n\neq m.$ $$\text{Define}\; f: \mathbb R \to \mathbb R\;\text{by}\;\displaystyle f(x) = \sum_{r_n \leq x} 1/2^n,\;x\in \mathbb R.$$ Prove that $f$ is continuous at each point of $\mathbb Q^c$ and discontinuous at each point of $\mathbb Q$.

I find this question very challenging and have no idea even how to start off with the proof. Please suggest a proof or any hint.

• A simple hint: can you show that if $x_0\in\mathbb{Q}$, then $\lim_{x\to x_0^-}f(x)$ exists and is $\neq f(x_0)$? – Steven Stadnicki Jun 15 '13 at 16:20
• You may find this paper interesting: arxiv.org/pdf/0901.2360v1.pdf (see Example 1) – Erel Segal-Halevi Jun 17 '13 at 20:48

I use the notation $$\lim_{y\to x^{+}}f(y)=f(x^+)$$ $$\lim_{y\to x^{-}}f(y)=f(x^-)$$

There is a very nice way of constructing, given a sequence $\{x_n\}$ of real numbers, a function which is continuous everywhere except the elements of $\{x_n\}$ [That is, discontinuous on a countable set $A\in\Bbb R$]. Let $\{c_n\}$ by any nonnegative summable sequence [that is $\sum\limits_{n\geq 0} c_n$ exists finitely], and let $$s(x)=\sum_{x_n<x} c_n$$

What we do is sum through the indices that satisfy the said inequality. Because of absolute convergence, order is irrelevant. The function is monotone increasing because the terms are nonnegative, and $s$ is discontinuous at each $x_n$ because $$s(x_n^+)-s(x_n^-)=c_n$$

However, it is continuous at any other $x$: see xzyzyz's proof with the particular case $c_n=n^{-2}$. In fact, this function is lower continous, in the sense $\lim\limits_{y\to x^{-}}f(y)=f(x^-)=f(x)$ for any value of $x$. If we had used $x_n\leq x$, it would be upper continuous, but still discontinuous at the $x_n$.

To see the function has the said jumps, note that for $h>0$, we have \begin{align} s(x_n^+)-s(x_n^-)&=\\ \lim_{h\to 0^+} s(x_k+h)-s(x_k-h)&=\lim_{h\to 0^+}\sum_{x_n<x_k+h} c_n-\sum_{x_n<x_k-h}c_n\\&=\lim_{h\to 0^+}\sum_{x_k-h\leq x_n<x_k+h} c_n\end{align}

and we can take $\delta$ so small that whenever $0<h<\delta$, for any given $x_m\neq x_k$, $x_m\notin [x_k-\delta,x_k+\delta)$, so the only term that will remain will be $c_k$, as desired.

• Dear Pedro, would such a function be $0$ at a point $x$ where $x< x_{k}$ for all the elements of the sequence? Also, would you know how one would go about showing whether are not such function is differentiable at the points outside the sequence? – user135520 Nov 19 '15 at 19:36

Here's an easy reason why this is true: look at the interval from 0 to 1. there are only finitely many fractions with a given base between 0 and 1. There is only one with base 2, (I.e, 1/2), two with base 3, etc. so as you approach any irrational number by a sequence , that sequence is going to run out of all the fractions with small bases.

The same thing is true as you approach any rational number; so in either case, the limit as you approach a number is 0. Since that agrees with the function for irrationals, it's continuous there. Since it disagrees at a rational, it's discontinuous.