Thomae's function,

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

is an example of a function from $(0,1)\to [0,1]$ which is continuous at the irrationals and discontinuous at the rationals.

I was wondering: is there a two-dimensional analogue of this? Namely, can we construct a function from $[0,1]^2\to [0,1]^2$ which is discontinuous at points with rational coordinates and continuous elsewhere?

  • 3
    $\begingroup$ Just a wild guess but how about $$ f(x,y)= \begin{cases} (0,0) & \text{$x$ is irrational or $y$ is irrational}\\ (\frac{1}{p},\frac{1}{r}) & \text{$x = \frac{p}{q},y = \frac{r}{s}$ where $\gcd(p,q) = 1,\gcd(r,s)=1$} \end{cases}, $$ $\endgroup$
    – kingW3
    Commented Aug 15, 2015 at 13:41
  • $\begingroup$ @kingW3 I guess for the x,y both rational case the y coordinate should be $1/s$ rather than $1/r$? $\endgroup$
    – Vim
    Commented Aug 15, 2015 at 15:46

1 Answer 1


If your "rational coordinates" means $x,y$ both being rational, namely, that $(x,y)\in\Bbb Q^2$, then @kingW3's example won't satisfy your "continuous elsewhere".

Take the point $(\sqrt2/2,1/2)$ as an example, it is not in $\Bbb Q^2$, and the $f(x,y)$ so defined in @kingW3's comment is not continuous at this point. To see the discontinuity, you may just fix $y=1/2$, and let $x\to\sqrt2/2$, then you will of course find that, however small an $x-$neighborhood $(-\delta+\sqrt2/2,\delta+\sqrt2/2)$ you confine your $x$ to, there are both infinitely many rational $x$s and infinitely many irrational $x$s in it. When you hit a rational $x=q/p$, $f(x,y)=(1/p,1/2)$ (assuming $\delta$ to be small enough, $1/p$ will be extremely small); and when you hit an irrational one, $f(x,y)=(0,0)$, hence the discontinuity.

To answer your question, consider this modified version $$ f(x,y)= \begin{cases} (0,0) &x,y\text{ both irrational}\\ (\frac1p,0) &x=\frac{p}{q}\, \text{in the lowest term},\,y \,\text{irrational}\\ (0,\frac1r) &x\,\text{irrational},\,y=\frac{s}{r}\,\text{in the lowest term}\\ (\frac1p,\frac1r) &x=\frac{q}{p},y=\frac{s}{r}\,\text{in the lowest term} \end{cases} $$

The reasoning is simple and similar to that of the Riemann-Thomaes function you mentioned in your post.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .