Series $\sum_{n=1}^{\infty}\frac{\cos(nx)}{n^2}$

Solution 1:

See the results posted here, where I show that

$$\sum_{n=-\infty}^{\infty} \frac{\sin^2{a n}}{n^2} = \pi a$$

when $a \in (0,\pi)$. Now, use the fact that

$$\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}$$

and let $S$ be the sum in question. Then

$$\frac{\pi^2}{6} - S = \sum_{n=1}^{\infty} \frac{1-\cos{n x}}{n^2} = 2 \sum_{n=1}^{\infty} \frac{\sin^2{n x/2}}{n^2}$$

Rewrite the last sum as

$$2 \sum_{n=1}^{\infty} \frac{\sin^2{n x/2}}{n^2} = \sum_{n=-\infty}^{\infty} \frac{\sin^2{n x/2}}{n^2} - \left ( \frac{x}{2} \right )^2 = \pi \frac{x}{2} - \frac{x^2}{4}$$

Then

$$\frac{\pi^2}{6} - S = \pi \frac{x}{2} - \frac{x^2}{4} \implies S = \frac{x^2}{4} - \pi \frac{x}{2} + \frac{\pi^2}{6}$$

as was to be shown.

Solution 2:

The sum term $$T(x) = \sum_{n\ge 1}\frac{\cos(nx)}{n^2} = x^2 \sum_{n\ge 1}\frac{\cos(nx)}{(xn)^2}$$ is harmonic and may be evaluated by inverting it's Mellin transform. Put $$S(x) = \sum_{n\ge 1}\frac{\cos(nx)}{(xn)^2}$$ and recall the harmonic sum identity $$\mathfrak{M}\left(\sum_{k\ge 1} \lambda_k g(\mu_k x);s\right) = \left(\sum_{k\ge 1} \frac{\lambda_k}{\mu_k^s} \right) g^*(s)$$ where $g^*(s)$ is the Mellin transform of $g(x).$

In the present case we have $$\lambda_k = 1, \quad \mu_k = k \quad \text{and} \quad g(x) = \frac{\cos x}{x^2}.$$ We need the Mellin transform $g^*(s)$ of $g(x)$ which is $$\int_0^\infty \frac{\cos x}{x^2} x^{s-1} dx = \int_0^\infty \cos x \times x^{(s-2)-1} dx.$$ Now the Mellin transform of $\cos(x)$ was computed at this MSE link and found to be $$\Gamma(s) \cos(\pi s/2)$$ and therefore $$g^*(s) = \Gamma(s-2) \cos(\pi (s-2)/2) = \Gamma(s-2) \cos(\pi s/2 - \pi) = -\Gamma(s-2) \cos(\pi s/2).$$ Therefore the Mellin transform $Q(s)$ of $S(x)$ is given by $$ Q(s) = -\Gamma(s-2) \cos(\pi s/2) \zeta(s) \quad\text{because}\quad \sum_{k\ge 1} \frac{\lambda_k}{\mu_k^s} = \zeta(s).$$ Therefore the Mellin inversion integral for an expansion about zero is $$\frac{1}{2\pi i} \int_{5/2-i\infty}^{5/2+i\infty} Q(s)/x^s ds$$ which we evaluate in the left half-plane $\Re(s)<5/2.$ The cosine term cancels the poles of the gamma function term at odd negative integers and the zeta function term the poles at even negative integers. We are left with just three poles. $$\begin{align} \mathrm{Res}(Q(s)/x^s; x=2) & = \frac{\pi^2}{6x^2} \\ \mathrm{Res}(Q(s)/x^s; x=1) & = -\frac{\pi}{2x} \quad\text{and}\\ \mathrm{Res}(Q(s)/x^s; x=0) & = \frac{1}{4}. \end{align}$$ Hence in a neighborhood of zero, $$S(x) = \frac{\pi^2}{6x^2} -\frac{\pi}{2x} +\frac{1}{4}.$$ Using $T(x) = x^2 S(x)$ this finally yields in a neigborhood of zero that $$T(x) = \frac{\pi^2}{6} -x\frac{\pi}{2} +x^2\frac{1}{4}.$$ Since $T(x)$ is periodic with period $2\pi$ the interval this approximation is good in $(0,2\pi).$

There is a theorem hiding here, namely that certain Fourier series can be evaluated by inverting their Mellin transforms which is not terribly surprising and which the reader is invited to state and prove.

Solution 3:

From here we have

$$\sum_{n=1}^{\infty}\frac{\sin nx}{n}=\frac{\pi-x}{2}\quad (0<x<2\pi)$$

Integrate both sides with respect to $x$

$$-\sum_{n=1}^{\infty}\frac{\cos nx}{n^2}=\frac{\pi x}{2}-\frac{x^2}{4}+C$$

Set $x=0\Longrightarrow C=-\zeta(2)=-\frac{\large \pi^2}{6}$

Giving us

$$\sum_{n=1}^{\infty}\frac{\cos(nx)}{n^2}=\frac{x^2}{4}-\frac{\pi x}{2}+\frac{\pi^2}{6}$$