TITLE: show this indentity $\sum_{k=1}^{2n-1}\frac{\sin{\frac{k^2\pi}{2n}}}{\sin{\frac{k\pi}{2n}}}=n$
QUESTION [9 upvotes]: let $n$ be postive integers.show that
$$\sum_{k=1}^{2n-1}\dfrac{\sin{\frac{k^2\pi}{2n}}}{\sin{\frac{k\pi}{2n}}}=n$$
Try:I can show $n$ is smaller number.
let $LHS=f(n)$.when $n=1$ it is clear
$$f(1)=\dfrac{\sin{\pi/2}}{\sin{\pi/2}}=1$$
when $n=2$ then
$$f(2)=\dfrac{\sin{\frac{\pi}{4}}}{\sin{\frac{\pi}{4}}}+\dfrac{\sin{\frac{4\pi}{4}}}{\sin{\frac{2\pi}{4}}}+\dfrac{\sin{\frac{9\pi}{4}}}{\sin{\frac{3\pi}{4}}}=1+0+1=2$$
when $n=3$,then
$$f(3)=\dfrac{\sin{\frac{\pi}{6}}}{\sin{\frac{\pi}{6}}}+\dfrac{\sin{\frac{4\pi}{6}}}{\sin{\frac{2\pi}{6}}}+\dfrac{\sin{\frac{9\pi}{6}}}{\sin{\frac{3\pi}{6}}}+\dfrac{\sin{\frac{16\pi}{6}}}{\sin{\frac{4\pi}{6}}}+\dfrac{\sin{\frac{25\pi}{6}}}{\sin{\frac{5\pi}{6}}}=1+1-1+1+1=3$$
$$\begin{align}f(4)&=\dfrac{\sin{\frac{\pi}{8}}}{\sin{\frac{\pi}{8}}}+\dfrac{\sin{\frac{4\pi}{8}}}{\sin{\frac{2\pi}{8}}}+\dfrac{\sin{\frac{9\pi}{8}}}{\sin{\frac{3\pi}{8}}}+\dfrac{\sin{\frac{16\pi}{8}}}{\sin{\frac{4\pi}{8}}}+\dfrac{\sin{\frac{25\pi}{8}}}{\sin{\frac{5\pi}{8}}}+\dfrac{\sin{\frac{36\pi}{8}}}{\sin{\frac{6\pi}{8}}}+\dfrac{\sin{\frac{49\pi}{8}}}{\sin{\frac{7\pi}{8}}}\\
&=1+\sqrt{2}-\tan{\frac{\pi}{8}}+0-\tan{\frac{\pi}{8}}+\sqrt{2}+1\\
&=4\end{align}$$
because use this well known $\tan{\frac{\pi}{8}}=\sqrt{2}-1$

REPLY [7 votes]: Let $\omega = e^{i\pi/2n}$. If we write $S$ for the sum, then from
$$ \frac{\sin(\pi k^2/2n)}{\sin(\pi k/2n)} = \frac{\omega^{k^2} - \omega^{-k^2}}{\omega^k - \omega^{-k}} = \omega^{k(-k+1)} \frac{(\omega^{2k})^k - 1}{\omega^{2k} - 1} =  \sum_{j=0}^{k-1} \omega^{k(2j-k+1)}, $$
we may recast $S$ as the double sum
$$ S = \sum_{k=1}^{2n-1} \sum_{j=0}^{k-1} \omega^{k(2j-k+1)} = \sum_{(k,l) \in \mathcal{T}} \omega^{kl}, $$
where $l = 2j-k+1$ and the region $\mathcal{T}$ is defined by
$$\mathcal{T} = \{ (k, l) \in \mathbb{Z}^2 : 0 < |l| < k < 2n \text{ and } k + l \text{ is odd}\} .$$
The following figure illustrates the region $\mathcal{T}$ for $n = 8$:

Now the key observation is that the sum $S$ enjoys the following symmetry:
$$ S = \sum_{(l, k) \in \mathcal{T}} \omega^{kl} = \sum_{(-k,-l) \in \mathcal{T}} \omega^{kl} = \sum_{(-l,-k) \in \mathcal{T}} \omega^{kl} $$
Moreover, if we write
\begin{align*}
\mathcal{T}_1 &= \mathcal{T}, &
\mathcal{T}_2 &= \{(l, k) : (k, l) \in \mathcal{T}\}, \\
\mathcal{T}_3 &= \{(-k, -l) : (k, l) \in \mathcal{T}\}, &
\mathcal{T}_4 &= \{(-l, -k) : (k, l) \in \mathcal{T}\}, 
\end{align*}
then $\mathcal{T}_1, \ldots, \mathcal{T}_4$ are disjoint and
$$ \mathcal{T}_1 \cup \mathcal{T}_2 \cup \mathcal{T}_3 \cup \mathcal{T}_4
= \{(k, l) : |k|, |l| < 2n \text{ and } k + l \text{ is odd} \}. $$
From this, we may write
$$ 4S = Z - 2B, $$
where
$$ Z = \sum_{\substack{k, l \in \mathbb{Z}/4n\mathbb{Z} \\ k+l \text{ odd}}} \omega^{kl}
\qquad\text{and}\qquad
B = \sum_{\substack{k = 2n \\ l \in \mathbb{Z}/4n\mathbb{Z} \\ k+l \text{ odd}}} \omega^{kl}
= \sum_{\substack{k \in \mathbb{Z}/4n\mathbb{Z} \\ l = 2n \\ k+l \text{ odd}}} \omega^{kl}. $$
The figure below illustrates the regions $\mathcal{T}_k$'s as well as the points $(k, l)$ contributing the sum for $2B$ when $n = 5$.

Then the claim will follow once we prove:

Claim. $Z = 0$ and $B = -2n$.

The value of $B$ is easier to compute. Indeed, using $\omega^{2n} = -1$, we get
$$ B
= \sum_{\substack{|k| < 2n \\ k \text{ odd}}} \omega^{2nk}
= \sum_{\substack{|k| < 2n \\ k \text{ odd}}} (-1)^{k}
= -2n. $$
So we shift our focus to the value of $Z$. Substituting $l \mapsto l + 2r$ for $r = 0, 1, \dots, 2n-1$, we find that
$$ Z
= \frac{1}{2n} \sum_{r=0}^{2n-1} Z
= \frac{1}{2n} \sum_{r=0}^{2n-1} \sum_{\substack{k, l \in \mathbb{Z}/4n\mathbb{Z} \\ k+l \text{ odd}}} \omega^{k(l + 2r)}
= \sum_{\substack{k, l \in \mathbb{Z}/4n\mathbb{Z} \\ k+l \text{ odd}}} \omega^{kl} \left( \frac{1}{2n} \sum_{r=0}^{2n-1} \omega^{2kr} \right). $$
Then by using the identity
$$ \frac{1}{2n} \sum_{r=0}^{2n-1} \omega^{2kr}
= \begin{cases}
1, & \text{if $k \equiv 0$ (mod $2n$),} \\
0, & \text{otherwise,}
\end{cases}$$
it follows that
$$ Z
= \sum_{\substack{k, l \in \mathbb{Z}/4n\mathbb{Z} \\ k+l \text{ odd} \\ \text{$k \equiv 0$ (mod $2n$)}}} \omega^{kl}
= \sum_{l\in\mathbb{Z}/4n\mathbb{Z}} \sum_{\substack{k \in \mathbb{Z}/4n\mathbb{Z} \\ k+l \text{ odd} \\ \text{$k \equiv 0$ (mod $2n$)}}} \omega^{kl}. $$
Now the inner sum can be easily evaluated for each given $l\in\mathbb{Z}/4n\mathbb{Z}$, yielding
$$ \sum_{\substack{k \in \mathbb{Z}/4n\mathbb{Z} \\ k+l \text{ odd} \\ \text{$k \equiv 0$ (mod $2n$)}}} \omega^{kl}
= \begin{cases}
0, & \text{if $l$ is even,} \\
1 + (-1)^l = 0, & \text{if $l$ is odd.}
\end{cases} $$
Therefore $Z = 0$ and the desired claim follows.