I'm currently reading Spivak's Calculus and I'm having trouble understanding the example with the limit of Thomae's function. The function \begin{align} f(x) = \begin{cases} 0 & \text{$x$ irrational, $0 < x < 1$}\\ \frac{1}{q} & \text{$x = p/q$ in lowest terms, $0 < x < 1$} \end{cases} \end{align} approaches $0$ for any $a \in (0, 1)$. Looking at this picture, I don't get how that could be true. For instance, if $a = \frac{1}{2}$, then it seems to me that for $\epsilon = \frac{1}{10}$ there's no $\delta$ such that $0 < \lvert x - a \rvert < \delta \implies \lvert f(x) - 0\rvert < \epsilon$. What am I missing here?

  • $\begingroup$ There is no a in your definition of $f(x)$. $\endgroup$
    – Paul
    Mar 4 at 15:20
  • $\begingroup$ While $f(1/2) = 1/2$, we can make $f(x)$ as small as we like by taking $x$ sufficiently close to $1/2$ but not equal to $1/2$. Is that what you're asking? $\endgroup$ Mar 4 at 15:20
  • $\begingroup$ @Paul It is not clear to me what your point is. I think there should not be any $a$ in the definition of $f(x)$. OP is saying that that $\lim_{x\to a} f(x) = 0$ for any $a$ in $(0,1)$. $\endgroup$
    – MJD
    Mar 4 at 15:53

1 Answer 1


Consider $\delta = \frac1{20}$. Other than $\frac12$ itself, each rational number in the interval $(\frac9{20}, \frac{11}{20})$ has a denominator at least $11$, so the value of Thomae's function in this interval is at most $\frac1{11}$.

(If you disagree, please say what rational number in the interval has a denominator smaller than $11$.)

In fact we can take $\delta$ as large as $\frac1{18}$ because this is the value that is required to exclude $\frac49$ and $\frac59$ from the interval.

Note that for any given $n$, we can simply list the fractions in (say) $(0, 1)$ whose denominators are less than $n$. This is a finite set, so there must be an interval around $\frac12$ that will exclude them all.

  • $\begingroup$ So if we let $n \in \mathbb{N}$ such that $\frac{1}{n} \leq \epsilon$, there's a finite number of $\frac{p}{q} \in (0, 1)$ such that $q < n$ (let $A$ be that finite set). What I also don't get from Spivak's reasoning is why there's only one $\frac{p}{q}$ closest to $a$, i.e. that there's a fixed $\delta$ such that $\delta = \min{\{\lvert \frac{p}{q} - a \rvert : \frac{p}{q} \in A, \frac{p}{q} \neq a }\}$. What am I missing here? $\endgroup$ Mar 5 at 17:53
  • $\begingroup$ If $A$ is a finite set, then there is an element of $A$ that is closest to $\frac12$, or possibly two elements that are tied for closest. To find the closest element, order the elements of $A$ by their distance to $\frac12$ and look for the one (possibly two) with the smallest distance. These must exist because a finite set always has a minimum. $\endgroup$
    – MJD
    Mar 5 at 20:15
  • $\begingroup$ So in this case, it's indeed possible for two $\frac{p}{q}$ (not necessarily one element in $A$ as Spivak claims) to be equally close to $a=\frac{1}{2}$? $\endgroup$ Mar 5 at 21:49
  • $\begingroup$ Sure, but it doesn't matter because any $\delta$ that excludes one will necessarily exclude the other. As long as $\delta$ is less than the distance to the closest $\frac pq$ with a small denominator, all the rational numbers in $(\frac12-\delta, \frac12+\delta)$ will have large denominators. $\endgroup$
    – MJD
    Mar 5 at 22:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .