I was explaining to my students the other day why $\cos(2x)$ is not a linear combination of $\sin(x)$ and $\cos(x)$ over $\mathbb{R}$. Besides the canonical method of using special values of sine and cosine, I noticed something interesting. In the following, all vector spaces are over $\mathbb{R}$.
Consider the linear space $C^\infty_b(\mathbb{R})$ of real-valued bounded smooth functions on $\mathbb{R}$, and take any $c > 0$. We say a function $f \in C^\infty_b(\mathbb{R})$ has property $P(c)$, if for all $k \in \mathbb{N}$ (including $0$), we have $$\sup f^{(k+1)} = c \sup f^{(k)} = -\inf f^{(k+1)} = -c \inf f^{(k)}.$$ Here, the supremum and infimum are of course taken over $\mathbb{R}$, and $f^{(k)}$ is the $k$-th derivative of $f$, with the convention that $f^{(0)}=f$.
Define $$S(c) = \{f \in C^\infty_b(\mathbb{R}) \,\vert\, f \text{ has property } P(c)\}.$$ Since for fixed $a,b$ and all $x$, we have $a \sin(x) + b \cos(x) = \sqrt{a^2 + b^2} \sin(x + \theta) $ for some fixed $\theta$, it is clear that all linear combinations of $\sin(cx)$ and $\cos(cx)$ belong to $S(c)$. In particular, linear combinations of $\sin(x)$ and $\cos(x)$ are all in $S(1)$, while $\cos(2x)$ is not.
Question: is it true that $S(c) = \operatorname{Vect}\bigl(\sin(cx), \cos(cx)\bigr)$?
If $f \in S(1)$ and $f$ is periodic, then using Fourier series, I can prove that $f$ is indeed $2 \pi$-periodic and $f \in \operatorname{Vect}\bigl(\sin(x), \cos(x)\bigr)$ with some work. Although I haven't checked this yet, I also believe that the periodic case for $S(c)$ where $c>0$ is arbitrary could be established by a more elaborate Fourier series argument (of course, I could be wrong). So the real interest lies in treating the non-periodic case, i.e., answering the following
Special case: does $f \in S(c)$ imply $f$ is periodic?
At first, I suspect the answer to the above special case is negative. But after some experiment, I am not so sure. Note that the radius of convergence of the Taylor series (say around $0$) for all $f \in S(c)$ is infinite, so the Taylor series of $f$ converges to $f$ itself. In particular, all functions in $S(c)$ are automatically analytic, so one does not have much freedom when trying to construct a (counter-)example.
If the answer turns out to be negative, then can one at least assert that $S(c)$ is a linear subspace? What if we only consider periodic functions for some fixed period in case $S(c)$ is not a linear subspace? Of course, these probably depend on the explicit form of the answer which is not yet known to me, and all of these are just some (perhaps stupid and naive) speculation on an old exercise of a first-year undergraduate. But it seems interesting, and any thought is appreciated.
Edit: I was a bit careless in formulating the question since the questions for all different $c$ are equivalent merely by rescaling, so one can simply assume $c = 1$, in which case we still have much work to do.
Edit 2: Proof of the periodic case can be found here in case anyone is interested.