# Prove that the function $f : \Bbb R \to \Bbb R$ is continuous at $x = 0$ and discontinuous at every $x \ne 0$.

Prove that the function $f : \Bbb R \to \Bbb R$ defined by

$f(x) = \begin{cases} 0 &\text{if$x$is rational} \\ x &\text{if$x$is irrational} \end{cases}$

is continuous at $x = 0$ and discontinuous at every $x \ne 0$.

I'm having trouble with this. Can somebody provide an example of a function that is continuous at every $x \ne 0$ and discontinuous at $x = 0$? I'm wondering if a contradiction would work.

• Try to do it in steps. First, try to show that it is continuous at $x=0$. $\epsilon$-$\delta$ does a good job here. – Fimpellizieri Apr 4 '18 at 14:58
• What do you mean with “at every $x=0$”? – José Carlos Santos Apr 4 '18 at 15:02
• @JoséCarlosSantos typo, excuse me. Corrected. – c87 Apr 4 '18 at 15:03
• Have you had previous experience in showing a function is discontinuous at a point before? – Theo Bendit Apr 4 '18 at 15:17
• @TheoBendit very little, many years ago. I'm afraid I don't recall how – c87 Apr 4 '18 at 15:19

you may want to use the definition of continuity in terms of sequences here. I'll show you how to prove that $f(x)$ is discontinuous at any $x\in\mathbb{Q}$ with $x\not=0$. Recall that $f$ is continuous in $a\in D$ if for any sequence $(a_n)_{n\in\mathbb{N}}\subset D$ converging to $a$ we have $\lim_{n\rightarrow\infty} f(a_n)=f(a)$.

Hence, in order to show discontinuity, it suffices to find to sequences $(a_n)$ and $(a_n')$ both converging to $a$ with $\lim_{n\rightarrow\infty} f(a_n) \not= lim_{n\rightarrow\infty} f(a_n')$.

So for your $f$, fix $x\in \mathbb{Q}$ and let $$a_n = x+\frac{1}{n}$$ as well as $$a_n'= x+\frac{\sqrt{2}}{n}$$ for $n\in\mathbb{N}$. Observe that $a_n \in \mathbb{Q}$ for any $n$, hence $f(a_n)=0$ for any $n$. Thus $$\lim_{n\rightarrow\infty} f(a_n)= \lim_{n\rightarrow\infty} 0 =0.$$ By a similar argument, $a_n'\in\mathbb{R}\setminus\mathbb{Q}$ for any $n\in\mathbb{N}$ (think why), hence $f(a_n')=a_n'$. Thus, $$\lim_{n\rightarrow\infty} f(a_n')= \lim_{n\rightarrow\infty} a_n'=\lim_{n\rightarrow\infty} (x+\frac{\sqrt{2}}{n})=x$$ Since $x\not=0$ we have that $f$ is discontinuous at $x$. In a similar fashion one can prove that $f$ is discontinuous at any $x\in\mathbb{R}\setminus\mathbb{Q}$ with $x\not=0$.

Cold and straight definition:

1) $f$ is continuous at $x = 0$.

Pf: For any $\epsilon > 0$ let $\delta = \epsilon$. If $|x - 0| < \delta$, then if $x\in \mathbb Q$ then $f(x)= 0$ and $|f(x) - f(0)| =|0-0| = 0 < \epsilon$. If $x \not \in \mathbb Q$ then $f(x) = x$ and $|f(x) -f(0)| = |x-0| < \delta = \epsilon$.

So $|x - 0|< \delta\implies |f(x) - f(0)|<\epsilon$ so $f$ is continuous.

2) $f$ is not continuous at any $x\ne 0$.

Let $\epsilon = |x| > 0$. Let $\delta =$ any positive value; any at all.

Case 1: $x$ is rational and $f(x)=0$. Let $y$ be an irrational number so that if $x > 0$ then $0 < x < y <x + \delta$ or if $x < 0$ then $0 > x > y > x-\delta$. Then:

i) $|y-x| < \delta$

ii) $f(y) = y; |f(y)| =|f(y)| > |x|$

iii) $|f(y) - f(x)| = |f(y) - 0| = |f(y)| > |x| \ge \epsilon$.

So for that $\epsilon$ there is NO $\delta$ in which $|x - y| < \delta \implies |f(x) - f(y)| < \epsilon$.

So $f$ is not continuous at $x$.

Case 2: $x$ is irrational and $f(x)=x$. Let $y$ be an rational number so that $|y-x| < \delta$. Then:

i) $|y-x| < \delta$

ii) $f(y) = 0$;

iii) $|f(y) - f(x)| = |0 -x| = |x| \ge \epsilon$.

So for that $\epsilon$ there is NO $\delta$ in which $|x - y| < \delta \implies |f(x) - f(y)| < \epsilon$.

So $f$ is not continuous at $x$.

====

"Can somebody provide an example of a function that is continuous at every x≠0 and discontinuous at x=0? I'm wondering if a contradiction would work. "

A function that is continuous at $x \ne 0$ and discontinuous at $x= 0$ is not a contradiction.

The definition of $f$ contionuous at $x$ is:

For every $\epsilon > 0$ there exists a $\delta > 1$ so that for every $y$ so that $|x-y| < \delta$ then $|f(x) - f(y)| < \epsilon$.

The negation of that is

There exists an $\epsilon > 0$ so that for any $\delta > 0$, no matter how small, there will always exist a $y$ so that $|x-y| < \delta$ and $|f(x) - f(y)| \ge \epsilon$.

===

Anyway take any function that is continuous everywhere, such as $g(x) = 2x + 7$ and simply alter the value of $g(x)$. Example:

$f(x) = \begin{cases} 2x + 7 &\text{if$x\ne0$} \\ -2 &\text{if$x=0$} \end{cases}$

but I don't see how that will help you in any way.