The popcorn function
Statement
Define by if is irrational, , and if is a non-zero rational written in lowest terms with . Prove that is continuous at every irrational number and discontinuous at every rational number.
Hint
At an irrational and for a given , only finitely many rationals near have denominator at most . Shrink the neighbourhood to avoid all of them.
Show solutionHide solution
Solution
Rational points. Let be rational. Then . Every neighbourhood of contains irrational numbers, where , so cannot tend to . Hence is discontinuous at .
Irrational points. Let be irrational and . Choose an integer .
*Finitely many bad rationals.* Consider the rationals in whose denominator (in lowest terms) is at most . For each fixed denominator there are only finitely many such fractions in a bounded interval, so the set of all of them is finite. Since is irrational, , so
*Checking.* Let . If is irrational, . If is rational, then , so and . In both cases .
Conclusion. is continuous exactly at the irrational numbers.
Remark. A function can be continuous at infinitely many points and discontinuous at infinitely many others, with both sets dense. The graph looks like popcorn: tall kernels above each rational, flattening toward . The reverse is impossible: there is no function continuous exactly at the rationals.