Hubbry Logo
search
logo
1891202

Thomae's function

logo
Community Hub0 Subscribers
Read side by side
from Wikipedia

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

Thomae's function is a real-valued function of a real variable that can be defined as:[1]: 531 

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),[2] the Riemann function, or the Stars over Babylon (John Horton Conway's name).[3] Thomae mentioned it as an example for an integrable function with infinitely many discontinuities in an early textbook on Riemann's notion of integration.[4]

Since every rational number has a unique representation with coprime (also termed relatively prime) 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

[edit]
  • Thomae's function is bounded and maps all real numbers to the unit interval:
  • is periodic with period for all integers n and all real x.
  • is discontinuous at every rational number, so its points of discontinuity are dense within the real numbers.
  • is continuous at every irrational number, so its points of continuity are dense within the real numbers.
  • is nowhere differentiable.
  • has a proper local maximum at each rational number, providing an example of a function with a dense set of proper local maxima.[5]
    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.[6] 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.
  • If is the graph of the restriction of to , then the box-counting dimension of is .[7]
[edit]

Empirical probability distributions related to Thomae's function appear in DNA sequencing.[8] 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.[8]

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 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.

[edit]

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, neither 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 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 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.

See also

[edit]

References

[edit]

Further reading

[edit]
[edit]
Revisions and contributorsEdit on WikipediaRead on Wikipedia
from Grokipedia
Thomae's function, also known as the popcorn function, is a real-valued function defined on the closed unit interval [0,1][0,1] that assigns the value 1/q1/q to each rational number x=p/qx = p/q expressed in lowest terms with pZp \in \mathbb{Z} and q>0q > 0, and the value 0 to each irrational number.[1][2] It is named after the German mathematician Carl Johannes Thomae (1840–1921), who contributed to the study of elliptic functions and analysis.[3] This function is continuous at every irrational point in [0,1][0,1], as the values near an irrational approach 0 due to the density of irrationals and the sparsity of rationals with large denominators, but discontinuous at every rational point, where sequences of irrationals converge to the point while the function values approach 0, differing from the positive rational value.[1] Despite its discontinuities forming a dense countable set (the rationals), Thomae's function is bounded and Riemann integrable over [0,1][0,1] with integral 0, because the set of discontinuities has Lebesgue measure zero and the upper Darboux sums converge to 0 as the partition refines.[4] The function exemplifies key concepts in real analysis, such as the distinction between pointwise and uniform continuity, the role of discontinuity sets in integrability criteria, and the behavior of functions on dense subsets like the rationals and irrationals.[1][4] Its graph, which appears as isolated spikes at rational points diminishing in height with increasing denominator, visually motivates its "popcorn" moniker and highlights the counterintuitive nature of continuity in the reals.[2] Thomae's function remains a standard pedagogical tool for understanding Riemann integration and the topology of the real line.[5]

Definition and Background

Formal Definition

Thomae's function, also known as the popcorn function or raindrop function, is defined on the closed interval [0,1][0,1] with codomain [0,1][0,1].[6] The function f:[0,1][0,1]f: [0,1] \to [0,1] is given by
f(x)={0if x is irrational,1qif x=pq is rational in lowest terms, where p,qZ,q>0,gcd(p,q)=1. f(x) = \begin{cases} 0 & \text{if } x \text{ is irrational}, \\ \frac{1}{q} & \text{if } x = \frac{p}{q} \text{ is rational in lowest terms, where } p, q \in \mathbb{Z}, \, q > 0, \, \gcd(p,q) = 1. \end{cases}
[7] The condition that the rational x=p/qx = p/q is expressed in lowest terms, with integers pp and positive integer qq such that gcd(p,q)=1\gcd(p,q) = 1, ensures a unique denominator qq for each rational number, which determines the function value.[7] This representation applies to the boundary points as well: 0=0/10 = 0/1 and 1=1/11 = 1/1, both in lowest terms with q=1q = 1, so f(0)=1f(0) = 1 and f(1)=1f(1) = 1.[7] Variations in notation may specify that the denominator qq is positive to standardize the representation and avoid sign ambiguities in the fraction.[8]

Historical Context

Thomae's function was introduced by the German mathematician Carl Johannes Thomae in his 1875 textbook Einleitung in die Theorie der bestimmten Integrale, where it served as an illustrative example in the development of Riemann's theory of integration.[9] Thomae presented the function on page 14, section 20, highlighting its behavior amid discussions of integrability for functions exhibiting discontinuities. This work reflected Thomae's broader contributions to function theory, influenced by his time in Göttingen, where he intended to study under Bernhard Riemann but completed his doctorate under Friedrich Schering, and by his studies under Karl Weierstrass earlier in his career.[3] The function appeared during a period of intense exploration in 19th-century German mathematics, particularly in the rigorous analysis of discontinuous functions and the foundations of real integration following Riemann's 1854 habilitation lecture. Thomae's example contributed to ongoing debates about the boundaries of Riemann integrability, building on earlier work by Dirichlet and others on pointwise discontinuities, though it received limited contemporary attention beyond pedagogical contexts. Over time, the function acquired several alternative names reflecting its distinctive graphical features or connections to prior examples. These include the "popcorn function," due to the spiky, kernel-like appearance of its graph; the "raindrop function," evoking inverted droplets; and the "modified Dirichlet function," acknowledging its relation to Peter Gustav Lejeune Dirichlet's 1829 discontinuous example.[10] In English-language texts, particularly from the mid-20th century onward, such as in real analysis textbooks by authors like Stephen Abbott, these informal names gained traction alongside "Thomae's function" to emphasize its role in teaching continuity and integrability.[11] Despite its enduring value as a counterexample in real analysis, Thomae's function has not undergone extensive historical scrutiny, functioning mainly as a concise pedagogical device rather than a focal point of major theoretical advancement.

Core Properties

Continuity Behavior

Thomae's function exhibits a distinctive continuity behavior: it is continuous at every irrational number in the interval [0,1][0,1] and discontinuous at every rational number in that interval.[5] This property arises from the function's definition, where f(x)=0f(x) = 0 for irrational xx and f(x)=1/q>0f(x) = 1/q > 0 for rational x=p/qx = p/q in lowest terms with q>0q > 0, highlighting the interplay between the density of rationals and irrationals in the reals.[1] To establish continuity at an irrational point c[0,1]c \in [0,1], note that f(c)=0f(c) = 0. For any ϵ>0\epsilon > 0, select an integer n>1/ϵn > 1/\epsilon, so 1/n<ϵ1/n < \epsilon. In the bounded interval (c1,c+1)(c-1, c+1), there are only finitely many rationals with denominator at most nn in reduced form, say r1,,rmr_1, \dots, r_m. Let δ=min{1,crk:k=1,,m}>0\delta = \min\{1, |c - r_k| : k=1,\dots,m\} > 0, excluding zero since cc is irrational. Then, for xc<δ|x - c| < \delta, if xx is irrational, f(x)f(c)=0<ϵ|f(x) - f(c)| = 0 < \epsilon; if xx is rational p/qp/q in lowest terms, then q>nq > n, so f(x)=1/q<1/n<ϵf(x) = 1/q < 1/n < \epsilon. Thus, f(x)f(c)<ϵ|f(x) - f(c)| < \epsilon, proving continuity at cc. The density of irrationals ensures such neighborhoods are nonempty, while the finite exclusion of low-denominator rationals controls the function values.[5][1] For discontinuity at a rational point a=p/q[0,1]a = p/q \in [0,1] in lowest terms with q1q \geq 1, f(a)=1/q>0f(a) = 1/q > 0. Consider any δ>0\delta > 0; the interval (aδ,a+δ)(a - \delta, a + \delta) contains irrationals yy (by density of irrationals) where f(y)=0f(y) = 0, so f(y)f(a)=1/q|f(y) - f(a)| = 1/q. Choosing ϵ=1/(2q)>0\epsilon = 1/(2q) > 0, no such δ\delta satisfies f(x)f(a)<ϵ|f(x) - f(a)| < \epsilon for all xa<δ|x - a| < \delta, as the irrationals force the difference to reach 1/q>ϵ1/q > \epsilon. Alternatively, any sequence of irrationals converging to aa has f(xn)=00f(a)f(x_n) = 0 \to 0 \neq f(a), so the limit at aa is 0, differing from f(a)f(a). The density of rationals ensures neighborhoods also contain other rationals where ff approaches 0, but the jump at aa prevents continuity.[5][1] Thomae's function serves as a standard example of a function continuous precisely at the irrationals in [0,1][0,1] but nowhere differentiable, as the oscillatory behavior near rationals disrupts differentiability even at irrationals.[12]

Riemann Integrability

A bounded function ff on a closed interval [a,b][a, b] is Riemann integrable if and only if the set of its points of discontinuity has Lebesgue measure zero. For Thomae's function ff on [0,1][0, 1], the points of discontinuity are precisely the rational numbers in this interval, which form a countable set.[13] Every countable set of real numbers has Lebesgue measure zero, as it can be covered by open intervals of arbitrarily small total length.[14] Thus, the set of discontinuities of ff has measure zero, implying that ff is Riemann integrable on [0,1][0, 1].[15] The Riemann integral of Thomae's function over [0,1][0, 1] equals zero: 01f(x)dx=0\int_0^1 f(x)\, dx = 0.[13] To see this, consider the Darboux upper and lower sums for any partition P={x0=0<x1<<xn=1}P = \{x_0 = 0 < x_1 < \cdots < x_n = 1\} of [0,1][0, 1]. The lower sum L(f,P)L(f, P) is always zero, since every subinterval [xi1,xi][x_{i-1}, x_i] contains irrational points where f(x)=0f(x) = 0, so the infimum of ff on each subinterval is zero.[15] For the upper sum U(f,P)U(f, P), given ϵ>0\epsilon > 0, choose a positive integer NN such that 1N<ϵ2\frac{1}{N} < \frac{\epsilon}{2}. The set AN={x[0,1]:f(x)1N}A_N = \{x \in [0, 1] : f(x) \geq \frac{1}{N}\} consists of the finitely many rationals in [0,1][0, 1] with denominator at most NN in lowest terms; let AN=M<|A_N| = M < \infty. Construct a partition PϵP_\epsilon by isolating each point in ANA_N within a subinterval of length less than ϵ2M\frac{\epsilon}{2M} centered at that point (adjusting endpoints if necessary to fit within [0,1][0, 1]), and filling the remaining subintervals arbitrarily. In these isolating subintervals, the supremum of ff is at most 1, so their total contribution to U(f,Pϵ)U(f, P_\epsilon) is less than ϵ2\frac{\epsilon}{2}. In the remaining subintervals, the supremum of ff is less than 1N<ϵ2\frac{1}{N} < \frac{\epsilon}{2}, and their total length is at most 1, so their contribution is less than ϵ2\frac{\epsilon}{2}. Thus, U(f,Pϵ)<ϵU(f, P_\epsilon) < \epsilon.[13] Since ϵ>0\epsilon > 0 is arbitrary and L(f,P)=0L(f, P) = 0 for all PP, the upper and lower integrals coincide at 0, confirming the integral value.[15] In contrast, the Dirichlet function g(x)=1g(x) = 1 if xx is rational and g(x)=0g(x) = 0 if xx is irrational is not Riemann integrable on [0,1][0, 1], as it is discontinuous at every point in [0,1][0, 1], so its set of discontinuities is the entire interval, which has positive Lebesgue measure.[15] For any partition PP of [0,1][0, 1], the upper sum U(g,P)=1U(g, P) = 1 (since every subinterval contains rationals) while L(g,P)=0L(g, P) = 0 (since every subinterval contains irrationals), so the upper and lower integrals do not agree.[16]

Examples and Illustrations

Specific Function Values

Thomae's function assigns the value 1 to the endpoints of its domain, as $ f(0) = f(1) = 1 $, corresponding to the representations $ 0/1 $ and $ 1/1 $ in lowest terms. For other rational points in (0,1), the function value decreases as the denominator in lowest terms increases; for instance, $ f(1/2) = 1/2 $, $ f(1/3) = 1/3 $, $ f(2/3) = 1/3 $, $ f(1/4) = 1/4 $, $ f(3/4) = 1/4 $, and $ f(2/5) = 1/5 $. This reflects the function's dependence on the denominator $ q $ of the reduced fraction $ p/q $, where $ \gcd(p,q)=1 $ and $ q > 0 $. Importantly, fractions not in lowest terms are evaluated after reduction; for example, $ 2/4 $ simplifies to $ 1/2 $, so $ f(2/4) = 1/2 $ rather than $ 1/4 $. At irrational points, Thomae's function is uniformly zero, regardless of the point's location in [0,1]. Examples include $ f(\sqrt{2}/2) = 0 $ (where $ \sqrt{2}/2 \approx 0.707 $) and $ f(\pi - 3) = 0 $ (where $ \pi - 3 \approx 0.142 $). The following table illustrates function values at all rational points in [0,1] with denominators $ q = 1 $ to $ 5 $ in lowest terms, highlighting how higher denominators yield smaller values and introduce greater sparsity in the set of such points.
$ x $ (decimal approx.)Reduced form $ p/q $$ f(x) $
00/11
1/5 (0.2)1/51/5
1/4 (0.25)1/41/4
1/3 (≈0.333)1/31/3
2/5 (0.4)2/51/5
1/2 (0.5)1/21/2
3/5 (0.6)3/51/5
2/3 (≈0.667)2/31/3
3/4 (0.75)3/41/4
4/5 (0.8)4/51/5
11/11
These values demonstrate the function's tendency to cluster near 0, with isolated spikes at rationals featuring small denominators, underscoring the sparsity of higher spikes as $ q $ grows.

Graphical Description

The graph of Thomae's function over the interval [0,1] consists of a horizontal line at y=0, interrupted by isolated spikes at every rational point x = p/q in lowest terms, where the spike height is 1/q. This creates a baseline of zero values at all irrational points, with the spikes becoming progressively shorter as the denominator q increases, resulting in a visually sparse appearance for higher denominators despite the countable infinity of rationals. Taller spikes are prominent at points with small q, such as integers and half-integers, giving the graph its characteristic "popcorn" or "raindrop" look due to the upward projections resembling scattered kernels or droplets above the x-axis.[5][17][18] The density of these spikes is highest near irrational numbers, where rationals accumulate, but visually, the graph appears mostly flat because the spikes for large q are too short and numerous to resolve distinctly without magnification. Upon zooming into finer scales, the function reveals a predominantly horizontal line at y=0, punctuated only by taller spikes near low-denominator rationals like 1/2 (height 0.5), 1/3 and 2/3 (height approximately 0.333), and similar fractions, while the infinite but countable spikes approach zero height everywhere. This perceptual flatness at irrationals underscores the function's continuity there, contrasting with the discontinuities at rationals that manifest as these isolated peaks.[5][19][18] In comparison to the Dirichlet function, which alternates densely between 1 at rationals and 0 at irrationals and thus cannot be plotted without appearing as a solid blend of lines due to its uniform discontinuity everywhere, Thomae's graph is more discernible because the varying spike heights allow for a structured, hierarchical pattern rather than an undifferentiated fill. Plotting Thomae's function presents challenges, as accurately capturing the continuity at irrationals requires infinite resolution to show the flat segments amid the dense rational spikes, often leading to approximations that emphasize the popcorn-like irregularity only over limited scales.[20][5][17]

The Ruler Function

The ruler function, a dyadic analog of Thomae's function, is defined on the interval [0,1][0,1] by setting r(x)=0r(x) = 0 for irrational xx or for rational xx that are not dyadic rationals, and r(x)=2kr(x) = 2^{-k} if x=m/2kx = m / 2^k where mm is an odd integer and k0k \geq 0 (with the fraction in lowest terms).[21] This construction assigns positive values exclusively to dyadic rationals, those rationals whose denominators in lowest terms are powers of 2.[22] Unlike Thomae's function, which evaluates to 1/q1/q at any rational p/qp/q in lowest terms regardless of the prime factors of qq, the ruler function restricts nonzero values to dyadics by setting r(p/q)=2kr(p/q) = 2^{-k} precisely when q=2kq = 2^k, and r(p/q)=0r(p/q) = 0 for all other rationals.[21] In its discrete form on the positive integers, the ruler function is given by r(n)=v2(n)r(n) = v_2(n), the 2-adic valuation of nn (the highest power of 2 dividing nn), often shifted or inverted as 2v2(n)2^{-v_2(n)} in continuous extensions.[22] For real arguments, it can also be expressed via the dyadic expansion of xx, where the value corresponds to the inverse power of 2 at the first differing bit position in binary representations.[21] The continuity properties of the ruler function parallel those of Thomae's function but are confined to the dyadic points: it is continuous at every non-dyadic real number (both irrationals and non-dyadic rationals) and discontinuous at every dyadic rational.[23] At a non-dyadic point cc, for any ϵ>0\epsilon > 0, there exists a neighborhood excluding sufficiently fine dyadics whose values fall below ϵ\epsilon, ensuring the function approaches 0. At a dyadic d=m/2kd = m/2^k, sequences of finer dyadics approach dd with values approaching 2k02^{-k} \neq 0.[23] The function is Riemann integrable over [0,1][0,1] because its discontinuities form a countable set of measure zero, and the integral equals 0.[24] Historically, the ruler function draws its name from the visual resemblance of its graph to the tick marks on a ruler, with "spikes" at dyadic points decreasing in height as denominators increase; in combinatorics, it originates as the sequence tracking 2-adic valuations, sometimes linked to variants of the Minkowski question-mark function through continued fraction approximations at quadratic irrationals.[25] Thomae's function admits interpretations in probability theory through models of random rationals, where the function value $ f(x) = 1/q $ for $ x = p/q $ in lowest terms relates to the reciprocal of the denominator in sampling schemes for rationals. In particular, when considering a random rational selected uniformly from the Farey sequence of order $ n $, the value $ 1/q $ corresponds to the contribution from fractions with denominator $ q $, and the expected value of $ 1/Q $ (where $ Q $ is the denominator) approaches 0 as $ n \to \infty $, reflecting the increasing dominance of large denominators.[26] A key link to the Riemann zeta function arises from the sum over all reduced rationals $ x = p/q \in [0,1] $ of $ f(x) $, which equals $ \sum_{q=1}^\infty \phi(q)/q $, where $ \phi $ is Euler's totient function. This sum diverges as $ N \to \infty $ with partial sum approximately $ (6/\pi^2) N $, since the average value of $ \phi(q)/q $ is $ 6/\pi^2 = 1/\zeta(2) $; the divergence mirrors the pole of $ \zeta(s) $ at $ s=1 $, as the Dirichlet series for $ \phi(n)/n $ behaves like $ \zeta(s-1)/\zeta(s) $ near the boundary of convergence.[27][28] The function's "heights" $ 1/q $ analogize probabilities in distributions over reduced fractions, notably in Farey sequences where the uniform measure on $ F_n $ (with approximately $ 3n^2 / \pi^2 $ terms) assigns mass to fractions with denominator $ q $ proportional to $ \phi(q) $. Asymptotically, the probability $ P(Q = q) $ for the denominator $ Q = q $ in this discrete uniform model is $ \phi(q) / \sum_{k=1}^n \phi(k) \approx 2 (q / n^2) $ for $ q \ll n $, but more refined models of "uniform" rationals (e.g., via independent geometric sampling of numerator and denominator) yield spike heights mimicking $ 1/q $ in the resulting empirical distribution $ g(q) $ for ratios $ q = p/(p+r) $.[26][27][29] The integral $ \int_0^1 f(x) , dx = 0 $ underscores the Lebesgue measure zero of the rationals, even though the spikes sum to infinity; this contrast highlights how the function models discrete masses on a set of measure zero, with the spikes approximating a discrete uniform distribution on Farey fractions of order $ n $ as $ n \to \infty $.[30][29] Pedagogically, Thomae's function serves to illustrate mixed probability distributions, combining a discrete component (spikes at rationals with masses tied to $ 1/q $) and a continuous part (zero on irrationals), thereby demonstrating how seemingly continuous phenomena can arise from discrete rational approximations while emphasizing the distinction between countable supports and full-measure continuity in probability spaces.[29]

References

User Avatar
No comments yet.