Given an example of a function in real number

55 Views Asked by At

Give an example of a function $f:\mathbb R\to\mathbb R$ such that $f$ is continuous at $0$ but discontinuous in $\mathbb{R}\setminus\{0\}$

2

There are 2 best solutions below

0
On

Take $$ f(x)=xI_{\mathbb{Q}}(x) $$ where $I$ is the indicator function.

0
On

To get a function which is continuous at $0$ and discontinuous on $\mathbb R\setminus\{0\}$ the other answers are good.

But we can also go further. For $2\leq k\in\mathbb N$, the function $$ f(x)=\begin{cases} x^k & x\in\mathbb Q\\ 0 & otherwise \end{cases} $$ it $(k-1)$-times continuously differentiable at $0$ while discontinuous on $\mathbb R\setminus\{0\}$.

In addition, we can consider the function $$ f(x)=\begin{cases} exp\left(-\frac1{x^2}\right) & x\in\mathbb Q\\ 0 & otherwise \end{cases} $$ which is infinitely differentiable at $0$ while discontinuous on $\mathbb R\setminus\{0\}$.