Thomae's function

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Point plot on the interval (0,1). The topmost point in the middle shows f(1/2) = 1/2

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,[1] the Riemann function, or the Stars over Babylon (John Horton Conway's name).[2] This real-valued function f(x) of the real variable x is defined as:[3]

Since every rational number has a unique representation with relatively prime and , the function is well-defined. Note that is the only number in which is coprime to

It is a modification of the Dirichlet function, which is 1 at rational numbers and 0 elsewhere.


  • Thomae's function is bounded and maps all real numbers to the unit interval:
  • is periodic with period for all integer n and all real x.
Proof of periodicity

For all since

For all there exist and such that and According to Bézout's identity, for some holds

and thus

  • is discontinuous at all rational numbers, dense within the real numbers.
Proof of discontinuity at rational numbers

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

  • is continuous at all irrational numbers, also dense within the real numbers.
Proof of continuity at irrational arguments

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


The minimal distance of to its i-th lower and upper bounds equals

We define as the minimum of all the finitely many

so that

for all and

This is to say, that all these rational numbers are outside the -neighborhood of

Now let with the unique representation where are coprime. Then, necessarily, and therefore,

Likewise, for all irrational and thus, if then any choice of (sufficiently small) gives

Therefore, is continuous on

  • is nowhere differentiable.
Proof of being nowhere differentiable
  • For rational numbers, this follows from non-continuity.
  • For irrational numbers:
All sequences of irrational numbers converging to the irrational point imply a constant sequence identical to and so
According to Hurwitz's theorem, there also exists a sequence of rational numbers converging to with coprime and
Thus for all and so is not differentiable at all irrational
See the proofs for continuity and discontinuity above for the construction of appropriate neighbourhoods, where has maxima.
  • is Riemann integrable on any interval and the integral evaluates to over any set.
The Lebesgue criterion for integrability states that a bounded function is Riemann integrable if and only if the set of all discontinuities has measure zero.[4] Every countable subset of the real numbers - such as the rational numbers - has measure zero, so the above discussion shows that Thomae's function is Riemann integrable on any interval. The function's integral is equal to over any set because the function is equal to zero almost everywhere.


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 Fσ set. If such a function existed, then the irrationals would be an Fσ 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 (which is evidently meager), 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 Fσ 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 Kim, Sung Soo. "A Characterization of the Set of Points of Continuity of a Real Function." American Mathematical Monthly 106.3 (1999): 258-259.

Related probability distributions[edit]

Empirical probability distributions related to Thomae's function appear in DNA sequencing.[5] The human genome is diploid, having two strands per chromosome. When sequenced, small pieces ("reads") 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 (where is the polylogarithm function) 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.[5]

The ruler function[edit]

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, ... (sequence A007814 in the OEIS). If 1 is added, or if the 0's are removed, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, ... (sequence A001511 in the OEIS). 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 those rational numbers whose denominators are powers of 2.

See also[edit]


  1. ^ "…the so-called ruler function, a simple but provocative example that appeared in a work of Johannes Karl Thomae … The graph suggests the vertical markings on a ruler—hence the name." (Dunham 2008, p. 149, chapter 10)
  2. ^
  3. ^ Beanland, Roberts & Stevenson 2009, p. 531
  4. ^ Spivak 1965, p. 53, Theorem 3-8
  5. ^ a b Trifonov, Vladimir; Pasqualucci, Laura; Dalla-Favera, Riccardo; Rabadan, Raul (2011). "Fractal-like Distributions over the Rational Numbers in High-throughput Biological and Clinical Data". Scientific Reports. 1 (191). doi:10.1038/srep00191. PMC 3240948Freely accessible. PMID 22355706. 


External links[edit]