TITLE: Value of $\sum_{n=1}^{\infty} \frac{\cos (n)}{n}$
QUESTION [14 upvotes]: I was trying to calculate the value of the series $\displaystyle \sum_{n=1}^{\infty} \dfrac{\cos (n)}{n}$ and I got an answer which I think could be right, but I'm not sure about some of the steps I took to get there. I was wondering if someone could provide some more insight so I can clear my doubts, and also check if I actually got the correct value.
First of all, I used Dirichlet's test for the convergence of the series, since $a_n = \dfrac{1}{n}$ is monotonic and $\displaystyle \lim_{n \to \infty} a_n = 0$, and the cosine partial sums can be bounded by a constant not dependent on $n$ (I'm pretty sure this is right since I looked other ways to do it, so I won't list exactly what I did to get the bound).
With that out of the way, I tried taking the expression $\dfrac{\cos(n)}{n}$ and rewriting it as something I could attempt to sum, and got this:
$$\displaystyle \int_1^{\pi} \sin(nx) \, dx = \left. -\dfrac{\cos(nx)}{n} \right|_1^{\pi} = \dfrac{(-1)^{n+1}}{n} + \dfrac{\cos(n)}{n}$$
So
$$\displaystyle \int_1^{\pi} \sin(nx) \, dx + \dfrac{(-1)^{n}}{n} = \dfrac{\cos(n)}{n}$$
And then
$$\displaystyle \lim_{n \to \infty} \displaystyle \sum_{k=1}^{n}\left(\displaystyle \int_1^{\pi} \sin(kx) \, dx + \dfrac{(-1)^{k}}{k}\right) = \displaystyle \lim_{n \to \infty} \displaystyle \sum_{k=1}^{n} \dfrac{\cos(k)}{k}$$
Then I tried separating the left side member into two sums, since
$$\displaystyle \sum_{n=1}^{\infty} \dfrac{(-1)^n}{n} = \displaystyle -\sum_{n=1}^{\infty} \dfrac{(-1)^{n+1}}{n} = -\ln (2)$$
I believe the latter equality can be derived using the alternate series test for the convergence of the series, and the Taylor expansion around $x = 0$ of $\ln {(1+x)}$ along with Abel's theorem. As for the other sum, this is the step I'm not sure about. I did
$$\displaystyle \lim_{n \to \infty} \displaystyle \sum_{k=1}^{n}\left(\displaystyle \int_1^{\pi} \sin(kx) \, dx\right) = \displaystyle \lim_{n \to \infty} \displaystyle \int_1^{\pi} \left(\displaystyle \sum_{k=1}^{n} \sin(kx)\right) \, dx$$
I'm not sure that's valid, and if it is I'm not sure why: I thought it would be fine since the partial sums could be arranged that way before taking the limit, but I suspect this thinking isn't correct, and I can't just swap the sum and the integral anytime without affecting the result. But anyways, if we take it as valid, then we can get a value for the sum by doing
$$\cos {(nx+\dfrac{x}{2})} - \cos {(nx-\dfrac{x}{2})} = -2\sin {(nx)}\sin{\left(\dfrac{x}{2}\right)}$$
So
$$\sin{(nx)} = \dfrac{\cos {(nx-\frac{x}{2})} + \cos {(nx+\frac{x}{2})}}{2\sin{\left(\frac{x}{2}\right)}}$$
And then
$$\displaystyle \sum_{k=1}^{n} \sin{(kx)} = \displaystyle \sum_{k=1}^{n} \dfrac{\cos {(kx-\frac{x}{2})} + \cos {(kx+\frac{x}{2})}}{2\sin{\left(\frac{x}{2}\right)}}$$
Which telescopes to
$$\displaystyle \sum_{k=1}^{n} \sin{(kx)} = \dfrac{\cos {\left(\frac{x}{2}\right)}-\cos {\left(\frac{2n+1}{2} \cdot x\right)}}{2\sin{\left(\frac{x}{2}\right)}}$$
Returning to the integral, we need to evaluate
$$\displaystyle \lim_{n \to \infty} \displaystyle \int_1^{\pi} \left(\displaystyle \sum_{k=1}^{n} \sin(kx)\right) \, dx = \displaystyle \lim_{n \to \infty} \displaystyle \int_1^{\pi} \frac{\cos {\left(\frac{x}{2}\right)}-\cos {\left(\frac{2n+1}{2} \cdot x\right)}}{2\sin{\left(\frac{x}{2}\right)}} \, dx$$
I again tried separating it in the sum of the integrals. The first one
$$\displaystyle \int_1^{\pi} \frac{\cos {\left(\frac{x}{2}\right)}}{2\sin{\left(\frac{x}{2}\right)}} \, dx = \displaystyle \int_{\sin {\frac{1}{2}}}^1 \dfrac{1}{u} \, du = -\ln({\sin{\frac {1}{2}}})$$
Via substitution $u = \sin{\frac{x}{2}}$
This won't change when $n$ goes to infinity. As for the second one
$$-\dfrac{1}{2} \displaystyle \int_1^{\pi} \dfrac{\cos{\left(nx+\frac{x}{2}\right)}}{\sin{\left(\frac{x}{2}\right)}} \, dx = -\dfrac{1}{2}\left(\displaystyle \int_1^{\pi} \dfrac{\cos{(nx)}\cos{\left(\frac{x}{2}\right)}}{\sin{\left(\frac{x}{2}\right)}} \, dx - \displaystyle \int_1^{\pi} \sin(nx) \, dx \right) = $$
$$= -\dfrac{1}{2}\left(\displaystyle \int_1^{\pi} \dfrac{\cos{(nx)}\cos{\left(\frac{x}{2}\right)}}{\sin{\left(\frac{x}{2}\right)}} \, dx + \displaystyle \left. \frac{\cos(nx)}{n} \right|_1^{\pi} \right)$$
Both of these integrals go to 0 as $n$ goes to infinity, applying the Riemann-Lebesgue lemma for the first one, since the function $f(x) = \cot{\left(\frac{x}{2}\right)}$ is continuous on $[1,\pi]$. Putting it all together gives
$$\displaystyle \displaystyle \sum_{n=1}^{\infty} \dfrac{\cos(n)}{n} = -\ln2-\ln{\left(\sin{\frac{1}{2}}\right)} = \boxed{-\ln{\left(2 \cdot \sin{\frac{1}{2}}\right)}} \approx 0.0420195$$
I used Octave to try and check the result: setting $n = 10^6$ gave me
$$S_{10^6} \approx 0.042020$$
Because of this, I'm inclined to think I got the correct answer, but I still doubt some of the steps I took (mainly the interchanging sum and integral one).
Thanks in advance. I'm sorry if I didn't make myself clear, english isn't my first tongue. I did some search as to find something related to this value, but couldn't find anything. Very sorry if its been answered before.

REPLY [5 votes]: If  $\log$ is  the principal branch of logarithmic function, we have that $-\log(1-z)=\sum^\infty_{n=1}\frac{z^n}{n}$ for all $|z|<1$. If $z=re^{i\theta}$ with $0<r<1$,  then the  Abel sum of the sawtooth function $$f(\theta)=\frac{1}{2i}\sum_{|n|\geq1}\frac{e^{in\theta}}{n}=\sum^\infty_{n=1}\frac{\sin(n\theta)}{n}$$
is given by
$$ \begin{align} A_rf(\theta)&= \sum^\infty_{n=1}\frac{r^n\sin(n\theta)}{n}= \frac{1}{2i}\sum_{|n|\geq1}\frac{r^{|n|}e^{in\theta}}{n}=\frac{1}{2i}\sum^\infty_{n=1}\frac{r^n}{n}\Big(e^{in\theta}-e^{-in\theta}\Big)\\
    &=-\frac{1}{2i}\big(\log(1-re^{i\theta})-\log(1-re^{-i\theta})\big)=\operatorname{Im}\big(-\log(1-re^{i\theta})\big)\\
    &= -\operatorname{arg}(1-re^{i\theta}).
  \end{align}$$
Thus, for $0<\theta<2\pi$, we have that $\frac{1}{2}(\pi-\theta)=f(\theta)=\lim_{r\rightarrow1-}A_rf(\theta)=-\operatorname{arg}(1-e^{i\theta})$. Now we consider
$$\begin{align}
  -\log(1-re^{i\theta})&=\sum^\infty_{n=1}\frac{r^n\cos(n\theta)}{n} + i\sum^\infty_{n=1}\frac{r^n\sin(n\theta)}{n}\nonumber\\
&=  -\log(|1-re^{i\theta}|) - i\arg(1-re^{i\theta})\tag{2}\label{sawtooth-log}
\end{align}$$
The second term the right hand side of $\eqref{sawtooth-log}$ converges to $i\,f(\theta)$ for $0<\theta<2\pi$, and   the first term  converges to the $2\pi$--periodic even function $$g(\theta):=-\log(|1-e^{i\theta}|)=-\log\big(2|\sin(\theta/2)|\big)$$
Notice that $g$ is unbounded and that $\lim_{\theta\rightarrow0}g(\theta)=\infty=\lim_{\theta\rightarrow2\pi}g(\theta)$.  Since $\sin(t)\cong t$ as $t\rightarrow0$ and $\lim_{t\rightarrow0+}t^\alpha\log(t)$ for any $\alpha>0$, we have that $g\in\mathcal{L}_p(\mathbb{S}^1)$ for all $p\geq1$. Since $\theta\mapsto\sum^\infty_{n=1}\frac{\cos(n\theta)}{n}$ is square integrable over $\mathbb{S}^1$,
$$\log\big(2|\sin(\theta/2)|\big)=-\sum^\infty_{n=1}\frac{\cos(n\theta)}{n}$$
at $\theta=1$, one gets
$$-\log\big(2|\sin(1/2)|\big)=\sum^\infty_{n=1}\frac{\cos(n)}{n}$$