# Example of a function continuous at only one point. [duplicate]

I want to know some example of a continuous function which is continuous at exactly one point. We know that $f(x)=\frac{1}{x}$ is continuous everywhere except at $x=0$. But i think this in reverse manner but i dont get any example. So please help me out!

## marked as duplicate by J. M. is a poor mathematician, Henning Makholm, t.b., Asaf Karagila♦, Zev ChonolesJul 14 '12 at 5:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

## 2 Answers

One standard example is the function

$$f(x)=\begin{cases} x,&\text{if }x\in\Bbb Q\\ 0,&\text{if }x\in\Bbb R\setminus\Bbb Q\;. \end{cases}$$

That is, $f(x)=x$ if $x$ is rational, and $f(x)=0$ if $x$ is irrational. This function is continuous only at $x=0$.

Added: The same basic idea can be used to build a function that is continuous at any single specified point. With a little more ingenuity, you can use it to get, for instance, a function that is continuous just at the integers:

$$f(x)=\begin{cases} \sin\pi x,&\text{if }x\in\Bbb Q\\ 0,&\text{if }x\in\Bbb R\setminus\Bbb Q\;. \end{cases}$$

This works because $\sin\pi x=0$ if and only if $x\in\Bbb Z$.

• Does this example have a name? – Lucas Jun 3 '13 at 0:49
• @Lucas: Not to my knowledge. – Brian M. Scott Jun 3 '13 at 3:27
• How does this work if we can find a rational number between any two real numbers? – Ian Macalinao Feb 15 '17 at 3:08
• Just to be sure, this would work as well if you would switch the definition, right? Namely f(x) = 0 if x is rational, and f(x) = x if x is irrational. – TStancek Jan 31 at 9:54

Just take something like the Dirichlet function:

$$f : \mathbb R \ni x \mapsto \begin{cases} x&\text{if}\; x\in \mathbb Q\\0&\text{otherwise}\end{cases}$$

Then $f$ is continuous only at $x=0$.