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.
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$.