# How to calculate $\sum_{k=1}^n\cos\frac{k\pi}{n+1}$ and $\prod_{k=1}^n(-2)\cos\frac{k\pi}{n+1}$?

The question is to calculate, given $n$ a positive integer

$$S_n:=\sum_{k=1}^n\cos\frac{k\pi}{n+1},$$ and

$$P_n:=\prod_{k=1}^n(-2)\cos\frac{k\pi}{n+1}.$$

By the way, if we define the matrix $\mathbf{A}_n=[a_{ij}^n]_{\forall\,i,j}$ as follows:

$$a_{ij}^n= \begin{cases} 1, \text{ if i=j+1 or j = i+1}\\ 0, \text{ otherwise} \end{cases},$$ or simply

$$\mathbf{A}_n=\begin{bmatrix} 0 & 1 & 0 & \cdots & \cdots & \cdots & 0 \\ 1 & 0 & 1 & \ddots & & & \vdots\\ 0 & 1 & 0 & \ddots & \ddots & & \vdots \\ \vdots & \ddots & \ddots & \ddots & \ddots & \ddots & \vdots \\ \vdots & & \ddots & \ddots & 0 & 1 & 0 \\ \vdots & & & \ddots & 1 & 0 & 1 \\ 0 & \cdots & \cdots & \cdots & 0 & 1 & 0 \\ \end{bmatrix},$$

then one can show that

$$S_n=\operatorname{tr}(\mathbf{A}_n),\tag{E1}$$

and

$$P_n=\det(\mathbf{A}_n).\tag{E2}$$

Is it easy to find the determinant of $\mathbf{A}_n$?

Without proving $(E1)$ and $(E2)$, I can say that

• $S_n=0$ for all $n$; and
• if $n$ is odd then $P_n=0$
• if $n$ is even then $P_n=\ldots$.
• Notice that $P_n$ is not an integer for even $n$ (it equals $0$ for odd $n$), so it cannot be equal to the determinant. – Igor Rivin Jan 1 '17 at 22:48
• I was told to calculate $P_n(x):=\det(\mathbf{A}_n-xI_n)$ which I found equals to $\dfrac{\sin(n+1)\theta}{\sin\theta}$ for $\theta\in(0,\pi)$ and $x=-2\cos\theta$. After that, $P_n(0)=\det(\mathbf{A}_n)$ which is true for $\theta=\dfrac{\pi}{2}$. – drzbir Jan 1 '17 at 22:49
• What can I tell you, $P_n$ is visibly non-integral. $P_2=\cos(\pi/3) \cos(2\pi/3 = -\frac14.$ – Igor Rivin Jan 1 '17 at 22:55
• I missed a $-2$ inside the product. – drzbir Jan 1 '17 at 22:57
• Show $P_n(x)$ is a $n$ degree polynomial that vanishes when $\theta_k = \frac{k\pi}{n+1}$ for $k=1,2,3,\ldots,n$. This gives you the roots $x_k(\theta_k)$. From Vieta's formula you know that $P_n(x) = A[x^n - \sum x_k x^{n-1} + \ldots + (-1)^n x_1\cdots x_n]$. Taking $x=0$ you get $P_n(0) = \det A_n$ which gives you the relation between the product of the roots and $\det A_n$. – Winther Jan 1 '17 at 23:08

For $S_n$, you can use the factorisation formula, analogous to formula for the sum of consecutive terms of an arithmetic sequence: $$\cos\theta+\cos2\theta+\dots+\cos n\theta=\frac{\sin\dfrac{n\theta}2}{\sin \dfrac{\theta\mathstrut}2}\,\cos\dfrac{(n+1)\theta}2$$ with $\;\theta=\dfrac{\pi}{n+1}$.

For the determinant, it is a tridiagonal determinant. These can be calculated by induction: if $A_k$ $\;(k\le n)$ is the leading principal minor, one has the relation: $$A_n=a_{n,\mkern1mu n}A_{n-1} -a_{n,\mkern1mu n-1}a_{n-1,\mkern1mu n}A_{n-2},$$ which gives i, the present case $$A_n=-A_{n-2},$$ with initial conditions $A_1=0$, $\; A_2=-1$. Hence $$A_{2n+1}=0,\quad A_{2n}=(-1)^n.$$

• The OP knows it's a determinant, he wants a determinant-free way of computing it. – Igor Rivin Jan 1 '17 at 23:17
• This was not very clear to me. Anyway, it gives a way to check other ways of computing. – Bernard Jan 1 '17 at 23:30

$S_n$ is the real part of $\sum_{k=1}^n e^{\frac{k i \pi}{n+1}}.$ The second identity is false.

• @SimpleArt Thanks for proofreading. – Igor Rivin Jan 1 '17 at 22:23
• It would be better if you mentioned roots of unity. – Simply Beautiful Art Jan 1 '17 at 22:24
• @SimpleArt Why? I am sure the OP can sum a geometric series whether or not it has anything to do with the roots of unity. – Igor Rivin Jan 1 '17 at 22:25
• The sum of roots of unity are well known, and it'd make all of this more beautiful IMO. Have you checked what your sum evaluates to? – Simply Beautiful Art Jan 1 '17 at 22:27
• @SimpleArt I don't think that your idea of beauty is universal. And the second part of your comment makes no sense. If you have a different answer, by all means, post it. – Igor Rivin Jan 1 '17 at 22:31

Hint: for the first use that $$\cos(\pi-x)=-\cos(x),$$ which can be easily visualized by using the unit circle:

• Well, you took my answer. +1 when I find votes to give you. – Simply Beautiful Art Jan 1 '17 at 22:40
• @SimpleArt in the sense that you were about to answer in the same way? – b00n heT Jan 1 '17 at 22:47
• More or less yes. – Simply Beautiful Art Jan 1 '17 at 23:14