# Using sage to test for squares in residue fields

Let $K$ be a number field, $x \in \mathcal{O}_K$, and $\mathfrak{p}$ a prime of $K$. I want to find out using sage whether or not the reduction of $x$ modulo $\mathfrak{p}$ is a square in the invertible elements of the residue field at $\mathfrak{p}$.

A primitive way to do this would be to test if $x^{(q-1)/2}-1$ is divisible by $\mathfrak{p}$, but that's too slow. I tried to find a way to reduce $x$ to an element of the quotient, but couldn't.

I could code all the functionality manually, but I'd prefer not to do that.

Can anybody suggest an efficient way to do this using sage?

-
Did you take a look at this? –  Eugene Jun 25 '12 at 2:20
I did look at it, but I didn't find quite what I needed. –  Tony Jun 25 '12 at 2:26
Not even the residue_field method? –  Hurkyl Jun 25 '12 at 2:34
That constructs the residue field. I need to take an element of the ring of integers and make sage reduce it to an element of the residue field. –  Tony Jun 25 '12 at 2:46
What about the residue_symbol method? –  Eugene Jun 25 '12 at 3:43