---
tag: 0HJ28H9Y95
kind: example
name: Thomae's function
aliases: [popcorn-function]
msc: [26A15]
uses: [0EEE2CZB2A, 000MXHEY22]
sources:
  - url: https://en.wikipedia.org/wiki/Thomae%27s_function
    locator: Properties
same_as:
  wikidata: Q776401
  wikipedia: Thomae's function
---

## Example

Define $f \colon \mathbb{R} \to \mathbb{R}$ as follows.
For irrational $x$, $f(x) = 0$. For rational $x = p/q$ in lowest terms with $q > 0$, $f(x) = 1/q$.
Then $f$ is [[continuous|0EEE2CZB2A]] at each irrational number and discontinuous at each rational number.

## Remarks

Let $a$ be irrational and let $\varepsilon > 0$. Only finitely many $p/q$ near $a$ have $1/q \ge \varepsilon$. So $f(x) < \varepsilon$ for all $x$ close enough to $a$.
At a rational $a$, irrational points near $a$ have value $0$, but $f(a) > 0$.
The function is periodic with period $1$.
No function on $\mathbb{R}$ is continuous exactly at the rationals.

## Explanations

### L1 human

The value $1/q$ is small when the denominator $q$ is large.
Near an irrational point, all rationals have large denominators, so the values there are small.
