Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|cite|improve this question
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.

share|cite|improve this answer
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}$$

share|cite|improve this answer
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.

share|cite|improve this answer
Somebody downvoted this answer. Why? – Grumpy 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

You could use the Dirichlet function extended to the real line: $$f(x)=\begin{cases} 1 \text{ if } x \in \mathbb{Q}\\ 0 \text{ if } x \not\in \mathbb{Q} \end{cases}$$

Or for something more fun:

$$f(x)=\begin{cases}x \text{ if } x \in \mathbb{Q}\\ 0 \text{ if } x \not\in \mathbb{Q} \end{cases}$$

share|cite|improve this answer
Hi @emka, I've become curious about one thing. Intuitively, if $g: \mathbb{R} \to \mathbb{R}$ is continuous and if we take $f(x) = g(x)$ when $x \notin \mathbb{Q}$ and $f(x) = g(x) + k$ when $x \in \mathbb{Q}$ for $k \neq 0$ then this $f$ will do the job. Is this correct? – user1620696 May 9 '13 at 15:23
I'm a little confused, isn't it true that the first function is also discontinuous at the irrationals, and the second one is discontinuous everywhere but at zero? – Tom Oldfield May 9 '13 at 15:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.