Function with arbitrary small period

You're right. The characteristic function of the rationals is periodic of period $1/n$ for all $n \in \mathbb N$ because $x$ is rational iff $x+1/n$ is rational.


You're correct.

Let $\epsilon$ be arbitrarily small. You need to prove that there exists some $0<p<\epsilon$ such that $D(x)=D(x+p)$ for all $x\in \mathbb{R}$.

We know that $\epsilon$ is some positive real number, so there exists some $p\in \mathbb{Q}$ such that $0<p<\epsilon$. Let's look at an arbitrary $x\in \mathbb{R}$ and see if our property is satisfied or not:

If $x$ is rational, then $D(x)=1$. Since the sum of two rationals is rational, then $D(x+p)=1$ too.

If $x$ is irrational, then $D(x)=0$. Since the sum of a rational and an irrational is irrational, then $D(x+p)=0$ too.

So if we choose our period to be $p$, our property is satisfied.


Another way to look at it is to think about the set of periods, i.e.

$$P = \{ p \in \mathbb{R} | f(x + p) = f(x) \text{ for all } x \in \mathbb{R} \}$$

Zero is clearly a member of this set no matter what f is. P is closed under addition and negation. So clearly P is a group over addition. So, if you want to find a function that has arbitrarily small periods, you want to find a subgroup of $\mathbb{R}$ that has arbitrarily small values. $\mathbb{Q}$ is the obvious choice, so the characteristic function for $\mathbb{Q}$ works, as stated in another answer.