TITLE: Counting the number of solutions of equation $x^2 + y^2 = 1$ over $\Bbb Z/p$
QUESTION [1 upvotes]: List proofs of the fact that the number of solutions to $x^2 + y^2 = 1$ over $\Bbb Z/p$, where $p$ is a prime $\neq 2$, is $p-(-1)^{\frac{p-1}2}$. I thought of two.
I write one below.

REPLY [2 votes]: Observe that the number of solutions to $x^2=a$ in $\mathbb F_p$ is $(a/p)+1$. So $$
\mathop\#\{x^2+y^2=1\}=
\sum_{a+b=1}\bigl(1+(a/p)\bigr)\bigl(1+(b/p)\bigr)=
p+\sum(a/p)+\sum\bigl(a(1-a)/p\bigr).
$$
Of the last two sums the first one is zero (the number of residues is equal to the number of non-residues). And the second one is almost zero: $a(1-a)=a^2(a^{-1}-1)$ and $a^{-1}-1$ ranges over $\mathbb F_p\setminus\{-1\}$; so if we add $(-1/p)$ to this sum we get $\sum(b/p)=0$. So
$$
\mathop\#\{x^2+y^2=1\}=p-(-1/p).
$$

P.S. This approach — counting number of solutions to equations using $\#\{x^n=a\}=\sum_\chi\chi(a)$ and Jacobi sums  $\sum_{a_1+\dots+a_k=1}\chi_1(a_1)\ldots\chi_k(a_k)$ — was used by Weil in his 1949 paper to estimate the number of solutions to equations of the form $\sum c_ix_i^{n_i}=b$ (that is, to prove Weil conjectures — which were formulated in the same paper — in this special case).
For example,
\begin{gather}
\mathop\#\{x^3+y^3=1\}\approx p-2\pm2\sqrt p;\\
\mathop\#\{x^n+y^n=1\}+\#\{t^n+1=0\}\approx p+1\pm(n-1)(n-2)\sqrt p.
\end{gather}
{"set_name": "stack_exchange", "score": 1, "question_id": 1326283}