Consider the space of all bounded continuous functions , with the uniform norm . Let be its subset that consists of all periodic continuous functions: recall that is periodic if there exists such that for all .

The set is not closed in the topology of . Indeed, let be the distance from to nearest integer. The function is periodic with . Therefore, each sum of the form is periodic with . Hence the sum of the infinite series is a uniform limit of periodic functions. Yet, is not periodic, because and for (for every there exists such that is not an integer).

The above example (which was suggested to me by Yantao Wu) is somewhat similar to the Takagi function, which differs from it by the minus sign in the exponent: . Of course, the Takagi function is periodic with period .

Do we really need an infinite series to get such an example? In other words, does the set contain an elementary function?

A natural candidate is the sum of trigonometric waves with incommensurable periods (that is, the ratio of periods must be irrational). For example, consider the function whose graph is shown below.

Since and for all , the function is not periodic. Its graph looks vaguely similar to the graph of . Is a uniform limit of periodic functions?

Suppose is a -periodic function such that . Then , hence for all , hence . By the definition of this implies and for all . The following lemma shows a contradiction between these properties.

**Lemma**. If a real number satisfies for all , then is an integer multiple of .

**Proof**. Suppose is not an integer multiple of . We can assume without loss of generality, because can be replaced by to get it in the interval and then by to get it in . Since , we have . Let be the smallest positive integer such that . The minimality of implies , hence . But then , a contradiction.

The constant in the lemma is best possible, since for all .

Returning to the paragraph before the lemma, choose so that . The lemma says that both and must be integer multiples of , which is impossible since they are incommensurable. This contradiction shows that for any periodic function , hence is not a uniform limit of periodic functions.

The above result can be stated as . I guess is actually . It cannot be greater than since for all . (**Update**: Yantao pointed out that the density of irrational rotations implies the distance is indeed equal to 1.)

**Note:** the set is a proper subset of the set of (Bohr / Bochner / uniform) **almost periodic functions** (as Yemon Choi pointed out in a comment). The latter is a linear space while is not. I was confused by the sentence “Bohr defined the uniformly almost-periodic functions as the closure of the trigonometric polynomials with respect to the uniform norm” on Wikipedia. To me, a trigonometric polynomial is a periodic function of particular kind. What Bohr called *Exponentialpolynom* is a finite sum of the form where can be any real numbers. To summarize: the set considered above is the **closure** of while the set of almost periodic functions is the **closed linear span** of . The function is an example of the latter, not of the former.