# Give an example of a function $f: \mathbb{R} \to \mathbb{R}$ which is continuous only at $0$.

I do not know an example. Will ask question if in doubt of the proofs provided thank you!!

-
math.stackexchange.com/q/194194 – user44923 Oct 16 '12 at 21:24

$$F(x) = \left\{ \begin{array}{rcl} x,& \mbox{if} & x \in \mathbb{Q}\\ -x , & \mbox{if} & x \notin \mathbb{Q} \\ \end{array} \right.$$

$|x-0| < \varepsilon \Rightarrow |f(x) - f(0)| = |x| <\varepsilon$. If $x_0 > 0$. There is $x \notin \mathbb{Q}$ sufficiently near $x_0$ such that $f(x) = -x$ is sufficiently near $-x_0$. Thus do not sufficiently near $f(x_0) = x_0$.

-
What is the difference between your answer amd tomas'? – Maximiliano Oct 16 '12 at 21:21
@Maximum: It is simpler, and therefore more elegant. – TonyK Oct 16 '12 at 21:23
can you explain how does this show that this function is only continous at 0? plz – Maximiliano Oct 16 '12 at 21:25
I add explanation in the answer. – user29999 Oct 16 '12 at 21:32
AWESOME thank you!! – Maximiliano Oct 16 '12 at 21:34

Let $g(x)=1$ if $x$ is rational, and $0$ if $x$ is irrational. Let $f(x)=xg(x)$.

-

$$f(x) = \left\{ \begin{array}{rl} x^{2} &\mbox{ if x is rational} \\ -x^{2} &\mbox{ otherwise} \end{array} \right.$$

-