ArticleslgStudy

mathematics

Thomae's function

Thomae's function is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Thomae's function rather than just read about it. In short: Thomae's function is a real-valued function of a real variable that can be defined as: f(x)={1qif x=pq(x is rational), with p∈ℤ and q∈ℕ coprime0if x is irrational. It is named after Carl Johannes Thomae, but has many other names: the popcorn function, the raindrop function, the countable cloud function, the modified Dirichlet function, the ruler function (not to be confused with the integer ruler function), the Riem…

Thomae's function — main illustration
Thomae's function — illustration

Key takeaways

  • Thomae's function belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Thomae's function to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Thomae's function from memory before moving on to harder problems.

Reference excerpt

Thomae's function is a real-valued function of a real variable that can be defined as: f(x)={1qif x=pq(x is rational), with p∈ℤ and q∈ℕ coprime0if x is irrational. It is named after Carl Johannes Thomae, but has many other names: the popcorn function, the raindrop function, the countable cloud function, the modified Dirichlet function, the ruler function (not to be confused with the integer ruler function), the Riemann function, or the Stars over Babylon (John Horton Conway's name). Thomae mentioned it as an example for an integrable function with infinitely many discontinuities in an early textbook on Riemann's notion of integration. Since every rational number has a unique representation with coprime (also termed relatively prime) p∈ℤ and q∈ℕ, the function is well-defined. Note that q=+1 is the only number in ℕ that is coprime to p=0. It is a modification of the Dirichlet function, which is 1 at rational numbers and 0 elsewhere.

Properties

Related probability distributions 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 ("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 m,n are sampled from a distribution f(n,m) and used to generate ratios q=n/(n+m), this gives rise to a distribution g(q) on the rational numbers. If the integers are independent the distribution can be viewed as a convolution over the rational numbers, g(a/(a+b))=∑t=1∞f(ta)f(tb). Closed form solutions exist for power-law distributions with a cut-off. If f(k)=k−αe−βk/Liα(e−β) (where Liα is the polylogarithm function) then g(a/(a+b))=(ab)−αLi2α(e−(a+b)β)/Liα2(e−β). In the case of uniform distributions on the set {1,2,…,L} g(a/(a+b))=(1/L2)⌊L/max⁡(a,b)⌋, which is very similar to Thomae's function.

The ruler function

For integers, the exponent of the highest power of 2 dividing n 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 0s 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 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 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 ⋃i=0∞Ci, but since the irrationals do not contain an interval, neither can any of the Ci. Therefore, each of the Ci would be nowhere dense, and the irrationals would be a meager set. It would follow that the real numbers, being the union of the irrationals and the rationals (which, as a countable set, 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 A=⋃n=1∞Fn is a countable union of closed sets Fn, define fA(x)={1nif x is rational and n is minimal so that x∈Fn−1nif x is irrational and n is minimal so that x∈Fn0if x∉A Then a similar argument as for Thomae's function shows that fA has A as its set of discontinuities.

See also Blumberg theorem Cantor function Dirichlet function Euclid's orchard – Thomae's function can be interpreted as a perspective drawing of Euclid's orchard Volterra's function

References

Further reading

External links "Dirichlet-function". Encyclopedia of Mathematics. EMS Press. 2001 [1994]. Weisstein, Eric W. "Dirichlet Function". MathWorld.

Illustrations

Thomae's function: Point plot on the interval (0,1). The topmost point in the middle shows f(1/2) = 1/2.
Point plot on the interval (0,1). The topmost point in the middle shows f(1/2) = 1/2.

Worked examples

Example 1 — a first encounter with Thomae's function

Start with the simplest possible case. Write down what Thomae's function claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Thomae's function before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Thomae's function ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Thomae's function

In research
Thomae's function appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Thomae's function in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Thomae's function is common in secondary-school and first-year university syllabi. It links to neighbouring topics Calculus, Fractals, General topology, so understanding it makes those chapters shorter.
In everyday life
Look for Thomae's function outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Thomae's function” →

How to study Thomae's function in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Thomae's function means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Thomae's function out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Thomae's function in simple terms?

Thomae's function is a real-valued function of a real variable that can be defined as: f(x)={1qif x=pq(x is rational), with p∈ℤ and q∈ℕ coprime0if x is irrational. It is named after Carl Johannes Thomae, but has many other names: the popcorn function, the raindrop function, the countable cloud func…

Why does Thomae's function matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Thomae's function?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Thomae's function.

Tags

  • Calculus
  • Fractals
  • General topology
  • Special functions

Keep exploring