Thomae's function
If you are having difficulty understanding this article, you might wish to learn more about algebra, functions, and mathematical limits.
The popcorn function is the real-valued function f(x) defined as follows
Here it is assumed that rational numbers are written in normalized form with p, q having no common prime factors and with .
The popcorn function is perhaps the simplest example of a function with a complicated set of discontinuities: f(x) is continuous at all irrational numbers and discontinuous at all rational numbers. This may be seen informally as follows: if x is irrational, and y is very close to x, then either y is also irrational, or y is a rational number with a large denominator. Either way, f(y) is close to f(x)=0. On the other hand, if x is rational and is very close to x, then it is also true that either y is irrational, or y is a rational number with a large denominator. Thus it follows that
The monicker "popcorn function" stems from the fact that the graph of this function resembles a snapshot of popcorn popping.