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.