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

Define a real valued function $f$ as follows: if $x\in\mathbb{R}$ is irrational, set $f(x)=0$. If $x$ is rational and non-zero, represent it as $p/q$, with $p\in\mathbb{Z}$ and $q\in\mathbb{N}$ having no common factors and let $f(x)=2^{-q}$. Set $f(0)=1$. Find all points where $f$ is continuous.

I am not entirely sure of my solution, but here it goes:

  • If $x_n \to 0$ and the elements in this sequence are irrational, then $f(x_n) \to 0 \neq f(0)$, thus $f$ cannot be continuous at $0$.
  • If $x\in\mathbb{R}\setminus\mathbb{Q}$, then taking $y=\frac{p}{q}\in (x-\delta,x+\delta)$ rational for any $\delta$ gives us $|f(x)-f(y)|=\frac{1}{2^q}$. Hence $f$ cannot be continuous at irrational points.
  • If $x=\frac{p}{q}$ then taking $y\in (x-\delta,x+\delta)$ irrrational for any $\delta$ gives us $|f(x)-f(y)|=\frac{1}{2^q}$. Hence $f$ cannot be continuous at rational points.

This is not a homework problem, so feel free to give as much help and detail as you find necessary.

share|cite|improve this question
The second bullet point seems shaky. What if such $q$ have to be really large? – Dylan Moreland Feb 19 '12 at 21:41
Hint for start: the first dot is the same as the last dot and it is correct. The second dot is incorrect - your function is continuous at irrational points :) – savick01 Feb 19 '12 at 21:45
up vote 2 down vote accepted

Here's an $\varepsilon$-$\delta$ proof that $f$ is continuous at irrational points. Let $x_0$ be irrational. We are given $\varepsilon>0$. We seek $\delta>0$ small enough so that whenever $|x-x_0|<\delta$ then $|f(x)-f(x_0)| = f(x) < \varepsilon$. Let the nonnegative integer $q$ be large enough so that $2^{-q} < \varepsilon$. All we have to do is make $\delta$ small enough so that no rationals with denominator smaller than $q$ are in the interval $(x_0-\delta, x_0+\delta)$. Now observe that in the interval $(x_0-1, x_0+1)$ only finitely many rationals have denominator smaller than $q$. Since $x_0$ is not one of that rationals, there is some interval about $x_0$ that contains none of them.

share|cite|improve this answer

Your argument showing that $f$ is not continuous at any rational point is correct. However, $f$ is continuous at every irrational point. Here’s a hint to get you started; let me know if you want me to expand on it.

For any positive integer $q$ let $F_q$ be the set of rational numbers with denominator $\le q$ in lowest terms. $F_q$ has a very regular structure; what does it look like? If $x$ is an irrational, how can you find an open interval around $x$ that completely misses $F_q$?

Added: Perhaps that hint was a little misleading. Let me improve it. Let $E_q$ be the set of all rational numbers that can be written with denominator $q$, whether in lowest terms or not. Then the points of $E_q$ are evenly spaced at intervals of $1/q$ along the real line. Thus, if $x$ is any irrational, there is an integer $n$ such that $nq<x<(n+1)q$. Let $\delta_{x,q}$ be the smaller of $x-nq$ and $(n+1)q-x$; then $(x-\delta_{x,q},x+\delta_{x,q})$ is an open interval centred at $x$ and disjoint from $E_q$.

Now $F_q$ is just the union of all $E_p$ with $1\le p\le q$, so if you let $\delta'_{x,q}$ be the smallest of the $\delta_{x,p}$ with $p\le q$, $(x-\delta'_{x,q},x+\delta'_{x,q})$ will be an open interval centred at $x$ and disjoint from $F_q$. That means that if $\frac{r}s$ is a rational number in lowest terms in the interval $(x-\delta'_{x,q},x+\delta'_{x,q})$, $s>q$. What does this tell you about $\left|f(x)-f\left(\frac{r}s\right)\right|$?

share|cite|improve this answer
Can you please explain more? – Galois Feb 19 '12 at 22:37
@Galois: I’ve added to my answer. – Brian M. Scott Feb 20 '12 at 0:08

The function $f$ is discontinuous at rational points for exactly the reason you gave. However, it is continuous at irrational points. To see this, let $x$ be irrational and $(\frac{p_n}{q_n})$ be a sequence of rational points converging to $x$. Suppose we have some upper bound $Q$ for the $q_n$. Then we have that $x$ is arbitrarily close to rational points with denominator at most $Q$, of which there are only finitely many in any interval. But for $x$ to be arbitrarily close to a collection of finitely many points, it must be one of these points! This contradicts the irrationality of $x$, so we have no such upper bound $Q$. In fact, we can have no upper bound $Q$ for the denominators of any subsequence of $(\frac{p_n}{q_n})$, as any subsequence of $(\frac{p_n}{q_n})$ must also converge to $x$. Thus the $q_n$ become arbitrarily large, so $\lim\limits_{n\to\infty} 2^{-q_n}=0$. Hence $f(x)=\lim\limits_{n\to\infty} f(\frac{p_n}{q_n})$. If $(x_n)$ is a sequence of irrational numbers converging to $x$, then $f(x)=\lim\limits_{n\to\infty}f(x_n)$ as $f(x)=f(x_1)=\cdots=0$. Thus for any sequence $(x_n)$ converging to $x$, we can break it up into rational and irrational parts, each of which satisfy $\lim\limits_{n\to\infty}f(y_n)=0$, so $\lim\limits_{n\to\infty}f(x_n)=0=f(x)$, hence $f$ is continuous at $x$.

share|cite|improve this answer

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.