﻿ Explanation of the Dirichlet function | Bits of Pancake

## Explanation of the Dirichlet function

My calculus teacher gave an example of a function that was discontinuous everywhere, the Dirichlet function. It indicates whether a number is rational or irrational:

$$D(x) = \begin{cases}1 & \text{ if } x \in \mathbb{Q} \\ 0 & \text{ otherwise }\end{cases}$$

That’s cool, but what’s even cooler is that there exists this expression for the Dirichlet function:
$$D(x) = \lim_{m \to \infty} \lim_{n \to \infty} [\cos(m! \pi x)]^{2n}$$

Unfortunately, neither Wikipedia nor Wolfram’s web site explains why this is equivalent to the Dirichlet function, so I spent a long time thinking about it. Here’s what I’ve come up with.

Let’s consider a simplified version first. Consider the function $f(x) = \cos^2\pi x$. It equals $1$ so long as $x$ is an integer, and a positive decimal less than $1$ otherwise. This is simple to see by graphing the function.

Now, if you exponentiate the result an infinite number of times — i.e., $\lim_{n \to \infty} f(x)^n$ — you end up with two outcomes. If $x$ is an integer, then $f(x) = 1$, and $f(x)$ exponentiated infinitely will still equal $1$. If $x$ is not an integer, then $f(x) < 1$ and will therefore get smaller after every exponentiation, eventually hitting $0$. That is to say, the limit will equal $0$ for non-integers. We've basically created an indicator function for integers: $$\operatorname{isInteger}(x) = \lim_{n \to \infty} (\cos\pi x)^{2n} = \begin{cases}1 & \text{ if } x \in \mathbb{Z} \\ 0 & \text{ otherwise }\end{cases}$$ Now we can rewrite the Dirichlet function in terms of this $\operatorname{isInteger}$ function: $$D(x) = \lim_{m \to \infty} \operatorname{isInteger}(m! x)$$ This is the especially cool part: we can show that if $x$ is rational, then $\lim_{m \to \infty} m! x$ is an integer. If we let $m$ approach $\infty$, then we have a product of all positive integers multiplied by the input $x$. If $x$ is rational, then $x$ can be written as a fraction of integers $\frac{p}{q}$ where $p$ and $q$ are integers. The $q$ will then cancel with one of the integers in the factorial, thus making the whole product $m! x$ an integer. In the other case — where $x$ is irrational — this won't happen, and $m!x$ will not be an integer. Visually, for rational numbers (because $x = \frac{p}{q}$): $$\lim_{m \to \infty} m! x = \lim_{m \to \infty} \frac{p}{\not{q}} \cdot (1 \cdots \not{q} \cdots m)$$

Now if we plug the either-integer-or-non-integer result into our $\operatorname{isInteger}$ function, what results is an indicator function for rationality — the Dirichlet function.

March 28, 2012, 2:05pm by Casey

1. Perfect explanation! Thanks so much!

2. I have another confusion though.

CONSIDER x=e, we have D(x)=0.
That’s because e is irrational.

Now, e = 1/0! + 1/1! + 1/2! + … + 1/m! where m approaches infinity.

Now, if you implement the cosine form of the Dirichlet function, then, the argument of the cosine is

m!*x*pi where m approaches infinity.
=m!*(1/0! + 1/1! + 1/2! + … + 1/m!)*pi where m approaches infinity
=(m!/0! + m!/1! + m!/2! + … + m!/m!)*pi where m approaches infinity

By inspection each term in the series is now an integer greater than or equal to 1.

Thus, the argument is essentially integer times pi.

Taking cosine and raising to the power of an even number should give 1.

We have thus established that the cosine representation of D(e) = 1 while indicator representation of D(e) = 0.

• The problem is that $e \ne \tfrac{1}{0!} + \cdots + \tfrac{1}{m!}$. Instead, $e = \lim_{m \to \infty} (\tfrac{1}{0!} + \cdots + \tfrac{1}{m!})$. This turns out the make all the difference; in the expression $m! x \pi$, we take the limit within $x$ first, followed by the limit as $m \to \infty$ second. Your proof, however, correctly says that $\tfrac{1}{0!} + \cdots + \tfrac{1}{m!}$ is rational for any (finite) integer $m$.