Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

(a) Find a function $f:\Bbb R \to \Bbb R$ which is discontinuous at $1,\frac 12,\frac 13, ... $ but is continuous at every other point.

(b) Find a function $f:\Bbb R \to \Bbb R$ which is discontinuous at $1,\frac 12,\frac 13, ... $and $0$ but is continuous at every other point.

share|cite|improve this question
Did you try something? Did you get stuck? – Asaf Karagila Apr 20 '13 at 21:36
@AsafKaragila: $f(x) = \begin{cases} 1 & if\,x=\frac 1q \in (0, 1] where\,\, q\in \Bbb N\\ 0 & if\,x\, otherwise\end{cases} $ , but I feel there is somthing wrong – Jhwana Apr 20 '13 at 21:40
@Fayz : your $f$ satisfies (b). You can modify that $f$ so it satisfies (a). – Stefan Smith Apr 20 '13 at 21:43
@AsafKaragila: I think my $f$ is continuous at $0$.. could u explain why is it satisfy (b)? – Jhwana Apr 20 '13 at 21:48
@Fayz If $f$ is continuous at a point $c$, then any sequence $\{x_n\}$ that tends to $c$ will satisfy $f(x_n)\to f(c)$. But $f(1/n) = 1\to 1$ as $n\to\infty$, and if we have a sequence $\{\xi_n\}$ of irrational numbers that tends to $0$, $f(\xi_n) = 0\to 0$ as $n\to\infty$, so $f$ is not continuous at $0$. – Stahl Apr 20 '13 at 21:52
up vote 9 down vote accepted

Hint: Try the functions $$f(x)=\begin{cases}x^2&:x=1/n,n\in\Bbb N\\ 0&:o.w.\end{cases}\quad\text{and}\quad g(x)=\begin{cases}1&:x=1/n,n\in\Bbb N\\ 0&:o.w.\end{cases}$$for $(a)$ and $(b)$ respectively.

share|cite|improve this answer
These both work for (a) , right? How I can make then discontinuous at $0$? – Jhwana Apr 20 '13 at 21:53
$g(x)$ is not continuous at $x=0$. Think about sequences and what continuity does to convergent sequences. – Clayton Apr 20 '13 at 21:56

I am personally fond of $$f(x)=\left\lfloor \frac 1 x\right\rfloor^{-1}$$

for $0< x\leq 1$ and zero elsewhere.

This is discontinuous at every $n^{-1}$ but continuous at zero.

To make it disccontinuous at zero, just ask that $f(0)=1$, and you're done. Here's "full" plot of the function over $[-1,1]$. Note, however, it is undefined at $x=0$.

enter image description here

ADD There is a very nice way of constructing, given a sequence $\{x_n\}$ of real numbers, a function which is continuous everywhere except the elements of $\{x_n\}$. Let $\{c_n\}$ by any nonnegative summable sequence, and let $$s(x)=\sum_{x_n<x} c_n$$

What we do is sum through the indices that satisfy the said inequality. Because of absolute convergence, order is irrelevant. The function is monotone increasing because the terms are nonnegative, and $s$ is discontinuous at each $x_n$ because $$s(x_n^+)-s(x_n^-)=c_n$$

However, it is continuous at any other $x$: see xzyzyz's proof with the particular case $c_n=n^{-2}$. In fact, this function is lower continous, in the sense $f(x^-)=f(x)$ for any value of $x$. If we had used $x_n\leq x$, it would be upper continuous, but still discontinuous at the $x_n$.

To see the function has the said jumps, note that for $h>0$, we have $$\begin{align}\lim_{h\to 0^+} s(x_k+h)-s(x_k-h)&=\lim_{h\to 0^+}\sum_{x_n<x_k+h} c_n-\sum_{x_n<x_k-h}c_n\\&=\lim_{h\to 0^+}\sum_{x_k-h\leq x_n<x_k+h} c_n\end{align}$$

and we can take $\delta$ so small that whenever $0<h<\delta$, for any given $x_m\neq x_k$, $x_m\notin [x_k-\delta,x_k+\delta)$, so the only term that will remain will be $c_k$, as desired.

share|cite|improve this answer
+1 My favorite as well. I always give this to my students to integrate over [0,1]. – Fixed Point Apr 20 '13 at 22:43
Nice answer! $ $ – leo Jun 3 '13 at 2:53

Let $\{a_n\}_{n \in \mathbb{N}}$ be any sequence of real numbers. The function $f(x) = \sum_{a_n \in (-\infty, x]} \frac{1}{n^2}$ is continuous everywhere apart from $a_n$.

This definition is a bit tricky, so let me explain the notation. Pick $x \in \mathbb{R}$. Let $S_x = \{n \in \mathbb{N}: a_n \in (-\infty, x])$. Then $f(x) = \sum_{n \in S_x} \frac{1}{n^2}$.

Let $x = a_k$ for some $k$. As $f$ is obviously increasing, it's easy to see that for $y < x$, $f(x) - f(y) \geq \frac{1}{k^2}$, so $f$ is not continuous at $x$.

If $x$ is not element of sequence $\{a_n\}$, in the definition of $f(x)$ we actually take sum over $a_n \in (-\infty, x)$ instead of $a_n \in (-\infty, x]$, so for $y < x$, we have $f(x) - f(y) = \sum_{a_n \in (y, x)} \frac{1}{n^2}$. Pick any $\epsilon > 0$. Since $\sum \frac{1}{n^2}$ is convergent, pick $N > 0$ large enough so that $\sum_{n > N} \frac{1}{n^2} < \epsilon$. Next, pick $z < x$ so that that for $n \leq N$, $a_n \not \in (z, x)$. Thus for every $y \in (z, x)$, $|f(x) - f(y)| = \sum_{a_n \in (y, x)} \frac{1}{n^2} \leq \sum_{n > N} \frac{1}{n^2} < \epsilon$.

Similarly, one can show that $f$ is continuous on the right at every $x \in \mathbb{R}$ (even for $x \in \{a_n\}$). Together, this implies that $f$ is discontinuous at $\{a_n\}$ and continuous everywhere else.

share|cite|improve this answer
I will upvote this when my vote limit wears off. It is weird it has no upvotes. – Pedro Tamaroff Apr 20 '13 at 23:28

I think the function

$$f(x)=\begin{cases}0&,\;\;x\neq\frac{1}{n}\\{}\\1&,\;\;x=\frac{1}{n}\end{cases}\;\;,\;\;\;n\in\Bbb N$$

does the trick for (b).

As for (a):

$$g(x)=\begin{cases}1&,\;\;x\neq\frac{1}{n}\\{}\\\frac{n-1}{n}&,\;\;x=\frac{1}{n}\end{cases}\;\;,\;\;\;n\in\Bbb N$$

share|cite|improve this answer
It's not continuous at $0$. – xyzzyz Apr 20 '13 at 22:15
Even if it were, how could a function be both continuous and discontinuous at $0$? – Stahl Apr 20 '13 at 22:16
Yup, missed that condition in (a). Trying to come up with an edit. – DonAntonio Apr 20 '13 at 22:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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