Show that $f(x)$, given by $f(x)=x$ for rational and $f(x)=-x$ for irrational numbers, is continuous at $0$

371 Views Asked by At

I came across the following function $$f(x) = \begin{cases} x, & x \in \mathbb{Q}, \\ -x, & x \in \mathbb{R} \backslash \mathbb{Q}. \end{cases}$$ It is claimed that $f(x)$ is continuous at zero. I want to be able to prove this.

So let $\varepsilon >0$ and consider that \begin{eqnarray*} \left| f(x) - f(0) \right| &=& \left| f(x) -0 \right| = \left| f(x) \right|. \end{eqnarray*} Now at any $x \in \mathbb{R}$, there exists a rational number $q$ such that $\left| x - q \right| < \frac{\varepsilon}{2}$ and similarly for an irrational number. I assume this is how the proof is formulated, but can't seem to structure it.

2

There are 2 best solutions below

0
On

Fix $\epsilon>0$. Taking $\delta=\epsilon$ we have $$ |x|<\delta\implies |f(x)-f(0)|=|x|<\epsilon $$

0
On

HINT: $|f(x)| = |x|$, so $|f(x)-f(0)| = |x-0| = |x|$.