TITLE: Are there natural choices of $\sqrt{-1}$ in $\mathbb Z/p\mathbb Z$ for a prime $p\equiv 1\pmod 4$
QUESTION [14 upvotes]: The definition of "natural" is of course somewhat personal and involves perhaps aesthetic aspects and/or interesting properties. I illustrate it with two examples:
The integer $((p-1)/2)!$ is such a square-root of $-1$ (modulo $p$ for $p$ a prime congruent to $1$ modulo $4$). 
Another choice which is perhaps natural is given by $2a/b\pmod p$ where $p=4a^2+b^2$ with $a,b\in\mathbb N$.
Are there other nice formulae?
An example of a not very natural choice (in my eyes) is $a^{(p-1)/4}\pmod p$ where $a$ is the smallest natural integer generating the multiplicative 
group of invertible elements modulo $p$. However, I accept this answer gladly, if there is some generator $a$ of $(\mathbb Z/p\mathbb Z)^*$ given by a "natural" formula. 
(The motivation for this question was Does (the ideal class of) the different of a number field have a canonical square root? )

REPLY [3 votes]: Even $((p-1)/2)!\pmod p$ is a "computationally difficult" square root of $-1\pmod p$, this seems to be the simplest uniform formula. Less universal is $a^{(p-1)/4}\pmod p$ for a quadratic nonresidue $a$ modulo $p$, which is easy $2^{(p-1)/4}\pmod p$ for $p\equiv 5\pmod 8$ as Victor mentions. For $p\equiv1\pmod8$, you simply search for the least quadratic nonresidue $a$ modulo $p$; as far as I remember, there is a bound of the form $a<\operatorname{const}\cdot \log^2p$ assuming GRH. Computing the Legendre--Jacobi symbol $(a/p)$ has polynomial complexity.
I cannot be original in what I indicated above, so let me add some "complicated" (but curious) stuff on a discrete analogue of the formula
$$
(1-x)^{-1/2}=\sum_{n=0}^\infty \binom{2n}{n}\biggl(\frac x4\biggr)^n.
$$
This is the subject of Lemma 3 in arXiv:1004.4337.
Denote $q(x)=q_p(x)=(x^{p-1}-1)/p$ the Fermat quotient of $x\in\mathbb Z_p^*$.
For a prime $p>3$, let $x$ be a rational number such that both
$x$ and $1-x$ are not divisible by $p$ and $1-x$ is a quadratic residue modulo $p$. Take $y$ such
that $y^2\equiv 1-x\pmod p$. Then
$$
\sum_{n=0}^{p-1}\binom{2n}n\biggl(\frac x4\biggr)^n
\equiv 1+\frac{px}{2(1-x)}\bigl(-q(x)+q(y+1)(y+1)-q(y-1)(y-1)\bigr)\pmod{p^2}.
$$
Taking $p\equiv1\pmod 4$ and $x=2$ one obtains a closed form for the left-hand side by means of $y$ which is your square root of $-1$ modulo $p$. Isn't it a curious result?