# Is there a solution for $\sum_{k=1}^{n}\cos(kx) = a$?

I am trying to predict the phase error in a chip based on its DFT components. Therefore it would be amazing if there is a specific solution of x for the following equation: $$\sum_{k=1}^{n}\cos(kx) = a$$ For the domain of x such that there is a unique mapping from the LHS to the RHS. In the general case this condition is for sure satisfied in the domain of $x = [0, \frac{\pi}{n}]$. However this domain could be larger. For example in the case of n = 3, WolframAlpha told me that there is a unique mapping between LHS and RHS for the domain of $x = [0, \sim 0.4\pi]$. The values of $a$ are only valid in the range $a = [n, ?)$, but I don't think it is of that much importance to know the exact lower bound of $a$ at this time.

I tried to solve this equation by looking at a specific case of this general equation, which can be found in this question on StackExchange. The given solution is valid since the identity $\cos(a)\sin(b)=\frac{1}{2}(\sin(a+b)−\sin(a−b))$, which results in a factor of $a$ (namely $\frac{1}{2}$) on the LHS such that the $a\sin{\frac{x}{2}}$ on both sides of the equal sign cancel. In the general case, this is of course not the case since $|a|$ is not by definition equal to $\frac{1}{2}$. Therefore:

1. Does anyone know if this equation could have a specific solution (and why or why no)?
2. If the answer to 1. is Yes: What will be the solution to this equation? Also the solution to a more specific case, like n = 3 or 4 (or preferable 8, because I perform an 8 sample DFT) would we very welcome.

I am looking forward to some brilliant ideas :)

• Isn't it summable: $\sum_{k=1}^{n} \cos(kx) = \Re \sum_{k=1}^n \mathrm{e}^{ikx} = \Re \sum_{k=0}^n \mathrm{e}^{ikx} - 1 = \Re \frac{1-\mathrm{e}^{iNx}}{1-\mathrm{e}^ix} -1$ I mean, perhaps this could assit you in investigating your equation. – Ranc Jul 28 '17 at 12:52
• You need to explain your true problem (the phase error in a chip based on its DFT components) – reuns Jul 28 '17 at 13:25

You have this formula: $$\sum_{k=1}^n\cos kx=\frac{\sin\dfrac {nx}2}{\sin\dfrac x2}\,\cos\frac{(n+1)x}2.$$ It can be rewritten as $$\sum_{k=1}^n\cos kx=\frac{\frac12\biggl[\sin\dfrac {(2n+1)x}2-\sin\dfrac x2\biggr]}{\sin\dfrac x2}=\frac{\sin\dfrac {(2n+1)x}2}{2\sin\dfrac x2}-\frac12,$$ so, setting $t=\dfrac x2$, you would have to solve $$\frac{\sin(2n+1)t}{\sin t}=2a+1.$$ This function is defined on $\mathbf R\smallsetminus\pi\mathbf Z$ and has period $\pi$, so all you have to do is trying to see what can be said on $(0,\pi)$.
By DeMoivre's Theorem $\cos(kx) = \operatorname{Re}{( e^{ikx} )}$. So \begin{eqnarray*} \sum_{k=1}^{n} \cos(kx) = \operatorname{Re}{ \left( \sum_{k=1}^{n} (e^{ix})^k \right)}=\operatorname{Re}{ \left( \frac{ e^{ix}(1-e^{inx})}{(1-e^{ix})} \right)} \\ \end{eqnarray*} \begin{eqnarray*} =\operatorname{Re}{ \left( \frac{ e^{ix}(1-e^{inx})(1-e^{-ix})}{(1-e^{ix})(1-e^{-ix})} \right)} \\ \end{eqnarray*} \begin{eqnarray*} =\operatorname{Re}{ \left( \frac{ -1+e^{ix}+e^{inx}-e^{i(n+1)x}}{2-(e^{ix}+e^{-ix})} \right)} \\ = \frac{ -1+\cos(x)+\cos(nx)-\cos((n+1)x)}{2(1-\cos(x))} \\ \end{eqnarray*} \begin{eqnarray*} = \frac{ -1}{2}+\frac{\cos(nx)-\cos((n+1)x)}{2(1-\cos(x))} \\ \end{eqnarray*} Now use $\cos x=1-2 \sin^2(x/2)$ and $\cos(nx)-\cos(n+1)x)=2 \sin(x/2)\sin((n+1/2)x)$ \begin{eqnarray*} \sum_{k=1}^{n} \cos(kx) =\color{red}{ \frac{\sin((n+1/2)x)}{2(\sin(x/2))} -\frac{ 1}{2}} \\ \end{eqnarray*} which is valid provided $x$ is not a multiple of $\pi$.