Order of convergence of series It is known that for $ x \in (0,\pi] $
$$ -\log\left(2\sin\left(\frac{x}{2}\right)\right) = \sum_{n=1}^{\infty}\frac{\cos(x n)}{n}. $$
I was wondering on what the rate of the convergence of the series is, i.e. if we let
$$ S_N(x) := \sum_{n=1}^{N}\frac{\cos(x n)}{n}, $$
what is the order of convergence of the series $ S_N $ to its limit as $ N \to \infty $. How could one find a representation
$$ S_N(x) = -\log\left(2\sin\left(\frac{x}{2}\right)\right) + \mathcal{O}(g(N)),$$
for some function $ g $ that is to be determined; or equivalently
$$ \left|S_N(x) + \log\left(2\sin\left(\frac{x}{2}\right)\right)\right| \leq C g(N), $$
for some constant $ C > 0 $.
 A: Note that
$$S_{M,N}(x)=\sum_{n=N}^{M}\cos(x n), \quad M \ge N$$ satisfies
$$|S_{M,N}(x)| \le \frac{C}{x}, \quad 0<x\le \pi$$ for some absolute constant $C > 0$ since
$$S_{N,0}(x)=\frac{\sin ((N+1)x/2)}{\sin (x/2)}\Re e^{iNx/2} \quad \text{and} \quad \sin (x/2) \ge \frac{x}{\pi}, \quad 0 \le x \le \pi,$$
while
$$|S_{M,N}(x)| \le |S_{M,0}(x)|+|S_{N-1,0}(x)|.$$
Now
$$\left|S_N(x) + \log\left(2\sin\left(\frac{x}{2}\right)\right)\right|=\left|\sum_{n=N+1}^{\infty}\frac{\cos(x n)}{n}\right|,$$ therefore, it is enough to show that
$$\left|\sum_{n=N+1}^{M}\frac{\cos(x n)}{n}\right| \le \frac{C}{Nx}$$ for some constant $C > 0$ and $M > N$ arbitrary, and we are done by letting $M \to \infty$.
By summation by parts, we have that
$$\sum_{n=N+1}^{M}\frac{\cos(x n)}{n}=\sum_{p=N+1}^{M-1}S_{p,1}(x)\left(\frac{1}{p}-\frac{1}{p+1}\right) + \frac{S_{M,1}(x)}{M} - \frac{S_{N,1}(x)}{N+1}.$$
Then, using the bound obtained above for $S_{M,N}$
\begin{align}
\left|\sum_{n=N+1}^{M}\frac{\cos(x n)}{n}\right| &\leq \left|\sum_{p=N+1}^{M-1}S_{p,1}(x)\left(\frac{1}{p}-\frac{1}{p+1}\right)\right| + \frac{|S_{M,1}(x)|}{M} + \frac{|S_{N,1}(x)|}{N+1} \\
&\leq \frac{C}{Mx} + \frac{C}{(N+1)x} + \sup_{p}|S_{p,1}(x)|\sum_{p=N+1}^{M-1}\left(\frac{1}{p} - \frac{1}{p+1}\right) \\
&= \frac{2C}{(N+1)x} \leq \frac{C'}{Nx},
\end{align}
for some constant $C' > 0$. Therefore, we are done!
