TITLE: Does there exist a nonconstant, periodic, real analytic function with period 1 and rational Maclaurin coefficients?
QUESTION [8 upvotes]: Does there exist a nonconstant, real analytic function $f \colon \mathbb{R} \to \mathbb{R}$ such that $f$ is periodic with period 1 and whose Maclaurin coefficients are all rational?
(The function $\sin x$ satisfies all the conditions except that its period isn't 1.)
I can't recall exactly what I was thinking about when this question occurred to me and my primary motivation now is curiosity. Note that if the answer is no, a proof that doesn't use the irrationality of $\pi$ would be an alternative way to prove irrationality of $\pi$ because of the function $\sin(2\pi x)$.
Also, WLOG, we may assume $f(0)=0$ and if we define the vector $c = (c_k)$ where $f(x) = \sum\limits_{k = 1}^{\infty} \frac{c_k}{k!}x^k$ and let $v = (1, 1/2!, 1/3!, 1/4!, \dots)$, then by comparing the derivatives of $f$ at 0 and 1, we get that for all nonnegative integers $n$,
$$v \cdot C^n c = 0,$$
where $C$ shifts the components of a vector one space to the left.

REPLY [12 votes]: Yes, such $f$ exist, and can even be taken to be entire,
and with a preassigned finite initial segment $c_0,c_1,\ldots,c_d$
of the sequence of $x^k/k!$ coefficients.
Indeed if $f(x) = \sum_{k=0}^\infty a_k \sin^k (2\pi x)$
then $f$ is entire provided $a_k \rightarrow 0$ quickly enough,
say $a_k \ll 1/k!$; and the map from $\{a_k\}$ to $\{c_k\}$
is linear and invertible, with $a_k$ a linear combination of
$c_0,\ldots,c_k$ and $c_k$ a linear combination of $a_0,\ldots,a_k$
for each $k$.  So, solve for $a_0,\ldots,a_d$, and then inductively
choose small $a_{d+1}, a_{d+2}, a_{d+3}, \ldots$ to make each of
$c_{d+1}, c_{d+2}, c_{d+3}, \ldots$ rational.  (One way to
avoid invoking the Axiom of Choice here is to fix some
enumeration of ${\bf Q}$ and then at each step with $k>d$
use the least-indexed $c_k$ that makes $|a_k| < 1/k!$.)
[I see now that David Speyer gave much the same solution
in a comment (using $g_k$ for what I called $a_k$),
though without bothering to make $f$ entire
or preassign the start of its Taylor expansion.]