An interesting Legendre symbol identity: $\left (\frac{a}{p} \right ) = \prod_{h\in\mathscr{H}}^{}\frac{\sin(2\pi ah/p)}{\sin(2\pi h/p)}$ If we call $\mathscr{H}$ a one-half set of reduced residues (mod $p$), $p$ is  a prime,  if $\mathscr{H}$ has the property that:
$h \in \mathscr{H}$ if and only if $-h \notin \mathscr{H}$
Let $\mathscr{H}$ and $\mathscr{K}$ be two complementary one-half sets. They form the reduced residue system modulo $p$.
There are some propositions about $\mathscr{H}$ and $\mathscr{K}$:

*

*if $(a, p) = 1$. Let $\nu$ be the number of $h \in \mathscr{H}$ for which $ah \notin \mathscr{H}$. That is $h \in \mathscr{H}$ but $ah \in \mathscr{K}$.
Then we can get:
\begin{split}
   (-1)^{\nu} = \left(\frac{a}{p}\right)
  \end{split}
$\left(\frac{a}{p}\right)$ is the Legendre symbol


*$(a, p) = 1$, $a \mathscr{H}$ and $a\mathscr{K}$ are complementary one-half sets.
That is $a \mathscr{H}$ and $a\mathscr{K}$ are disjoint and form the reduced residue system modulo $p$.
I wonder how to get the following equation:
\begin{split}
\left(\frac{a}{p}\right)  = \prod_{h\in\mathscr{H}}^{}\frac{\sin(2\pi ah/p)}{\sin(2\pi h/p)} 
\end{split}
for any integer $a$ and odd prime $p$.
Here are the hints:
Notice that $a\mathscr{H} = (a\mathscr{H} \cap \mathscr{H}) \cup(a\mathscr{H} \cap \mathscr{K})$.
Consider the product of elements in  $\mathscr{H}$ and $(\mathscr{H} \cap a\mathscr{H}) \cup(\mathscr{H} \cap a\mathscr{K})$ respectively, and they are equal.
 A: Let $a$ be an integer and $p$ be an odd prime. Define
$$L=\prod_{h\in\mathscr{H}}\frac{\sin(2\pi ah/p)}{\sin(2\pi h/p)}$$
We seek to prove that $L=\left(\frac{a}{p}\right)$.
We first prove (lemma) that for all $k\geq 0$,
$$L=\prod_{h\in\mathscr{H}}\frac{\sin(2\pi a^{k+1}h/p)}{\sin(2\pi a^kh/p)}$$
Suppose that the above formula is true for some specific $k\geq 0$, then we may write
$$
L=\prod_{h\in\mathscr{H}\cap a\mathscr{H}}\frac{\sin(2\pi a^{k+1}h/p)}{\sin(2\pi a^kh/p)}\prod_{h\in\mathscr{H}\cap a\mathscr{K}}\frac{\sin(2\pi a^{k+1}h/p)}{\sin(2\pi a^kh/p)}
$$
Noticing that $h\in\mathscr{H}\cap a\mathscr{K}$ iff $-h\in\mathscr{K}\cap a\mathscr{H}$, we have that
\begin{equation}
\begin{split}
L&=\prod_{h\in\mathscr{H}\cap a\mathscr{H}}\frac{\sin(2\pi a^{k+1}h/p)}{\sin(2\pi a^kh/p)}\prod_{h\in\mathscr{K}\cap a\mathscr{H}}\frac{\sin(2\pi a^{k+1}(-h)/p)}{\sin(2\pi a^k(-h)/p)}\\
&=\prod_{h\in\mathscr{H}\cap a\mathscr{H}}\frac{\sin(2\pi a^{k+1}h/p)}{\sin(2\pi a^kh/p)}\prod_{h\in\mathscr{K}\cap a\mathscr{H}}\frac{\sin(2\pi a^{k+1}h/p)}{\sin(2\pi a^kh/p)}\\
&=\prod_{h\in a\mathscr{H}}\frac{\sin(2\pi a^{k+1}h/p)}{\sin(2\pi a^kh/p)}\\
&=\prod_{h\in \mathscr{H}}\frac{\sin(2\pi a^{k+2}h/p)}{\sin(2\pi a^{k+1}h/p)}\\
\end{split}
\end{equation}
Since the base case of $k=0$ is true by definition, by induction, we may conclude the lemma.
From the above lemma, we see that if $n=o(a)$ is the order of $a$ (so $a^n=1$), we obtain the telescoping product
\begin{equation}
\begin{split}
L^n&=\prod_{k=0}^{n-1}\prod_{h\in\mathscr{H}}\frac{\sin(2\pi a^{k+1}h/p)}{\sin(2\pi a^kh/p)}\\
&=\prod_{h\in\mathscr{H}}\frac{\sin(2\pi a^nh/p)}{\sin(2\pi h/p)}\\
&=1\\
\end{split}
\end{equation}
and thus $L\in\{-1,1\}$. Now, let $\mathscr{M}=\{1,2,\cdots,(p-1)/2\}\subseteq\mathbb{Z}/p\mathbb{Z}$. Note that $|\mathscr{M}\cap\mathscr{H}\cap a\mathscr{K}|=|(-\mathscr{M})\cap\mathscr{K}\cap a\mathscr{H}|$, and note that if $x\ne 0\pmod p$,
$$
\text{sgn}[\sin(2\pi x/p)]=
\begin{cases}
-1  & \text{if }x\in -\mathscr{M} \\
1  & \text{if }x\in \mathscr{M} \\
\end{cases}
$$
From those two facts, we have that
\begin{equation}
\begin{split}
\text{sgn}(L)&=\prod_{h\in \mathscr{H}}\text{sgn}[\sin(2\pi h/p)]\text{sgn}[\sin(2\pi ah/p)]\\
&=(-1)^{|(-\mathscr{M})\cap\mathscr{H}|+|(-\mathscr{M})\cap a\mathscr{H}|}\\
&=(-1)^{2|(-\mathscr{M})\cap\mathscr{H}\cap a\mathscr{H}|+|(-\mathscr{M})\cap\mathscr{H}\cap a\mathscr{K}|+|(-\mathscr{M})\cap\mathscr{K}\cap a\mathscr{H}|}\\
&=(-1)^{|(-\mathscr{M})\cap\mathscr{H}\cap a\mathscr{K}|+|(-\mathscr{M})\cap\mathscr{K}\cap a\mathscr{H}|}\\
&=(-1)^{|(-\mathscr{M})\cap\mathscr{H}\cap a\mathscr{K}|+|\mathscr{M}\cap\mathscr{H}\cap a\mathscr{K}|}\\
&=(-1)^{|\mathscr{H}\cap a\mathscr{K}|}\\
&=(-1)^{\nu}\\
&=\left(\frac{a}{p}\right)
\end{split}    
\end{equation}
Finally, since $\text{sgn}(L)=\left(\frac{a}{p}\right)$ and $L\in\{-1,1\}$, then
$$\boxed{L=\prod_{h\in\mathscr{H}}\frac{\sin(2\pi ah/p)}{\sin(2\pi h/p)}=\left(\frac{a}{p}\right)}$$
as desired.
