# Limit of a sum using complex analysis.

I'm trying to find the limit of this sum: $$S_n =\frac{1}{n}\left(\frac{1}{2}+\sum_{k=1}^{n}\cos(kx)\right)$$ I tried to find a formula for the inner sum first and I ended up getting zero as an answer. The sum is supposed to converge to $\cot(x\over 2)$ and that appears in my last expression but it goes to zero. Here is what I got with a rather long and clumsy reasoning: $$S_n = \frac{1}{2n}\left(\cot\left(\frac{x}{2}\right)\sin(nx)+\cos(nx)\right)$$ Thanks in advance.

Just write $$\cos (kx)$$ as the real part of $$e^{ikx}$$.

• I already did that but it didn't work. Sep 30 '18 at 20:39
• Then the limit is 0. Why do you think the answer is a cotan ?
– user598294
Sep 30 '18 at 20:42
• I don't know either way, but it can't be zero because the question asks for an answer in terms of $x$ Sep 30 '18 at 20:43
• You must have forgotten something.
– user598294
Sep 30 '18 at 20:45
• TheSilverDoe's proof convinced me and it has two different answers depending on the value of $x$ which solves my troubles, so yes not $\cot$, my bad. Sep 30 '18 at 20:54

You have, for all $$x \neq 2k\pi$$, $$\sum_{k=1}^n \cos(kx) = \mathrm{Re}\left( \sum_{k=1}^n e^{ikx}\right) = \mathrm{Re}\left( e^{ix} \frac{1-e^{inx}}{1-e^{ix}} \right)$$

Moreover you have $$\left|e^{ix} \frac{1-e^{inx}}{1-e^{ix}}\right| \leq \frac{2}{|1-e^{ix}|}$$

So $$\left| \sum_{k=1}^n \cos(kx) \right| \leq \frac{2}{|1-e^{ix}|}$$

And therefore you get $$S_n \rightarrow 0$$.

If $$x = 2k\pi$$ for $$k \in \mathbb{Z}$$, you easily have $$S_n \rightarrow 1$$.

• Remember that $|e^{iz}|=1$ for all $z \in \mathbb{R}$. So by the triangle inequality, $|1-e^{inx}| \leq 2$. Sep 30 '18 at 20:48
• Thank you very much, this was very helpful. Sep 30 '18 at 20:51

Another view of the question.

Instead of taking the real part of $$e^{ikx}$$ as given by the answers from TheSilverDoe and AlexL, the complex exponential can be more symmetric:

\begin{align*} \cos kx &= \frac{e^{-ikx}+e^{ikx}}2\\ \frac12+\sum_{k=1}^n\cos kx &= \frac12\sum_{k=-n}^ne^{ikx}\\ &= \frac12 \cdot e^{-inx}\frac{e^{i(2n+1)x}-1}{e^{ix}-1}\\ &= \frac12 \cdot \frac{e^{i(n+1)x}-e^{-inx}}{e^{ix}-1}\\ &= \frac12 \cdot \frac{e^{i\left(n+\frac12\right)x}-e^{-i\left(n+\frac12\right)x}}{e^{i\frac12x}-e^{-i\frac12x}}\\ &= \frac12 \cdot \frac{\sin\left(n+\frac12\right)x}{\sin\frac12x}\\ S_n&= \frac{\sin\left(n+\frac12\right)x}{2n\sin\frac12x}\\ \end{align*}

When $$e^{ix} \ne 1$$, i.e. $$x\ne 2\pi m$$ for integer $$m$$, $$S_n \to 0$$.

For other $$x$$'s, i.e. when $$x=2\pi m$$,

\begin{align*} \cos kx = \cos 2\pi km &= 1\\ \sum_{k=1}^n\cos kx &= n\\ \frac12 + \sum_{k=1}^n\cos kx &= \frac12+ n\\ S_n &= \frac1n\left(\frac12 + n\right)\\ &= \frac1{2n} + 1\\ &\to 1 \end{align*}