# example of a function $f :\mathbb{R} \to \mathbb{R}$ whose set of points of discontinuity is $\mathbb{Q}$

I need an example of a function $f :\mathbb{R} \to \mathbb{R}$ whose set of points of discontinuity is $\mathbb{Q}$.

• What are you thoughts on this? – Alex Provost May 9 '13 at 15:20

Enumerate the rationals, $q_n$. Now consider:

$$\Large f(x)=\sum_{q_n<x}\frac1{2^n}$$

I am leaving you with the details of proving this function satisfies the conditions you ask for.

• I'm confused about the downvote. – Asaf Karagila May 9 '13 at 15:38
• Additionally, it's bounded, monotone and every discontinuity is a jump discontinuity. – kahen May 9 '13 at 16:04

Another alternative, known as Thomae's function, sometimes the (modified) Dirichlet function: $$f(x)=\begin{cases}0&\text{if x\notin\mathbb{Q}}\\ 1/q&\text{if x=p/q with p, q integers with \gcd(p,q)=1 and q>0}\end{cases}$$

• I think you're confusing your terms. The Dirichlet function usually refers to the indicator function of the rationals (over the reals). What you have there is Thomae's function. – kahen May 9 '13 at 16:02
• @kahen: I did say sometimes … Wolfram MathWorld agrees that it is sometimes called that. It is the name I learned for it; the wikipedia page you refer to says it is sometimes known as the modified Dirichlet function, so there is ample room for confusion. But I'll update my answer anyhow to bring it in line with what seems to be accepted terminology. – Harald Hanche-Olsen May 9 '13 at 16:23

As in Asaf's answer, enumerate the rationals to get $q_n$. Define $f(q_n)=1/n$ and $f(x)=0$ for irrationals.

• Somebody downvoted this answer. Why? – Cheerful Parsnip May 9 '13 at 18:29
• Perhaps they wanted to be in sync with the downvote on my answer? :-) – Asaf Karagila May 10 '13 at 0:30