Constructing $f(x)$ continuous at $x=a$

53 Views Asked by At

I would like to construct a function $f:\mathbb{R}\to\mathbb{R}$ with the property that $f$ is continuous only at one point $a\in\mathbb{R}$ and nowhere else. I have seen various threads, but cannot seem to find a general answer for any $a$. All the answers point to the classical example $$f(x)= \begin{cases} 0 & x\notin\mathbb{Q} \\ x & x\in\mathbb{Q} \end{cases} $$ which has the property that it is continuous at $0$ and nowhere else. In another post about this problem, someone stated "a similar line of reasoning can be used to construct a function that is continuous only at one specific point."

Here is my attempt: Let $$f(x)= \begin{cases} a & x\notin\mathbb{Q} \\ x & x\in\mathbb{Q} \end{cases} $$ We claim that $f(x)$ is continuous only at $x=a$. Let $c\in\mathbb{Q}$ such that $c\neq a$, and set $\epsilon=\frac{|c-a|}{2}$. Then, for any $\delta>0$, there exists a number $x_0$ such that $|x_0-c|<\delta$ and $x_0\notin\mathbb{Q}$. Therefore, $|f(x_0)-f(c)|=|a-c|\nless\epsilon$. However, this function does not work for $c$ irrational...