Calculus – Why This Function is Continuous Unlike Dirichlet Function

analysiscalculus

My teacher showed us this function and told us it was continuous at all non-$\mathbb{Q}$ points:

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

However, Wolfram MathWorld says the Dirichlet function, which is very similar, is discontinuous at all points. Why is one continuous and the other not?

Best Answer

As other answers have Henning's answer has explained already, your teacher is wrong. However, my guess is that s/he was confusing your function with this related one: $$ f(x) = \begin{cases} 0, &\text{ if $x$ is irrational}, \\\\ 1/b, &\text{ if $x = a/b$ with $\gcd(a,b)=1$}. \end{cases} $$ This function does have the property that it is continuous at all irrational points, and discontinuous at the rationals.

Source: Look at the "modified Dirichlet function" $D_M(x)$ in the Mathworld article on the Dirichlet function.

Edit: It turns out that @lhf posted the same answer independently, but he links to the Wikipedia page of the function: click here.

Terminology: I just learned1 that this function is usually called Thomae's function, and not the modified Dirichlet function. I have known this example for some time, but not by any specific name. Wikipedia lists a number of other interesting names as well: the Riemann function, the popcorn function, the Stars over Babylon, the raindrop function, and the ruler function.


1In the post what functions or classes of functions are Riemann non-integrable but Lebesgue integrable, Hans Lundmark's comment (under Jonas Meyer's answer) gives the name of the function and the wikipedia link. Thanks to Theo Buehler for sharing the post.

Related Question