# Prove that the function below is discontinuous everywhere except at $x = 0$

$f(x)=\begin{cases}0, \; x \notin \mathbb{Q} \\ x , \; x \in \mathbb{Q} \end{cases}$

I tried doing this proof through the epsilon delta definition using density of the rationals.

This is as far as I got:

Let $a \in \mathbb{R} , a \neq 0$ suppose $a \in \mathbb{Q}$ Let $\delta > 0$ by the densitiy of the irrationals there exists $x \notin \mathbb{Q}$ such that $|x - a| < \delta$ then $f(x) = 0$ therefore $|f(a) - f(x)| = |f(a)| = |a|$

I'm not sure what to do from this point

• Use the fact that continuity preserves limits. May 19, 2017 at 2:58

Let $a \in \mathbb{Q}$, $a \not = 0$ and select $\epsilon = \dfrac {|a|}{2}$. In order for the limit to exist, there must exist a $\delta$ such that $|f(x) - f(a)| < \dfrac {|a|}{2}$ whenever $x \in (a- \delta, a+\delta) - \{a\}$. Because of the density of irrationals, for any $\delta$ there exists an irrational $x_0$ such that $x_0 \in (a- \delta, a+\delta) - \{a\}$. But this implies that $|f(x_0) - f(a)| < \dfrac {|a|}{2} \implies |0-a| < \dfrac{|a|}{2}$, which is false.

The graph of $f$ is the blue line and the red line (with gaps in the of course). We can see that for any $a$, if we can find $\epsilon$ small enough so that the blue line is outside of $(f(a)-\epsilon, f(a) + \epsilon)$, we could show that there's no $\delta$ which satisfies the required proprety.

If $a=2$, we could pick any $\epsilon$ smaller than $2$, such as $1.5$. But we needed to find an $\epsilon$ that would work no matter what $a$ is, and $\dfrac a2$ does the work. But you need to keep in mind that $a$ could be negative; since $\epsilon>0$, we had to throw in the absolute value.

• Thank you for your response So would this be a proof by contradiction then or would we show that $|f(x_0) - f(a)| < \frac{|a|}{2} = \epsilon$ therefore the function diverges May 19, 2017 at 3:23
• It depends on how you write the proof but for example a very similar answer of mine doesn't use proof by contradiction, it uses proof by negation, which is not equivalent to excluded middle. May 19, 2017 at 3:27
• First we assume that the function is continous at $a$, which means that $\displaystyle \lim_{x \to a} f(x) = f(a)$. If this is true, then for every $\epsilon$ there must exist a $\delta$ such that $|f(x) - f(a)| < \epsilon$ whenever $0 < |x-a| < \delta$. But we showed that there exists an $\epsilon$ such that no $\delta$ will satisfy the above proprety. I will add a picture momentarily.
– Ovi
May 19, 2017 at 3:28

Hint:

If $x$ is irrational then by density of rationals there is a sequence of rationals $(x_n)$ converging to $x$ such that

$$x = \lim_n x_n =\lim_n f(x_n) \neq f(x) = 0.$$

Now consider rational $x \neq 0$.

• Thank you for your answer So I would have to define a sequence that is always rational but converges to something irrational May 19, 2017 at 3:02
• That's what I showed you. The part I left for you is to produce a sequence of irrationals that converges to rational $x \neq 0$ and see what happens. You already mentioned density which enables us to produce such sequences.
– RRL
May 19, 2017 at 3:05
• So I would have to find an explicit example of such a sequence like e or some other sequence May 19, 2017 at 3:07
• If $x$ is irrational, then any interval $(x, x+ 1/n)$ contains a rational $x_n$. That means $x_n \to x$.
– RRL
May 19, 2017 at 3:09
• Oh I see so use that interval to show that the sequence converges to x by bounding $/epsilon$ it using the Archimedean property May 19, 2017 at 3:12

Let $x$ be a real number. Then by the density of rational numbers there exists a sequence $\{x_{n} \}$ of rational numbers converging to $x$. But if $f$ is continuous then we have $f(x_{n}) \to f(x)$. But then $f$ would be identically zero, which is a contradiction.

For continuity at the origin, let $\epsilon>0$ be given. Then we claim that if $|x| < \epsilon$, then $|f(x) - f(0)| =|f(x)| < \epsilon$. Indeed, if $x$ is rational, then $|f(x)| = 0 < \epsilon$ and if $x$ is irrational, then $|f(x)| = |x| < \epsilon$.

If $a$ is irrational, then by density of the rationals, there is some sequence $r_n\to a$ with $r_n$ rational for every $n$. By our definition of $f$, $|f(a) - f(r_n)| \ge \eta$ for some $\eta>0$ and all $n$, so $f$ is not continuous at $a$.

If $a$ is rational, then by the density of the irrationals, there is a sequence $\alpha_n\to a$ with $\alpha_n$ irrational for every $n$. By our definition of $f$, $|f(a) - f(\alpha_n)| \ge \eta'>0$ for some $\eta'$ and all $n$, so $f$ is not continuous at $a$.

• Thank you so much for your answer you hit the nail right on the head this is how I was trying to complete the proof but I couldn't figure out what to use to bound epsilon using delta May 19, 2017 at 3:16

Let $x \in \mathbb{R}$ and $x \neq 0$. We want to show that $f$ is not continuous at $x$. So we want to find an $\epsilon > 0$ such that for all $\delta > 0$ the following condition is not satisfied: $$\forall x' \in \mathbb{R} \text{,} \ (|x-x'| < \delta \implies |f(x)-f(x')| < \epsilon)$$

So, if $x \in \mathbb{Q}$, you can choose $\epsilon = |x/2|$ because it doesn't matter how small you choose $\delta$, there will be always a irrational $x'$ in that interval and then $|f(x)-f(x')| = |x|$ which is always greater then $\epsilon$. Other case is similar.

And for continuity at $0$, you don't actually need the density of $\mathbb Q$, just choose $\delta$ as $\epsilon$.

• Thank you so much for your answer that is exactly what I was looking for I couldn't determine how exactly to bound epsilon May 19, 2017 at 3:15

To complement the other answers for anyone who is curious, here is a proof using nonstandard analysis. (Note: $x \approx y$ means $x - y$ is infinitesimal.)

First, for any $\epsilon \approx 0$, note that $f(\epsilon)$ is either $0$ or $\epsilon$ -- either way $f(\epsilon) \approx 0 = f(0)$ , which shows that $f$ is continuous at $0$.

Next let $a \ne 0$ be real. To show $f$ is not continuous at $a$ we need to show that there exists $a' \approx a$ such that $f(a') \not \approx f(a)$. Since between two reals there is always a rational and irrational value, between any two hyperreals there is a hyperrational and hyperirrational value. So take $a'$ to be hyper-rational if $a$ is irrational, and hyper-irrational if $a$ is rational. In the former case, $f(a') = a' \not \approx 0 = f(a)$. In the latter case, $f(a') = 0 \not \approx a = f(a)$.