The Popcorn Function

Continuity is not what it seems. In 1875, the German mathematician Carl Johannes Thomae defined a function P(x) with the following extraordinary property:

P(x) is  discontinuous if x is rational

P(x) is continuous if x is irrational.

A graph of this function on the interval (0,1) is shown below.

Thomae’s “popcorn function” for x in (0,1).

The function has many names. We will call it Thomae’s function or, in view of the similarity to popcorn frying on a pan, the popcorn function. We will present the definition of P(x) and justify the surprising claims about its properties.

Continuity is a central concept in mathematical analysis. It seems a simple idea: if we can draw the graph of a function without lifting the pencil from the paper, it is continuous. But this intuition is gravely misleading.

Functions may be defined in many ways. We will focus on explicit, piecewise definitions. Thus, the step function, or Heaviside function, is defined as

H(x) = 0 for x < 0 ,              H(x) = 1 for x >= 0

A rigorous definition of continuity was formulated by Augustin-Louis Cauchy. The basic idea was in terms of limits. If the limit of f(x) as x tends to a is f(a), then f is continuous at x = a. On this basis, H(x) is continuous away from zero, but discontinuous at x = 0. We call this a “jump discontinuity”.

In his work on heat diffusion, Joseph Fourier argued that an “arbitrary” function could be expressed as a sum of sine and cosine functions. These functions are the epitome of smoothness and continuity, and it seemed incredible that functions with jumps, such as the Heaviside function, could be expanded in sine functions.

Dirichlet showed that Fourier’s claim was too sweeping, but that, for a large class of functions, including H(x), he was right. In the process, Dirichlet introduced a function with an infinite number of jumps. The “Dirichlet function” is defined as:

D(x) = 1 ,  for x rational

D(x) = 0 ,  for x irrational

This is about as bad as can be: the function jumps between 0 and 1 on every interval no matter how small. It seems to be discontinuous everywhere, and this is indeed the case.

You may object that this is an artificial function: it does not have a formula like a “proper” function should. But, amazingly, the function defined as

\displaystyle f(x) = \lim_{k\rightarrow\infty}\left[ \lim_{j\rightarrow\infty}(\cos k!\pi x)^{2j} \right]

is nothing but Dirichlet’s function.

There is an even more surprising result in store: intuition would suggest that any function like D(x), with discontinuous jumps arbitrarily close together, could not possibly be continuous anywhere. But intuition is wrong. Carl Johannes Thomae defined a function P(x) with the following extraordinary property:

P(x) is discontinuous if x is rational

P(x) is continuous if x is irrational

A graph of this function was shown above. Here is the way it is defined:

P(x) = 1/q ,   for x rational with x = p/q in lowest terms.

P(x) = 0 ,   for x irrational

It is not too difficult to show that, for any a, the limit of P(x) as x tends to a is zero. The idea is that, given \epsilon, there are only a finite number of rationals p/q with 1/q greater than \epsilon. So, there is a neighbourhood of a on which P(x) is less than \epsilon except (possibly) at a itself. The continuity properties follow immediately.

The functions we have been looking at have jumps. Surely, a function without jumps must in some sense be smooth. Alas, even this cosy intuition was shattered by Karl Weierstrass when he constructed a function that is continuous everywhere but differentiable nowhere. But that is another story.

[Link to the Wikipedia page on Thomae’s Function]

Last 50 Posts