# The Fourier series $\sum_{n=1}^\infty (1/n)\cos nx$

The series $$\sum_{n=1}^\infty \frac{\sin nx}{n}$$ is the Fourier series of the odd $2\pi$-periodic extension of $(\pi-x)/2, 0<x<\pi$.

My question is : $$\sum_{n=1}^\infty \frac{\cos nx}{n}$$ is the Fourier series of the even $2\pi$-periodic extension of what function?

-
This is Example 1.6.3 in Arne Broman, "Introduction to partial differential equations", 1970. –  TCL Apr 23 '13 at 23:30

We can ask Mathematica to sum the series and see what comes out.

Simplify[ComplexExpand[Re@Sum[Cos[n*x]/n, {n, 1, Infinity}]]]


$$-\log(2-2\cos(x))/2$$

Note that I've grabbed just the real part because numerical experiments show that the imaginary part is zero. Of course, we should always check these kinds of computations. Note for example, that this function has a logarithmic singularity at $x=0$, exactly as we'd expect, since the series boils down to the Harmonic series at $x=0$. We can also try to use the computer to compute the Fourier coefficients of the result. I can't quite seem to get the result fully symbolically, but here's a partial result:

(2/Pi) Table[
Integrate[- Log[2 - 2 Cos[x]]*Cos[n*x]/2, {x, 0, Pi}],
{n, 1, 10}]
(* Out: {1, 1/2, 1/3, 1/4, 1/5, 1/6, 1/7, 1/8, 1/9, 1/10} *)


Well, that looks good! I guess we could also look at a plot:

Plot[{
-Log[2 - 2 Cos[x]]/2,
Sum[Cos[n*x]/n, {n, 1, 15}]
}, {x, -8, 8}]


-
Good use of computer! But can anyone prove this? –  TCL Mar 5 '13 at 20:56

The function $-\frac{1}{2}\ln(2-2\cos x)$ simplifies to $f(x)=-\ln(2\sin(x/2))$. We will show that the Fourier cosine series of $f(x), 0<x<\pi,$ is $$\sum_{n=1}^\infty \frac{\cos nx}{n}.$$ Firstly, $$\frac{1}{\pi}\int_0^\pi f(x)\,dx=\frac{1}{\pi}\int_0^\pi \ln 2+\ln(\sin(x/2))\,dx=0$$ because $$\int_0^\pi \ln(\sin(x/2)\,dx=2\int_0^{\pi/2}\ln(\sin(u))\,du=\int_0^\pi \ln(\sin(u))\,du=-\pi\ln 2$$ where the last equality can be found in Ahlfors' Complex Analysis p. 159. Let $n\ge 1$ be an integer. Using integration by parts with $u=\ln(\sin(x/2)$ and $dv=\cos(nx)\,dx$, and the fact that $\lim_{x\to 0^+}\sin(nx)\ln(\sin(x/2)=0$, we get (note that $\int_0^\pi \ln2\cos(nx)\,dx=0$) $$\int_0^\pi f(x)\cos nx\,dx=\frac{1}{2n}\int_0^\pi \cot(x/2)\sin nx\,dx=\frac{\pi}{2n}$$ where the last equality is from here. This proves that $$\frac{2}{\pi}\int_0^\pi f(x)\cos nx\,dx=\frac{1}{n}.$$

Note that the even $2\pi$-periodic extension of $-\ln(2\sin(x/2)), 0<x<\pi$ is the $2\pi$-periodic function $$-\ln\left|2\sin\left(\frac{x}{2}\right)\right|=\ln\left| \frac{1}{2}\csc\left(\frac{x}{2}\right)\right|,$$ $-\infty<x<\infty$.

-

It seems to have escaped attention that this sum may be evaluated using harmonic summation techniques which can be an instructive exercise and usually succeeds on Fourier series. Here is an opportunity to contribute to an interesting, diverse and visually appealing series of posts.

Introduce $S(x)%$ given by $$S(x) = \sum_{n\ge 1} \frac{1}{n}\cos(nx).$$

The sum term is harmonic and may be evaluated by inverting its Mellin transform.

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 = \frac{1}{k}, \quad \mu_k = k \quad \text{and} \quad g(x) = \cos(x).$$ We need the Mellin transform $g^*(s)$ of $g(x)$.

Now the Mellin transform of $\cos(x)$ was computed at this MSE link and found to be $$\Gamma(s) \cos(\pi s/2)$$

It follows that the Mellin transform $Q(s)$ of the harmonic sum $S(x)$ is given by

$$Q(s) = \Gamma(s)\cos(\pi s/2) \zeta(s+1) \quad\text{because}\quad \sum_{k\ge 1} \frac{\lambda_k}{\mu_k^s} = \sum_{k\ge 1} \frac{1}{k} \frac{1}{k^s} = \zeta(s+1)$$ for $\Re(s) > 0.$

The Mellin inversion integral here is $$\frac{1}{2\pi i} \int_{1/2-i\infty}^{1/2+i\infty} Q(s)/x^s ds$$ which we evaluate by shifting it to the left for an expansion about zero.

The zeros of the cosine term at the negative odd integers cancel the poles of the gamma function at those values. No additional cancelation is gained from the trivial zeros of the zeta function term $\zeta(s+1)$ as these are (also) at the odd negative integers to the left of $-1.$ This leaves the pole from the zeta term at $s=0$ and the poles of the gamma function at negative even integers to the left of zero.

Note that in a neighborhood of zero, we have $$\frac{1}{x^s} = 1 - \log(x) s + \frac{1}{2} \log^2(x) s^2 + \sum_{q\ge 3} \frac{(-1)^q}{q!} \log^q(x) s^q$$ and $$\zeta(s+1) = \frac{1}{s} + \gamma - \gamma_1 s + \sum_{q\ge 2} \frac{(-1)^q}{q!} \gamma_q s^q$$ and $$\Gamma(s) = \frac{1}{s} - \gamma + \left(\frac{\gamma^2}{2}+\frac{\pi^2}{12}\right) s + \cdots$$ and finally $$\cos(\pi s/2) = 1 - \frac{\pi^2}{8} s^2 + \frac{\pi^4}{384} s^4 + \sum_{q\ge 3} (-1)^q \frac{\pi^{2q}}{2^{2q}\times (2q)!} s^{2q}.$$

Collecting the contributions to $1/s$ we get $$-\log(x)s \times \frac{1}{s} \times \frac{1}{s} \times 1 + 1\times \frac{1}{s} \times -\gamma + 1\times \gamma \times \frac{1}{s}$$ and hence $$\mathrm{Res}\left(Q(s)/x^s; s=0\right) = -\log x.$$

Fortunately the residues from the remaining poles are simple to compute and summing all contributions we get $$\sum_{q\ge 1} \mathrm{Res}\left(Q(s)/x^s; s=-2q\right) = \sum_{q\ge 1} \frac{1}{(2q)!} (-1)^q \times x^{2q} \times -\frac{B_{2q}}{2q}.$$ This sum is in fact $$-\sum_{q\ge 1} \frac{(ix)^q}{q!} \frac{B_q}{q} + ix \times -\frac{1}{2}.$$ Recall that $$\sum_{q\ge 1} B_q \frac{t^q}{q!} = -1 + \frac{t}{e^t-1}$$ so that $$\sum_{q\ge 1} B_q \frac{t^{q-1}}{q!} = -\frac{1}{t} + \frac{1}{e^t-1}$$ and hence $$\sum_{q\ge 1} B_q \frac{t^q}{q\times q!} = -\log(t) + \log(e^t-1)- t.$$

This is $\sim -1/2 \times t$ in a neighborhood of zero so we can be sure no spurious constant has appeared during the integration.

We return to our collection of residues and finally obtain (setting $t=ix$) $$\log(ix) - \log(e^{ix}-1)+ ix - \frac{1}{2} ix -\log x = -\log(e^{ix}-1) + \log i + \frac{1}{2} ix \\= -\log e^{ix/2} -\log(e^{ix/2}-e^{-ix/2}) + \log i + \frac{1}{2} ix \\= -\log(2i\sin(x/2)) + \log i = -\log(2\sin(x/2)).$$

This holds for $x$ in $(0,2\pi).$ Observing that $S(x)$ is periodic with period $2\pi$ and even we get the end result $$-\log|2\sin(x/2)|.$$

-
Your ability to solve almost every problem with Mellin transforms is amazing. –  Pedro Tamaroff May 3 at 3:14
Very kind indeed. Yet there is so much more to learn on this topic, one could easily spend a lifetime on it, especially the numbertheoretic aspects. –  Marko Riedel May 3 at 3:17

The result can also be obtained by a much simpler derivation than given above.

Put $C(x) = \sum \frac{\cos(nx)}{n}$ then we first see that $C(\pi) = -(1-1/2+1/3-...) = -\log(2)$ and

$C(x) = C(\pi) + \int_\pi^x \frac{dC(x)}{dx}dx \\ = -\log(2) -\mathcal{Im}\left(\int_\pi^x\sum e^{inx}dx\right)\\ = -\log(2) -\int_\pi^x\frac{\sin(x)}{2-2\cos(x)}dx \\ = - \frac{\log|2-2\cos(x)|}{2}$

-
That is great! I didn't know it could be so short a proof. –  TCL May 3 at 5:02
By the way, your proof is flawed because $\sum_{n = 1}^\infty e^{inx}$ diverges in view of the fact that $|e^{ix}| = 1$ if $x$ is real. The series $\sum_{n = 1}^\infty e^{inx}$ converges to $e^{ix}/(1 - e^{ix})$ whenever $\textbf{I}[x] > 0$, that is, $\textbf{I}[\sum_{n = 1}^\infty e^{inx}] = (\sin x)/(2 - 2\cos x)$ provided $\textbf{I}[x] > 0$. Indeed, $\textbf{I}[\sum_{n = 1}^\infty e^{inx}] = \sum_{n = 1}^\infty \sin nx$, which clearly does not converge if $x$ is real (unless $x \in \pi \mathbb{Z}$, of course). –  glebovg Jun 28 at 8:42