Thomae's function


Thomae's function, named after Carl Johannes Thomae, has many names: the popcorn function, the raindrop function, the countable cloud function, the modified Dirichlet function, the ruler function, the Riemann function, or the Stars over Babylon. This real-valued function of a real variable can be defined as:
Since every rational number has a unique representation with coprime and, the function is well-defined. Note that is the only number in that is coprime to
It is a modification of the Dirichlet function, which is 1 at rational numbers and 0 elsewhere.

Properties

For all since
For all there exist and such that and
Consider. If divides and, it divides
and. Conversely, if divides and, it divides and. So, and.
Assume an arbitrary rational with and coprime.
This establishes
Let be any irrational number and define for all
These are all irrational, and so
This implies and
Taking and selects an such that
for all
which is exactly the definition of discontinuity of at.
This shows that is discontinuous on
Since is periodic with period and it suffices to check all irrational points in Assume now and According to the Archimedean property of the reals, there exists with and there exist such that
for
The minimal distance of to its i-th lower and upper bounds equals
We define as the minimum of all the finitely many
for all and
This is to say, that all these rational numbers are outside the
Now let with the unique representation where are coprime. Then, necessarily, and therefore,
Likewise, for all irrational and thus, if then any choice of gives
Therefore, is continuous on
Empirical probability distributions related to Thomae's function appear in DNA sequencing. The human genome is diploid, having two strands per chromosome. When sequenced, small pieces are generated: for each spot on the genome, an integer number of reads overlap with it. Their ratio is a rational number, and typically distributed similarly to Thomae's function.
If pairs of positive integers are sampled from a distribution and used to generate ratios, this gives rise to a distribution on the rational numbers. If the integers are independent the distribution can be viewed as a convolution over the rational numbers,. Closed form solutions exist for power-law distributions with a cut-off. If then. In the case of uniform distributions on the set , which is very similar to Thomae's function. Both their graphs have fractal dimension 3/2.

The ruler function

For integers, the exponent of the highest power of 2 dividing gives 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0,.... If 1 is added, or if the 0s are removed, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1,.... The values resemble tick-marks on a 1/16th graduated ruler, hence the name. These values correspond to the restriction of the Thomae function to the dyadic rationals: those rational numbers whose denominators are powers of 2.

Related functions

A natural follow-up question one might ask is if there is a function which is continuous on the rational numbers and discontinuous on the irrational numbers. This turns out to be impossible; the set of discontinuities of any function must be an set. If such a function existed, then the irrationals would be an set. The irrationals would then be the countable union of closed sets, but since the irrationals do not contain an interval, nor can any of the. Therefore, each of the would be nowhere dense, and the irrationals would be a meager set. It would follow that the real numbers, being a union of the irrationals and the rationals, would also be a meager set. This would contradict the Baire category theorem: because the reals form a complete metric space, they form a Baire space, which cannot be meager in itself.
A variant of Thomae's function can be used to show that any subset of the real numbers can be the set of discontinuities of a function. If is a countable union of closed sets, define
Then a similar argument as for Thomae's function shows that has A as its set of discontinuities.
For a general construction on arbitrary metric space, see this article