Orthogonality of discrete sine functions can somebody provide a proof of the attached result ? (excerpt from a thesis document). It seemed obvious but I got lost in the calculations. Many thanks
Gerald

But discrete $\sin$ functions that we consider are orthogonal when $x_j\ne y_j$,
$$\sum_{k=1}^{2R-1}\sin\left(\pi k\frac{x_j+R}{2R}\right)\sin\left(\pi k\frac{y_j+R}{2R}\right)=R\delta(x_j,y_j),$$
where $\delta(x,y)=0$ when $x\ne y$ and $\delta(x,y)=1$ when $x=y$.

 A: There is also a direct proof using the geometric partial sum
$$ \sum_{j=0}^N q^j = \frac{q^{N+1}-1}{q-1}. $$
I will prove the statement of the following form
$$ \sum_{j=1}^N \sin(\frac{\pi n j}{N+1})\sin(\frac{\pi n^\prime j}{N+1}) = \frac{N+1}{2}\delta_{nn\prime}$$
for $n, n^\prime \in \{1, \dots, N\}$. First, we note that $\sin(0)=0$, therefore we can include $j=0$ in the sum. Next we relate the $\sin$ to the exponential function $\sin(x) = (e^{ix} - e^{-ix})/2i$. Thus, we write
$$
\sum_{j=1}^N \sin(\frac{\pi n j}{N+1})\sin(\frac{\pi n^\prime j}{N+1})
 \\= \frac{-1}{4}\sum_{j=0}^{N}\left[
   \exp(i\pi \frac{n+n^\prime}{N+1}j)
 - \exp(i\pi \frac{n-n^\prime}{N+1}j)
 - \exp(-i\pi \frac{n-n^\prime}{N+1}j)
 + \exp(-i\pi \frac{n+n^\prime}{N+1}j)
\right].
$$
Each of the addends can be evaluated using the geometric partial sum:
$$\sum_{j=0}^{N}\exp(\pm i\pi \frac{n+sn^\prime}{N+1}j) = \frac{\exp(\pm i\pi(n+sn^\prime)) - 1}{\exp(\pm i\pi \frac{n+sn^\prime}{N+1}) -1}$$
where $s\in\{-1, +1\}$. Strictly speaking, we have to treat the case $n+sn^\prime=0$  separately, as the denominator becomes $0$. In this case the sum is trivially $N+1$ as we add only ones, agreeing with the limit of $n+sn^\prime\rightarrow 0$ using l'Hopital.
We distinguish two cases:

*

*The case if both $n$ and $n^\prime$ are even/odd is simple: $n+sn^\prime$ is even and therefore $\exp(\pm i\pi(n+sn^\prime))=1$; the terms with $s=+1$ vanish, the terms with $s=-1$ both give $\delta_{nn^\prime}(N+1)$.


*If one of $n$ and $n^\prime$ is even and the other is odd, $n+sn^\prime$ is odd and therefore $\exp(\pm i\pi(n+sn^\prime))=-1$. The terms compensate, as
$$\frac{1}{\exp(+ix)-1} + \frac{1}{\exp(-ix)-1} = -1$$
Q.E.D
A: In my opinion, the simplest understanding (and proof) of this discrete orthogonality is by recognizing that vectors 
$${\bf V_m}:=\begin{pmatrix}
\sin\left(1 m \right)\\
\sin\left(2 m\right)\\
\cdots \\
\sin\left(n m \right)
\end{pmatrix}$$
are eigenvectors of the following symmetrical matrix:
$${\bf D}=\begin{pmatrix}2&-1&&&&\\-1&2&-1&&&\\&-1&2&-1&&\\&&\ddots&\ddots&\ddots&\\&&&-1&2&-1\\&&&&-1&2
\end{pmatrix}$$
In fact, this matrix is attached to the discrete version of the opposite of the second derivative, because of the classical approximation :
\begin{equation}
f''(x)\approx\frac{1}{h^2}(f(x-h)-2f(x)+f(x+h))
\end{equation}
which is easily explained by Taylor expansions of  $f(x+h)$ et $f(x-h)$ at order 2. 
If $\bf{D}$ is applied to the following vector with $n$ coordinates
$$(f(h),f(2h), \cdots f(nh)) \ \ \text{with} \ \ h=\frac{1}{n+1}$$ 
one gets,  up to an unessential scaling factor $\dfrac{1}{h^2}$, an approximation of the following vector : 
$$-( * , f''(2h),f''(3h),\cdots f''((n-1)h)), * )$$
where the stars at the beginning and at the end mean that two specific rules have to be applied to obtain the values of this discrete 2nd derivative at the borders of the interval.
We are going to show that the eigenvalues and associated eigenvectors can be given simple analytical expressions. Almost everything is contained in the following relationship (that can be verified by using classical trigonometric expressions). For any $k,m \in \mathbb{R}$ :
\begin{equation}
-\sin((k-1)m)+2\sin(k m)-\sin((k+1)m) \ = \ 4 \sin\left(\frac{m}{2}\right)^2 \sin(k m) \ \ \ (*)
\end{equation}
In this formula, the presence of coefficients $-1,2,-1$ can be exploited by grouping, for a fixed $m$ ($1 \leq m \leq n$), versions of equation (*) , for values $k=1, 2, \ldots, n$ under the following common matrix form :
\begin{equation}
\bf{D}\bf{V_m}=\lambda_m {\bf V_m}
\end{equation}
with $\lambda_m:=4 \sin\left(\frac{m}{2}\right)^2.$
Concerning $m$, we will have to consider the very special value
\begin{equation}
m:=p\dfrac{\pi}{n+1} \ \ \ (§)
\end{equation}
Why that ? Because, in the exceptional case $k=n$, formula (*) needs to be replaced by the following identity:
\begin{equation}
-\sin((n-1)m)+2\sin(n m) \ = \ 4 \sin\left(\frac{m}{2}\right)^2 \sin(n m) \ \ \ (**)
\end{equation}
which is possible only if (§) holds (same remark for the very first identity). 
Let us give the name $\bf{S}$ to the matrix with general coefficient ${\bf S}_{pq}=\sin\left(pq \frac{\pi}{n+1}\right)$. Its columns are the eigenvectors of symmetrical matrix ${\bf S}$. Thus they are orthogonal, what was desired.
Remarks : 
1) $\bf{D}$, having all its eigenvalues $>0$ is (Symmetrical) Definite Positive (SDP). It is associated to the so-called (discrete) sine-transform, a relative to the (discrete) Fourier Transform.
2) To go a little further, take a look at the 2nd example in Looking for examples of Discrete / Continuous complementary approaches
