Possible generalizations of $\sum_{k=1}^n \cos k$ being bounded I just read in this month's MAA Math Horizons the problem:
Show that $\sum_{k=1}^n \cos k$ is bounded.
After a bit of floundering, I realized that the key is to
write this as the real part of
$\sum_{k=1}^n e^{ik}$ 
and sum the geometric series.
I then realized that this also shows that
$\sum_{k=1}^n \cos(ak)$ and
$\sum_{k=1}^n \sin(ak)$ are also bounded
for any real $a$ not a multiple of $2\pi$,
since the denominator of the expression that results
is $e^{i a}-1$, and this is nonzero for any such $a$.
So I wondered if there is a generalization
that doesn't depend on the properties
of $e^{ix}$, and came up with this:
If $f$ is continuous and periodic with shortest period $p$,
$\int_0^p f(x)\, dx = 0$,
and $q$ is not a multiple of $p$,
is $\sum_{k=1}^n f(qk)$  bounded?
If this is false, are there any additional conditions
on $f$ or $q$ (such as $f$ having a bounded derivative or $q/p$ being irrational)
 that would make it true?

(added later, after the comments and the very nice work by Micah)
Here is another possible condition:
$q/p$ is not an integer and, in every period of $f$,
for every $f(x)$, there is at most one other $z$
such that $f(z) = f(x)$.
(This would rule out the possibility suggested by
Thomas Andrews.)

I claim that the sequence $s_n=\sum_{k=0}^{n-1} f(kq)$ is bounded, for a given $q$, if the following hypotheses are satisfied:


*

*$f$ is $p$-periodic, and its integral over an entire period vanishes,

*$q$ is an irrational multiple of $p$,

*the irrationality measure of $q/p$ is finite (say, $q/p$ has irrationality measure $\mu$),

*$f$ is $C^k$ for some $k>\mu$. 


In particular, if $f$ is $C^3$, the sequence is bounded for almost all $q$, including all $q$ where $q/p$ is algebraic but irrational (by the Thue-Siegel-Roth theorem).
First of all, we may suppose without loss of generality that $f$ has period $2\pi$. As $\mu \geq 2$ for all irrational $q$, we need only consider those $f$ which are at least $C^3$. In particular, this means $f$ has an absolutely convergent Fourier series $f(x)=\sum_{-\infty}^\infty a_m e^{imx}$. Since $\int_0^{2\pi} f = 0$, $a_0=0$. Now, 
$$
s_n=\sum_{k=0}^{n-1} f(kq)= \sum_{k=0}^{n-1} \sum_{m=-\infty}^\infty a_m e^{imkq}=\sum_{m=-\infty}^\infty a_m \left(\sum_{k=0}^{n-1}e^{imkq}\right)
$$
(where we've used absolute convergence to swap the order of summation). 
As $a_0=0$ and $q/2\pi$ is irrational, the common ratio $e^{imq}$ in this last sum is never $1$, and so we can apply the general form of the geometric series formula to obtain
$$
s_n=\sum_{m=-\infty}^\infty a_m \left(\frac{1-e^{imnq}}{1-e^{imq}}\right)=\sum_{m=-\infty}^\infty a_m e^{im(n-1)q/2} \frac{\sin \frac{mnq}{2}}{\sin \frac{mq}{2}} \, .
$$
Now, let $\Phi_n(x)=\frac{\sin (nx/2)}{\sin (x/2)}$. It suffices to show that $\sum_{m=-\infty}^\infty |a_m \Phi_n(mq)|$ is bounded independently of $n$. Note that, for any $x$ with $0 < |x| < \pi$, we have $|\Phi_n(x)| \leq \left|\frac{1}{\sin (x/2)}\right| \leq \frac{\pi}{|x|}$.
Choose $\alpha$ with $\mu < \alpha < k$. Since $\alpha > \mu$, the inequality
\begin{equation}
\left| \frac{q}{2\pi} - \frac{\ell}{m}\right| > \frac{1}{|m|^\alpha}
\end{equation}
holds for all but finitely many choices of $(\ell, m) \in \Bbb{Z}^2$.
We will now divide and conquer: first we will show that the sum of all the terms in which the inequality holds for $m$ is bounded independent of $n$; then we will show that the sum of all the terms in which it does not hold is also so bounded.
Suppose the inequality holds for some $m$; choose $\ell \in \Bbb{Z}$ so that $|mq-2\pi\ell|<\pi$. Then by periodicity we have
$
\Phi_n(mq)=\Phi_n(mq-2\pi\ell)
$;
by the bound we just derived on $\Phi_n$ it follows that
$$
\left|\Phi_n(mq)\right|<\frac{\pi}{|mq-2\pi \ell|} = \frac{1}{2|m||q/2\pi - \ell/m|} < \frac{1}{2}|m|^{\alpha-1}
$$
by our irrationality measure inequality. Since $f$ is $C^k$, its Fourier coefficients $a_m$ are all bounded by $\frac{2C}{|m|^k}$ for some uniform constant $C$. So we can bound the sum over all the $m$ such that the irrationality measure inequality holds by
$$
\sum_{m=-\infty}^\infty \frac{C}{|m|^k} |m|^{\alpha-1}=\sum_{m=-\infty}^\infty C |m|^{\alpha-k-1} \, ;
$$
since $\alpha < k$, this is a convergent sum (and is independent of $n$, since $C$ depends only on $f$).
On the other hand, there are only finitely many $m$ such that the inequality does not hold. Let $\{m_1,\dots\,m_j\}$ be those $m$; then it follows immediately from our inequality for $\Phi$ that the sum of these terms is bounded by $\sum_j a_{m_j} \frac{\pi}{|m_j q - 2\pi \ell_j|}$, where the $\ell_j$ are chosen so that $|m_j q - 2\pi \ell_j|\leq \pi$. Since this is a finite sum independent of $n$, we are done.
