Thomae’s Function aka The Stars over Babylon aka The Popcorn Function

* Note it’s assumed the reader has heard of limits for both sequences and functions, the connection between limits for sequences and functions (Called Heine’s Continuity Criterion), and continuity for functions. I haven’t decided whether or not there will be a blog post about any of these topics. But it you want that, please comment so and I will be more likely to do so! *

Ok, so you’re familiar with continuity somehow! If you have only taken calculus or physics, then you probably have a very intuition-based knowledge of continuity, rather than one based on the definition of continuity. However, just as in science, sometimes an intuition only approach in math can lead you astray! A great example of this is when looking at the continuity of Thomae’s function (aka the popcorn function or The Stars over Babylon). Before we get to this awesome function, let us ask some questions about functions and what types of continuity they can have to warm up a little.

(Everything is in the context of functions of real numbers)

  • Can you have a function continuous everywhere?
  • Is there a function that is discontinuous at one point?
  • Is there a function that is discontinuous at two points?
  • Is there a function that is discontinuous at countably infinitely many points?
  • Can you have a function continuous nowhere?
  • Can you have a function continuous at infinitely many points and discontinuous at infinitely many points? (countably or uncountably)
  • Oooo… can you have a function continuous at irrational numbers and discontinuous at all rational numbers?

I’m guessing that your calculus intuition might have helped with the first few questions, and then less so towards the end.

Let’s run through some of these questions really quick. We won’t prove our answers here; however, the same logic we will use for Thomae’s function will apply to the more complex questions above.

Can you have a function continuous everywhere? Yes, like f(x) = x.

Is there a function that is discontinuous at one point? Yes, for example, the sign-function. Which is defined to be equal to +1 for positive numbers, -1 for negative numbers, and 0 for x=0.

Is there a function that is discontinuous at two points? Yes, for example, the rectangular-function. The key idea is similar to the sign-function.

Is there a function that is discontinuous at countably infinitely many points? Take your guess! If you think so, try to think of an example and put in the comments. If you don’t think so prove why you cannot have one!

Can you have a function continuous nowhere? This one is where I think calculus intuition starts to fail us. The answer is surprisingly yes! An example is called Dirichlet’s function. It’s a very weird function and is defined as follows,

It’s not a function that lends itself to being graphed and we won’t show why this function is continuous nowhere; however, you may be able to do this yourself after reading about Thomae’s function!

Oooooo… can you have a function continuous at irrational numbers and discontinuous at all rational numbers? We skipped one question, since the answer to this question is YES! So, the former question has an answer of YES when you want uncountably many continuous points and countably many discontinuous!

Wait! What? You can have a function that is continuous at all the irrational numbers and discontinuous at all the rational numbers? This is where you think: How’s that possible? Prove it! And we shall. With Thomae’s function!

Thomae’s function is continuous at all irrational numbers and discontinuous at all rational numbers. Let’s show why!

Finally, Thomae’s Function

The Definition:

We define Thomae’s function to be the following:

Very strange indeed. Here’s a great visualization of T before we study it.

By Smithers888 – Own work, Public Domain, https://commons.wikimedia.org/w/index.php?curid=4957683

Sketch:

We’ll soon see it’s not too bad to see that T is discontinuous at all a\in\mathbb{Q}. It’s trickier to see for c \notin \mathbb{Q} that \lim_{x\rightarrow c}{T(x)} = T(c). Before we go through the general proof for all irrational numbers, let’s do an example using everyone’s favorite \pi \notin \mathbb{Q} and \varepsilon = \frac{1}{10}>0.

Let \varepsilon = \frac{1}{10}>0. We want to find a \delta>0 such that for all x where |x-\pi|<\delta we have |T(x) - T(\pi)|<\varepsilon = \frac{1}{10}.

The key idea is the following: We want to get within one-tenth of T(\pi) = 0 ie |T(x) - T(\pi)| = |T(x)-0| = |T(x)|<\varepsilon = \frac{1}{10}. Observe that for all x \notin \mathbb{Q} we have T(x)=0 so we don’t have to do anything, and we done, since 0<\frac{1}{10} . For this reason, we focus on x\in\mathbb{Q} that get close to \pi.

Consider the set of all rational numbers \frac{p}{q} in the range 0<\frac{p}{q}<2\pi such that 0< q\leq 10 ,

S_{\pi}:= \left\{\frac{p}{q}\in \mathbb{Q}\;:\; 0<\frac{p}{q}<2\pi\;\;\mathrm{and}\;\;0<q\leq 10\right\}.

Some elements in S_{\pi} are,

S_{\pi}= \left\{\frac{1}{1},\frac{2}{1},\frac{3}{1},\cdots,\frac{3}{4},\frac{4}{4},\frac{5}{4},\cdots,\frac{21}{7},\frac{22}{7},\frac{23}{7},\cdots, \frac{26}{9},\frac{27}{9},\frac{28}{9},\cdots,\frac{61}{10},\frac{62}{10} \right\}.

Note that S_{\pi} is finite. This is key because we can talk about which rational number in S_{\pi} gets closest to \pi . None will be exact since \pi \notin\mathbb{Q}. Through trial and error (or some knowledge about approximating irrational numbers by rational numbers) we conclude:

\min{ \left\{ \left| \frac{p}{q} - \pi \right| \;:\; \frac{p}{q} \in S_{\pi} \right\} } \;=\; \frac{22}{7}-\pi \;\approx\; 0.00126448926735 \cdots

If we want some rational number to get closer to \pi than \frac{22}{7} does, we need to let the denominator q be larger! For this reason, we claim that letting,

\delta = \min{ \left\{ \left|\frac{p}{q}-\pi\right|\;:\;\frac{p}{q}\in S_{\pi}\right\}} \;=\; \frac{22}{7}-\pi \;\approx\; 0.00126448926735\cdots >0

does what we want it to do. Indeed, since for all x\in \mathbb{Q} such that |x-\pi|<\delta , it must be the case that x = \frac{a}{b} (assume this is it’s reduced fraction-form) where b>10 . Since, if b\leq 10 then x\in S_{\pi} and by the definition of \delta , it must be |x-\pi| \geq \delta . How awesome!

Thus, T(x) = \frac{1}{b}<\frac{1}{10} . Or, |T(x) - T(\pi)| = |T(x)-0| = |T(x)|<\frac{1}{10}. Which is what we wanted.

To recap, we showed for \varepsilon = \frac{1}{10}>0, letting \delta = \frac{22}{7}-\pi >0 we have for all x with |x-\pi|<\delta we have |T(x) - T(\pi)|<\varepsilon = \frac{1}{10}.

Proof:

We aim to show that T(x)  is continuous at only irrational numbers c\in\mathbb{R} \setminus \mathbb{Q}  . We will do this in two steps (i) using Heine’s criterion we show that for any a\in \mathbb{Q}  there is a sequence a_n that converges such that a_n \rightarrow a with T(a_n) \not\rightarrow T(a)  , (ii) we then use the definition of continuity to show \lim_{x\rightarrow c}{T(x)} = T(c)=0 for c\notin \mathbb{Q} by using the same key ideas as in the sketch.

(Step i) Showing that \lim_{x\rightarrow c}{T(x)} doesn’t exist for a\in\mathbb{Q}.

Let a\in\mathbb{Q}. Let the sequence a_n be such that it converges to a and all elements are irrational numbers and . An example of such a sequence is a_n = a + \frac{\sqrt{2}}{n} \rightarrow a. And since a\in\mathbb{Q} and \sqrt{2}\notin\mathbb{Q} we have a_n\notin\mathbb{Q}. By definition of T(x) we conclude T(a_n) = 0 for all a_n and thus T(a_n) \rightarrow 0. But observe that T(a) \neq 0 since a\in\mathbb{Q}. We conclude that T(x) is not continuous at any a\in\mathbb{Q}.

(Step ii) Showing that \lim_{x\rightarrow c}{T(x)} = T(c)=0 for c\notin \mathbb{Q}.

Remember we’re doing it by definition of continuity.

Let \varepsilon > 0. By the Archimedean property, there is some N\in\mathbb{N} such that \frac{1}{N} <\varepsilon. With this in mind, define the set,

S_c:= \left\{\frac{p}{q}\in \mathbb{Q}\;:\; \left|\frac{p}{q}\right|<2c\;\mathrm{and}\;0<q\leq N\right\}.

We claim letting,

\delta = \min{ \left\{ \left|\frac{p}{q}-c\right| \;:\; \frac{p}{q} \in S_{c}\right\} }>0,

works! The reason is similar to what we remarked earlier. Also, note that $\delta>0$ since no rational number can equal c\notin\mathbb{Q}.

Observe, for all x such that |x-c|<\delta  we either have x\in \mathbb{Q}  or x\notin  \mathbb{Q}  . In the first case, there are some a,b \in \mathbb{Z} such that x = \frac{a}{b}    such that \gcd{(a,b)}=1   and b>N   . So that T(x) = \frac{1}{b}<\frac{1}{N}  . And in the other case T(x). Thus, x such that |x-c|<\delta  we have,

\left| T(x)-T(c) \right| = |T(x)| \\ \textit{ }\qquad\qquad\;\;\;\;\;\leq \;\;\left| \frac{1}{N} \right| \\ \textit{ }\qquad\qquad\;\;\;\;\;< \varepsilon

Concluding the proof!

\square

Closing Remarks

How awesome is Thomae’s function. Answer: It’s pretty darn cool! I hope I made this more palatable for those who are taking Real Analysis or who have taken the class. I admit this is an advanced blog post; however, I hope that it was interesting!

Any who, you’re probably either sweating from exhaustion for making it to the end (thank you by the way). Or you’re sweating from excitement. In which case you should try to show that Dirichlet’s function is continuous nowhere. If you want a hint read the next line. If not, go have fun!

Oh, one last thing. You can tweak the argument to show that \lim_{x\rightarrow c}{T(x)} = T(c)=0 for c\in \mathbb{R}. This would prove that continuous at all the irrational numbers and discontinuous at all the rational numbers in one step.

Hint…

Try to come up with a justification why you can make two sequences a_n,b_n such that a_n,b_n \rightarrow c for some c \in \mathbb{R}, but where all elements of a_n are rational numbers and all the elements of b_n are irrational numbers. Then note what D(c) equals. It will be different than either D(a_n) = 0\rightarrow 0 or D(b_n)=1 \rightarrow 1.

Leave a comment