Is the set of periodic functions from $\mathbb{R}$ to $\mathbb{R}$ a subspace of $\mathbb{R}^\mathbb{R}$?

To show that the set of periodic functions $\mathbb R\to\mathbb R$ is not a vector space, you need to show that the sum of two periodic functions might not be periodic. Let $f(x)$ be periodic with period $\alpha$, let $g(x)$ be periodic with period $\beta$, and let $h(x)=f(x)+g(x)$. Suppose $\beta/\alpha$ is rational and can be written as $\beta/\alpha=r/s$ with $r,s\in\mathbb Z$; then $s\beta=r\alpha$. Consequently, $$ h(x+s\beta)=f(x+r\alpha)+g(x+s\beta)=f(x)+g(x)=h(x) $$ and thus $h$ is periodic. This means that if you want $f+g$ not to be periodic, the ratio of the periods of $f$ and $g$ must be irrational, as in your example.


The idea is that if $f$ is $a$-periodic and $g$ is $b$-periodic, and $\frac{a}{b}\in \mathbb{Q}$, then it's easy to see that $f+g$ is periodic : if $\frac{a}{b} = \frac{p}{q}$ with $p,q\in \mathbb{N}$ then put $c = qa=pb$.

Since $f$ is $a$-periodic, it's also $c$-periodic. Likewise, $g$ is $c$-periodic since it's $b$-periodic.

Thus $f+g$ is $c$-periodic.

So if you want a coutner-example, looking at periods whose quotient is irrational is necessary.