I need to find a function $f:\mathbb{R}\to\mathbb{R}$ which is continuous only at two points, but discontinuous everywhere else.

How on earth would I go about doing this? I can't think of any function like this.

Thanks in advance.

Edit: I've seen examples including the indicator function for rationals. Is this the only method of finding such functions?

  • $\begingroup$ Please See this link : math.stackexchange.com/questions/7821/… $\endgroup$ – usermath Jun 8 '14 at 17:14
  • $\begingroup$ Yes, I've made an edit to make sure this question is not a duplicate. $\endgroup$ – Mr Croutini Jun 8 '14 at 17:15
  • $\begingroup$ Not about duplicate..The link seemed very good to me,that's why I suggeseted $\endgroup$ – usermath Jun 8 '14 at 17:17
  • 1
    $\begingroup$ Sorry, I forgot to thank you for the link, it was helpful! I just wanted to ensure and stress that this wasn't a duplicate. $\endgroup$ – Mr Croutini Jun 8 '14 at 17:19
  • $\begingroup$ Don't be sorry.I got your point. $\endgroup$ – usermath Jun 8 '14 at 17:22

Think of something like $$f(x)=\begin{cases} x^2 & \text{if } x \in \mathbb{Q}\\ x & \text{if } x \in \mathbb{R-Q}\\ \end{cases} $$ This is only continuous at two points, namely where $x^2=x$.

  • $\begingroup$ very nice! And it can be extended easily to any $n$ by using polynomials of degree $n$ (checking that there are different roots, but still!) $\endgroup$ – Ant Jun 9 '14 at 16:29

The following function is a standard example of a function that is continuous at one point only: $$ f(x) = \begin{cases} x &: x \in \Bbb Q \\ 0 &: \text{ otherwise.}\end{cases} $$

Show that this is indeed the case. Can you think of a way to modify it so that it's continuous at two points? Hint:

Instead of $x$ in the first case, consider the polynomial $(x - x_0)(x - x_1)$.

This can be generalized to construct a function that is continuous at a finite set of points only.


What about $$ f(x) = \begin{cases} x(1-x) & x \in \mathbb{Q} \\ 0 & x \notin \mathbb{Q} \\ \end{cases}? $$


General answer. If you have $a(x)$ and $c(x)$ continuous and $b(x)$ nowhere continuous, then $$a(x)\cdot b(x) + c(x)$$ is continuous at $x$, iff $a(x) = 0$.


It is possible to use something other than the rational indicator function to define these functions. Specifically, take $S$ to be a set define the function $I_S$ by

$$I_S(x) = \left\{\begin{array}{cc} 1 & x \in S\\ 0 & x \not\in S\end{array}\right.$$

This function is called the indicator function of $S$. Now, let $S$ be a dense subset of $\mathbb{R}$ such that $S^C$ is also dense in $\mathbb{R}$. (For example, we could take $S$ to be the set of all rational numbers with terminating decimal expansions.) Then, the function

$$f(x) = x^2I_S(x) + x(1-I_{S}(x))$$

is continuous at only $x=0$ and $x=1.$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.