How can I resolve the task below:
Given $f(x)= \begin{cases} x, &x\in \mathbb{Q}\text{ }\\ 1-x, &x\notin \mathbb{Q}\text{ (irrational)} \end{cases}$, $0 \leq x \leq 1$.
Show $f(x)$ is continuous only in $x=\dfrac{1}{2}$.
How can I resolve the task below:
Given $f(x)= \begin{cases} x, &x\in \mathbb{Q}\text{ }\\ 1-x, &x\notin \mathbb{Q}\text{ (irrational)} \end{cases}$, $0 \leq x \leq 1$.
Show $f(x)$ is continuous only in $x=\dfrac{1}{2}$.
ncmathstudent's answer is good, but if you want to see an alternative proof:
Note that both $\mathbb Q$ and $\mathbb R\setminus \mathbb Q$ are dense in $\mathbb R$. Thus for any $r\in\mathbb R$ there is a unique continuous function on $\mathbb Q\cup \{r\}$ which agrees with $x$ on $\mathbb Q$ (which clearly must be $x$), and a unique continuous function on $\mathbb R\setminus \mathbb Q\cup \{r\}$ which agrees with $1-x$ on $\mathbb Q\setminus \mathbb R$ (which clearly must be $1-x$). Thus if $f(x)$ is continuous at $r$, we must have $x=1-x$ at $r$ so $r=1/2$. It remains to verify that $f(x)$ is continuous at $1/2$, which is easy.