Show that the function $$f(x) \begin{cases} 1 & \text{if } x\in \mathbb{Q} \\ 0 & \text{if } x \not\in\mathbb{Q}\end{cases}$$ is not continuous anywhere in $\mathbb{R}$. Give reason(s) for your answer.

My Approach:

Between any two rational numbers, there exists infinitely many irrational numbers.

Also, between any two real numbers we know there exists a rational number. If we particularise this for two irrational numbers, we know that between any two irrational numbers, there exists a rational number.

Using the argument from above, we may deduce that the function $f$ results in an infinitely oscillating function between $0$ and $1$. Hence it cannot be continuous.

Does this reasoning make sense? Can anybody please provide me with a way to show this a bit more mathematically? Or provide me with a completely different approach?

  • 4
    $\begingroup$ What is your definition of "continuous"... something with $\epsilon$ and $\delta$? Use that. $\endgroup$ – GEdgar May 21 '15 at 20:51
  • $\begingroup$ @GEdgar - $f$ is continuous on a set $A$ provide that, for every $a \in A$, we have that for each real number $\epsilon>0$ there exists a real number $\delta >0$ such that $|f(x) - f(a)| < \epsilon$ whenever $||x-a||< \delta$. ... How can I use it in this case though? $\endgroup$ – user860374 May 21 '15 at 20:54
  • $\begingroup$ You don't want "continuous on a set" you want "continuous at a point". $\endgroup$ – GEdgar May 21 '15 at 20:57
  • $\begingroup$ @GEdgar - $f$ is continuous on at $a$ provided that for each real number $\epsilon>0$ there exists a real number $\delta >0$ such that $|f(x) - f(a)| < \epsilon$ whenever $||x-a||< \delta$. $\endgroup$ – user860374 May 21 '15 at 20:58

Pick a point $x \in \mathbb{R}$. Either $x$ is rational or irrational. Assume it is the latter, so $f(x) = 0$. Let $\epsilon = \frac{1}{2}$. Regardless of $\delta$, there will exist an irrational number $z$ such that $$|x - z| < \delta \ \ \text{but} \ \ |f(x) - f(z)| > \frac{1}{2}$$ where we have used the density of the reals and that $f(z) = 1$. So, this shows that $f$ is not continuous at $x$.

A similar approach works if $x$ is irrational. $\epsilon = \frac{1}{2}$ will work too.


Since $\mathbb{Q}$ is dense in $\mathbb{R}$, for every $x \in \mathbb{R}/\mathbb{Q}$ there exists a sequence $\{x_n\} \subset \mathbb{Q}$ of rational numbers such that $ x_n\rightarrow x$ and you have: $$ \lim_{n \rightarrow \infty}f(x_n)= 1 $$ but $f(x)=0$

  • $\begingroup$ I love this approach! :D. Thank you! $\endgroup$ – user860374 May 21 '15 at 20:59
  • $\begingroup$ Of course, first you have to show that continuity is equivalent to something about sequences. $\endgroup$ – GEdgar May 21 '15 at 21:01
  • $\begingroup$ @GEdgar - we have that theorem in the book later on :). So should be fine to use this :) $\endgroup$ – user860374 May 21 '15 at 21:03
  • 2
    $\begingroup$ Maybe the problem is supposed to help you learn to use the $\epsilon, \delta$ definition of "continuous"? $\endgroup$ – GEdgar May 21 '15 at 21:04

Your idea is fairly sound but you would get little or no credit on an exam for your answer.

If the $f(x)$ is continuous at some point $x=x_0$ then (by definition) for any given $\epsilon > 0$ you can find a $\delta > 0$ such that whenever $x-\delta < x < x+\delta$, $|f(x)-f(x_0) < \epsilon$.

In particular, at any irrational point $x_0$ (so that $f(x_0=0$suppose there exists such a $\delta$ that works for $\epsilon = \frac12$. Then choose as a denominator any integer $d$ greater than $\frac{2}{\delta}$. The interval $(x_0-\delta,x_0+\delta)$ contains at least one fraction with denominator $d$ therefore at that rational number $n/d$, $f(n/d) - f(x_0) = 1 > \epsilon$. Yet $n/d$ is in the $\delta$-neighborhood of $x_0$ for that $\delta$, so that $\delta$ cannot work in the definition. Since no $\delta$ can work, the definition is not satisfied.

You need to complete the proof by assuming that $x_0$ is rational; here, using the theorem about irrational numbers lying between any two rationals might be an easy way to do this step.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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