Sunday Function

It's been a while since we've done a Sunday Function, so let's get back into the swing of things with a weird one. This is Thomae's function, and using Wikipedia's conveniently typeset definition:


If you're new to the concept of rational and irrational numbers, it's pretty simple. A number is rational if it can be written as a fraction p/q. Otherwise it's irrational. Numbers like pi or the square root of two fit this description. For this function we assume that the fraction p/q is reduced as far as possible, so if x = 1/3 we have p = 1 and q = 3. This is opposed to something like p = 7 and q = 21 which is a perfectly valid way of writing the number, but we have to pick a representation to eliminate the ambiguity.

It's not a particularly complicated function in principle. f(pi) = 0, f(22/7) = 1/7, and so on. In practice we may not know whether a particular number is rational or not, for instance the irrationality of (pi - e) is an open question. It would be absolutely flabbergasting if it were not irrational, but thus far it hasn't been proved one way or another.

Before we plot the function, we'll look at its continuity properties. By definition f(c) = 0 for irrational c, but if we're looking at rational values of x very close to c then it's relatively clear that x is going to have a big denominator. The number 22/7 that I mentioned earlier is pretty close to pi, but to get closer you'd need a number with a bigger denominator. In fact the number with the next-smallest denominator which is closer to pi is 333/106. And a bigger denominator means smaller 1/q, which is closer to 0. So while this is not a proof, it's a good argument that f(x) is continuous for all irrational x and discontinuous at all rational x. Freaky!

So what does it look like? Via Wolfram's plotting algorithm, this:


This is an incomplete plot, of course. In reality there'd be an infinite number of lines, and really it would probably be better to represent this plot pointwise rather than with lines anyway. Still, it gives a sense of just how odd this bird is.

Does this function have any use in physics? Not really as such, though it's interesting in that if you plant a bunch of identical telephone poles in a square grid, this function happens to represent what you see if you're looking at it from ground level at one of the corners.

More like this

Another fun thing to try for those at the upper-division undergrad level in mathematics is to integrate this function (say, from 0 to 1). If you know Lebesgue integration theory, determining the correct answer is trivial, but showing that the answer actually exists as a Riemann integral takes a little bit of work.

@1: Yep!

@2: It exists as a Riemann integral? I wouldn't have expected that. Sadly I know very little about the theory of Lebesgue integration but as you say this one is pretty trivially zero.


I was a little surprised that you can take the Riemann integral of this, but with a little thought, it seems possible. As long as you keep partitioning on maximal elements in intervals, you should be able to make the upper sum converge on the lower sum (which is always 0).

I suppose this function has no direct use in physics, but it's an important example in analysis, and physics depends pretty heavily on real analysis working correctly, so there's always that.

It is a theorem that a function is Riemann integrable if
and only if it is continuous alomost everywhere.

By Anonymous (not verified) on 03 May 2010 #permalink

I should have said "bounded function"

By Anonymous (not verified) on 03 May 2010 #permalink

What is f(0)?

To elaborate on the f(0) = 1 answer, we know 0 is the same as 0/1, or 0/2, or 0/3, and so on. The definition requires that we pick the representation with the smallest possible natural number denominator, so that's 0/1. The denominator is 1, so f(0) = 1.

Indeed it is Riemann integrable. It is not terribly difficult to show this using the Darboux definition of the Riemann integral.

An intuitive argument would be that there are only finitely many points where the function takes the values larger than 1/N for every positive integer N. Thus the upper Riemann integral should take values less than 1/N for every such N. Since the lower Riemann integral is clearly zero we are done.

Yes this argument works in this special case. Enclose each of the finite points where the function takes values
greater than 1/N by disjoint intervals having a total length
less than epsilon. These intervals together with the complementary intervals will give a partition of the interval [a, b] over which one is integrating. The contribution from the first set of intervals will be at most
epsilon since the function is bounded by one. The complementary intervals will give at most (b - a)/N. So the
total upper sum will be at most epsilon + (b-a)/N. Since
epsilon and N are arbitrary the upper integral is zero.
In general a bounded function f on an interval [a, b] is
Riemann integrable if and only if it is continuous almost
everywhere. It is not necessary to assume that f is measurable. The Borel measurability of f follows from the

By Anonymous (not verified) on 05 May 2010 #permalink

Correction. The hypothesis that f is a bounded almost
everywhere continuous function implies that f is measurable
but not that f is Borel measurable. To show that f is measurable one can define a sequence of step funcions
and use the almost everywhere continuity of f to get that
the sequence converges pointwise almost everywhere to f.
This shows that f is measurable. Since f is then a bounded
measurable function it is Lebesgue integrable. One can
define then sequences of step functions whose integrals
are upper and lower Riemann sums of f and which converge
pointwise almost everywhere to f and then use the Dominated
Convergence Theorem to conclude that both the upper sums
and lower sums converge to the Lebesgue integral of f hence
to the same value so f is Riemann integrable.
A similar type of argument proves the converse result that
a Riemann integrable function is continuous almost every-
Now a step function is Borel measurable but to conclude that
a pointwise limit of Borel functions is a Borel function
requires pointwise convergence everywhere. With almost
everywhere convergence the limit is measurable but not
necessarily Borel measurable.
To see that a Riemann integrable function need not be Borel consider all functions which are zero off the
Cantor set and bounded on the Cantor set but otherwise arbitrary.
Since the Cantor set is closed and has measure
zero all such functions are continuous almost everywhere
hence Riemann integrable. But the number of such functions
is 2^(2^alephnull) while the number of Borel functions is
2^alephnull so there are lots of Riemann integrable functions which are not Borel measurable.

By Anonymous (not verified) on 06 May 2010 #permalink