# Continuous, Discontinuous, and Bounded Variation

Is there such a function that is continuous at every irrational, discontinuous at every rational, and is also of bounded variation on $$[0,1]$$? A candidate is Thomae’s Function,

$$f(x) = \begin{cases} \frac{1}{x} & x = \frac{p}{q}, \text{and gcd}(p,q) = 1, q > 0 \\ 0 & x \text{is irrational} \end{cases},$$

but it can be shown to be not of bounded variation since we end up with a series $$\sum_k^m \frac{1}{k}$$.

Let $$F(x)=\sum_{r_n \leq x} \frac 1 {2^{n}}$$ where $$(r_n)$$ is an ennumeration of rationals in $$[0,1]$$. (The sum is over all n such that $$r_n \leq x$$). Then $$F$$ has all the desired properties.

The answer by @KaviRamaMurthy is elegant and ingenious since his $$\ F\$$ is monotone (increasing) -- thus, while the construction of $$\ F\$$ is a bit involved, the proof is instant.

The following is perhaps more straightforward(?); I'll make it general so that it's even easier to see what's going on (altogether not too much):

Let $$\ A\subseteq X\subseteq\mathbb R,\$$ where $$\ X\setminus A\$$ is dense in $$\ X,\$$ and let $$\ g:A\rightarrow\mathbb R\setminus\{0\}\$$ be such that

$$s\ :=\ \sum_{a\in A}\,|g(a)|\ <\ \infty$$

(it follows that $$\ A\$$ is countable). Define $$\ G:X\rightarrow\mathbb R\$$ as the extension of $$\ g\$$ by $$\ 0,\$$ i.e. $$\ \forall_{x\in X\setminus A}\, G(x)=0.\$$

It follows that $$\ G\$$ is continuous at every $$\ x\in X\setminus A,\$$ and that the total variation is $$\ \le\ 2\cdot s$$.

Since $$\ X\setminus A\$$ is dense in $$\ X,\$$ function $$\ G\$$ is discontinuous at every $$\ a\in A.$$