How to evaluate $ \prod_{1\le i While doing my research on elementary number theory, I came across the following problem which I cannot overcome: Let $p$ be an odd prime, $g$ be any primitive of $p$. Define
$$f(p)=\prod_{1\le i <j\le\frac{p-1}{2}}j^2-i^2\pmod p$$ and
$$h(p,g)=\prod_{1\le i <j\le\frac{p-1}{2}}g^{2j}-g^{2i} \pmod p .$$  What I want to know is the relationship between $f(p)$ and $h(p,g)$. I calculated the first one hundred primes and find that either $f(p)+h(p,g)=p $ or $f(p)=h(p,g) $.  For example $f(17)=4 $ , $h(17,5)=13 $ and $f(73)=h(73,11)=46 $.  I believe that this is true for all primes $p$ and all primitives $g$.
Now my questions are :

*

*Does it true that we always have $f(p)+h(p,g)=p $ or $f(p)=h(p,g) $


*Is it possible to evaluate $f(p)$ and $h(p,g)$ and find the condition when does $f(p)+h(p,g)=p $ and $f(p)=h(p,g) $
I am eager to know any answer, link, or hints to this problem, thank you!!

I presume you are doing the calculations modulo $p$. In the first case
the admissible $i^2$ are the quadratic residues modulo $p$.
In the second case
the admissible $g_{2i}$ are also the quadratic residues modulo $p$.
Both products have the form $\prod_{1\le i<j\le m}(a_j-a_i)$
where $a_1,\ldots,a_m$ ($m=\frac12(p-1)$) are the distinct quadratic
residues modulo $p$. But the ordering of the $a_i$ differs. If
the first product is $\prod_{1\le i<j\le m}(a_j-a_i)$
and the second is $\prod_{1\le i<j\le m}(b_j-b_i)$, then
$b_j=a_{\tau(j)}$ for some permutation $\tau\in S_m$ and then
$\prod_{1\le i<j\le m}(b_j-b_i)=\text{sgn}(\tau)
\prod_{1\le i<j\le m}(a_j-a_i)$ (at least modulo $p$).
Here $\text{sgn}(\tau)$ is the sign of the permutation $\tau$.
