Prime-field character Gauss sum identity (source code)

= Prime-field character Gauss sum identity
{title2=$|\sum_{y\ne0}\chi(y)e^{2\pi iay/p}|^2=p$}

For a nontrivial <Dirichlet character> modulo a <prime> $p$ and $a\not\equiv0\pmod p$, set $\tau=\sum_{y\ne0}\chi(y)e(ay/p)$. Substituting $y=tz$ in $|\tau|^2$ gives $\sum_{t\ne0}\chi(t)\sum_{z\ne0}e(a(t-1)z/p)$. The inner sum is $p-1$ at $t=1$ and $-1$ otherwise. Since <character orthogonality> gives $\sum_{t\ne0}\chi(t)=0$, the result is $p$.