Problem 6. For $x=\frac{\pi}{2 n}$, find the value of the sum

$$
\cos ^{2}(x)+\cos ^{2}(2 x)+\cos ^{2}(3 x)+\ldots+\cos ^{2}(n x)
$$
Answer: $\frac{n-1}{2}$.

Solution. Note that

$$
\cos ^{2}\left(\frac{k \pi}{2 n}\right)+\cos ^{2}\left(\frac{(n-k) \pi}{2 n}\right)=\cos ^{2}\left(\frac{k \pi}{2 n}\right)+\cos ^{2}\left(\frac{\pi}{2}-\frac{k \pi}{2 n}\right)=\cos ^{2}\left(\frac{k \pi}{2 n}\right)+\sin ^{2}\left(\frac{k \pi}{2 n}\right)=1
$$

If $n$ is odd, we can divide all the terms, except $\cos ^{2}(n x)$, into pairs, such that the sum of the numbers in each pair is 1. Thus, the paired terms sum up to $\frac{n-1}{2}$, and $\cos ^{2}(n x)=\cos ^{2}\left(\frac{\pi}{2}\right)=0$. If $n$ is even, then $\cos ^{2}(n x)=\cos ^{2}\left(\frac{\pi}{2}\right)=0$ and $\cos ^{2}\left(\frac{\pi}{4}\right)=\frac{1}{2}$ remain unpaired. In both cases, the total sum is $\frac{n-1}{2}$.